Add ColorPicker

This commit is contained in:
纳边 committed 2018-05-22 15:22:32 +08:00
1 parent 09766e18eb
commit a0b6fc87f9
86 files changed
+8160 -9

No files matched your search

+123
View File
@@ -0,0 +1,123 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="ColorPickerRepeatButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="ColorPickerSliderThumbTemplate" TargetType="{x:Type Thumb}">
<Border Width="13" Height="13" Background="White" CornerRadius="6.5"></Border>
</ControlTemplate>
<ControlTemplate x:Key="ColorPickerSliderHorizontal" TargetType="{x:Type Slider}">
<Grid>
<Border Margin="7,0" Background="{TemplateBinding Background}" MaxHeight="11" CornerRadius="2"></Border>
<Border Margin="7,0" Background="{TemplateBinding Foreground}" MaxHeight="11" CornerRadius="2">
<Border.OpacityMask>
<LinearGradientBrush EndPoint="0,0.5" StartPoint="1,0.5">
<GradientStop Color="Transparent" Offset="1"/>
<GradientStop Color="White" Offset="0"/>
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
<Track x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb x:Name="Thumb" Focusable="False" Height="13" Width="13" OverridesDefaultStyle="True" Template="{StaticResource ColorPickerSliderThumbTemplate}" VerticalAlignment="Center">
<Thumb.Effect>
<DropShadowEffect ShadowDepth="0" Opacity=".6"/>
</Thumb.Effect>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="ColorPickerSliderVertical" TargetType="{x:Type Slider}">
<Grid >
<Border Margin="0,7" CornerRadius="2" MaxWidth="11" Background="{TemplateBinding Background}"></Border>
<Border Margin="0,7" CornerRadius="2" MaxWidth="11" Background="{TemplateBinding Foreground}">
<Border.OpacityMask>
<LinearGradientBrush EndPoint="0,0.5" StartPoint="1,0.5">
<GradientStop Color="Transparent" Offset="1"/>
<GradientStop Color="White" Offset="0"/>
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
<Track x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb x:Name="Thumb" Focusable="False" Height="13" OverridesDefaultStyle="True" Template="{StaticResource ColorPickerSliderThumbTemplate}" VerticalAlignment="Top" Width="13">
<Thumb.Effect>
<DropShadowEffect ShadowDepth="0" Opacity=".6"/>
</Thumb.Effect>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
<Style x:Key="ColorPickerSlider" TargetType="{x:Type Slider}">
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Foreground" Value="Transparent"></Setter>
<Setter Property="Template" Value="{StaticResource ColorPickerSliderHorizontal}"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Template" Value="{StaticResource ColorPickerSliderVertical}"/>
</Trigger>
</Style.Triggers>
</Style>
<LinearGradientBrush x:Key="ColorPickerRainbowBrush">
<GradientStop Color="#ff0000"/>
<GradientStop Color="#ff00ff" Offset="0.167"/>
<GradientStop Color="#0000ff" Offset="0.334"/>
<GradientStop Color="#00ffff" Offset="0.501"/>
<GradientStop Color="#00ff00" Offset="0.668"/>
<GradientStop Color="#ffff00" Offset="0.835"/>
<GradientStop Color="#ff0000" Offset="1"/>
</LinearGradientBrush>
<DrawingBrush x:Key="ColorPickerOpacityBrush" Viewport="0,0,12,11" ViewportUnits="Absolute" Stretch="None" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="#d0cec7">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,6,5" />
<RectangleGeometry Rect="6,6,6,5" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="#e7e7e2">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,5,12,1" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</ResourceDictionary>