|
| 1 | +<Application x:Class="ColorPickerApp.MyApp" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + Startup="AppStartup" |
| 5 | + xmlns:local="clr-namespace:ColorPickerLib;assembly=ColorPickerLib" |
| 6 | + xmlns:app="clr-namespace:ColorPickerApp"> |
| 7 | + |
| 8 | + <Application.Resources> |
| 9 | + |
| 10 | + <local:ColorBrushConverter x:Key="ColorBrushConverter"/> |
| 11 | + <local:ByteDoubleConverter x:Key="ByteDoubleConverter"/> |
| 12 | + |
| 13 | + <!-- |
| 14 | + This Converter is defined in MyApp.xaml.cs |
| 15 | + Notice the ?Mapping? at the top used to import the ColorPickerApp ClrNamespace and the associated xmlns:app. |
| 16 | + --> |
| 17 | + <app:ColorGradientConverter x:Key="ColorGradientConverter"/> |
| 18 | + |
| 19 | +<!--<SnippetSetterValueRef>--> |
| 20 | + |
| 21 | +<!--<SnippetDefaultStyleKeyAsSetter>--> |
| 22 | + <Style x:Key="Slider_RepeatButton" TargetType="{x:Type RepeatButton}"> |
| 23 | + <Setter Property="OverridesDefaultStyle" Value="true" /> |
| 24 | +<!--</SnippetDefaultStyleKeyAsSetter>--> |
| 25 | + <Setter Property="IsTabStop" Value="false" /> |
| 26 | + <Setter Property="Focusable" Value="false" /> |
| 27 | + <Setter Property="Template"> |
| 28 | + <Setter.Value> |
| 29 | + <ControlTemplate TargetType="{x:Type RepeatButton}"> |
| 30 | + <Border Background="Transparent" /> |
| 31 | + </ControlTemplate> |
| 32 | + </Setter.Value> |
| 33 | + </Setter> |
| 34 | +<!--<SnippetDefaultStyleKeyAsSetter2>--> |
| 35 | + </Style> |
| 36 | +<!--</SnippetDefaultStyleKeyAsSetter2>--> |
| 37 | + |
| 38 | +<!--</SnippetSetterValueRef>--> |
| 39 | + |
| 40 | +<!--<SnippetStyleTargetNameRef>--> |
| 41 | + <Style x:Key="Slider_Thumb" TargetType="{x:Type Thumb}"> |
| 42 | + <Setter Property="OverridesDefaultStyle" Value="true" /> |
| 43 | + <Setter Property="Width" Value="14" /> |
| 44 | + <Setter Property="Height" Value="14" /> |
| 45 | + <Setter Property="Template"> |
| 46 | + <Setter.Value> |
| 47 | + <ControlTemplate TargetType="{x:Type Thumb}"> |
| 48 | + <Grid Width="14" Height="14"> |
| 49 | + <Ellipse Fill="{TemplateBinding Foreground}" /> |
| 50 | + <Ellipse Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" x:Name="ThumbCover" > |
| 51 | + <Ellipse.Fill> |
| 52 | + <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
| 53 | + <LinearGradientBrush.GradientStops> |
| 54 | + <GradientStop Color="#CCFFFFFF" Offset="0" /> |
| 55 | + <GradientStop Color="#00000000" Offset=".5" /> |
| 56 | + <GradientStop Color="#66000000" Offset="1" /> |
| 57 | + </LinearGradientBrush.GradientStops> |
| 58 | + </LinearGradientBrush> |
| 59 | + </Ellipse.Fill> |
| 60 | + </Ellipse> |
| 61 | + </Grid> |
| 62 | + <ControlTemplate.Triggers> |
| 63 | + <Trigger Property="IsDragging" Value="true"> |
| 64 | + <Setter TargetName="ThumbCover" Property="Fill"> |
| 65 | + <Setter.Value> |
| 66 | + <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
| 67 | + <LinearGradientBrush.GradientStops> |
| 68 | + <GradientStop Color="#CCFFFFFF" Offset="1" /> |
| 69 | + <GradientStop Color="#00000000" Offset=".5" /> |
| 70 | + <GradientStop Color="#66000000" Offset="0" /> |
| 71 | + </LinearGradientBrush.GradientStops> |
| 72 | + </LinearGradientBrush> |
| 73 | + </Setter.Value> |
| 74 | + </Setter> |
| 75 | + </Trigger> |
| 76 | + </ControlTemplate.Triggers> |
| 77 | + </ControlTemplate> |
| 78 | + </Setter.Value> |
| 79 | + </Setter> |
| 80 | + </Style> |
| 81 | +<!--</SnippetStyleTargetNameRef>--> |
| 82 | + |
| 83 | + <Style x:Key="Slider_CustomStyle" TargetType="{x:Type Slider}"> |
| 84 | + <Setter Property="OverridesDefaultStyle" Value="true" /> |
| 85 | + <Setter Property="Height" Value="14" /> |
| 86 | + <Setter Property="Width" Value="80"/> |
| 87 | + <Setter Property="Margin" Value="1"/> |
| 88 | + <Setter Property="Orientation" Value="Horizontal"/> |
| 89 | + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> |
| 90 | + <Setter Property="Minimum" Value="0"/> |
| 91 | + <Setter Property="Maximum" Value="255"/> |
| 92 | + <Setter Property="SmallChange" Value="1"/> |
| 93 | + <Setter Property="LargeChange" Value="51"/> |
| 94 | + <Setter Property="IsMoveToPointEnabled" Value="true"/> |
| 95 | + <Setter Property="Template"> |
| 96 | + <Setter.Value> |
| 97 | + <ControlTemplate TargetType="{x:Type Slider}"> |
| 98 | + <Grid ClipToBounds="false"> |
| 99 | + <Border Height="6" CornerRadius="3" Background="{TemplateBinding Background}" |
| 100 | + BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" |
| 101 | + Width="{TemplateBinding Width}"/> |
| 102 | + <Track Name="PART_Track"> |
| 103 | + <Track.DecreaseRepeatButton> |
| 104 | + <RepeatButton Style="{StaticResource Slider_RepeatButton}" |
| 105 | + Command="Slider.DecreaseLarge"/> |
| 106 | + </Track.DecreaseRepeatButton> |
| 107 | + <Track.IncreaseRepeatButton> |
| 108 | + <RepeatButton Style="{StaticResource Slider_RepeatButton}" |
| 109 | + Command="Slider.IncreaseLarge"/> |
| 110 | + </Track.IncreaseRepeatButton> |
| 111 | + <Track.Thumb> |
| 112 | + <Thumb x:Name="Thumb" |
| 113 | + Style="{StaticResource Slider_Thumb}"/> |
| 114 | + </Track.Thumb> |
| 115 | + </Track> |
| 116 | + </Grid> |
| 117 | + </ControlTemplate> |
| 118 | + </Setter.Value> |
| 119 | + </Setter> |
| 120 | + </Style> |
| 121 | + |
| 122 | + <LinearGradientBrush x:Key="BorderBackground" EndPoint="0,1" StartPoint="0,0"> |
| 123 | + <LinearGradientBrush.GradientStops> |
| 124 | + <GradientStop Color="#77FFFFFF" Offset="0" /> |
| 125 | + <GradientStop Color="#00FFFFFF" Offset=".15" /> |
| 126 | + <GradientStop Color="#00000000" Offset=".85" /> |
| 127 | + <GradientStop Color="#33000000" Offset="1" /> |
| 128 | + </LinearGradientBrush.GradientStops> |
| 129 | + </LinearGradientBrush> |
| 130 | + |
| 131 | + <LinearGradientBrush x:Key="BorderBrush" EndPoint="0,1" StartPoint="0,0"> |
| 132 | + <LinearGradientBrush.GradientStops> |
| 133 | + <GradientStop Color="#99cccccc" Offset="0" /> |
| 134 | + <GradientStop Color="#99666666" Offset="1" /> |
| 135 | + </LinearGradientBrush.GradientStops> |
| 136 | + </LinearGradientBrush> |
| 137 | + |
| 138 | + <Style x:Key="ColorPicker_CoolStyle" TargetType="{x:Type local:ColorPicker}"> |
| 139 | + <Setter Property="Template"> |
| 140 | + <Setter.Value> |
| 141 | + <ControlTemplate TargetType="{x:Type local:ColorPicker}"> |
| 142 | + |
| 143 | + <Border CornerRadius="5" Background="{TemplateBinding Background}" HorizontalAlignment="Center" VerticalAlignment="Center"> |
| 144 | + <Border BorderThickness="1" CornerRadius="5" Background="{StaticResource BorderBackground}" Padding="3"> |
| 145 | + |
| 146 | + <Grid> |
| 147 | + <Grid.ColumnDefinitions> |
| 148 | + <ColumnDefinition/> |
| 149 | + <ColumnDefinition/> |
| 150 | + </Grid.ColumnDefinitions> |
| 151 | + |
| 152 | + <Grid.RowDefinitions> |
| 153 | + <RowDefinition/> |
| 154 | + <RowDefinition/> |
| 155 | + <RowDefinition/> |
| 156 | + </Grid.RowDefinitions> |
| 157 | + |
| 158 | + <Slider Grid.Column="0" Grid.Row="0" Foreground="red" Style="{StaticResource Slider_CustomStyle}" |
| 159 | + Value="{Binding Path=Red, Converter={StaticResource ByteDoubleConverter}, RelativeSource={RelativeSource TemplatedParent}}" |
| 160 | + Background="{Binding Path=Color, Converter={StaticResource ColorGradientConverter},ConverterParameter=Red, RelativeSource={RelativeSource TemplatedParent}}" |
| 161 | + /> |
| 162 | + <Slider Grid.Column="0" Grid.Row="1" Foreground="green" Style="{StaticResource Slider_CustomStyle}" |
| 163 | + Value="{Binding Path=Green, Converter={StaticResource ByteDoubleConverter}, RelativeSource={RelativeSource TemplatedParent}}" |
| 164 | + Background="{Binding Path=Color, Converter={StaticResource ColorGradientConverter},ConverterParameter=Green, RelativeSource={RelativeSource TemplatedParent}}" |
| 165 | + /> |
| 166 | + <Slider Grid.Column="0" Grid.Row="2" Foreground="blue" Style="{StaticResource Slider_CustomStyle}" |
| 167 | + Value="{Binding Path=Blue, Converter={StaticResource ByteDoubleConverter}, RelativeSource={RelativeSource TemplatedParent}}" |
| 168 | + Background="{Binding Path=Color, Converter={StaticResource ColorGradientConverter},ConverterParameter=Blue, RelativeSource={RelativeSource TemplatedParent}}" |
| 169 | + /> |
| 170 | + |
| 171 | + <Border Grid.Row="0" Grid.RowSpan="3" Grid.Column="2" Width="40" Height="Auto" Margin="5" BorderThickness="1" CornerRadius="5" |
| 172 | + Background="{Binding Path=Color, Converter={StaticResource ColorBrushConverter}, RelativeSource={RelativeSource TemplatedParent}}"/> |
| 173 | + <Border Grid.Row="0" Grid.RowSpan="3" Grid.Column="2" Width="40" Height="Auto" Margin="5" |
| 174 | + BorderThickness="1" CornerRadius="5" Background="{StaticResource BorderBackground}" BorderBrush="{StaticResource BorderBrush}"> |
| 175 | + |
| 176 | + |
| 177 | + </Border> |
| 178 | + </Grid> |
| 179 | + </Border> |
| 180 | + </Border> |
| 181 | + </ControlTemplate> |
| 182 | + </Setter.Value> |
| 183 | + </Setter> |
| 184 | + |
| 185 | + </Style> |
| 186 | + |
| 187 | + </Application.Resources> |
| 188 | +</Application> |
0 commit comments