整理代码
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:assists="clr-namespace:Melskin.Assists"
|
||||
xmlns:controls="clr-namespace:Melskin.Controls"
|
||||
xmlns:converters="clr-namespace:Melskin.Converters"
|
||||
xmlns:internal="clr-namespace:Melskin.Converters.Internal"
|
||||
xmlns:markup="clr-namespace:Melskin.Markup"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:markup="clr-namespace:Melskin.Markup">
|
||||
<!-- 1. ColorPanel 样式 -->
|
||||
<Style TargetType="{x:Type controls:ColorPanel}">
|
||||
<Setter Property="Padding" Value="4" />
|
||||
@@ -43,38 +43,38 @@
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}" />
|
||||
<!-- Effect="{DynamicResource PopupShadow}" -->
|
||||
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
|
||||
Effect="{DynamicResource PopupShadow}" />
|
||||
<StackPanel Margin="{TemplateBinding Padding}">
|
||||
<Canvas
|
||||
ClipToBounds="True"
|
||||
x:Name="PART_ColorCanvas"
|
||||
Height="150"
|
||||
x:Name="PART_ColorCanvas">
|
||||
ClipToBounds="True">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Hue, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:HueToBrushConverter.Instance}}"
|
||||
Width="{Binding ActualWidth, ElementName=PART_ColorCanvas}"
|
||||
Height="{Binding ActualHeight, ElementName=PART_ColorCanvas}"
|
||||
Width="{Binding ActualWidth, ElementName=PART_ColorCanvas}" />
|
||||
<Rectangle Height="{Binding ActualHeight, ElementName=PART_ColorCanvas}" Width="{Binding ActualWidth, ElementName=PART_ColorCanvas}">
|
||||
Fill="{Binding Path=Hue, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:HueToBrushConverter.Instance}}" />
|
||||
<Rectangle Width="{Binding ActualWidth, ElementName=PART_ColorCanvas}" Height="{Binding ActualHeight, ElementName=PART_ColorCanvas}">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="White" Offset="0" />
|
||||
<GradientStop Color="Transparent" Offset="1" />
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||||
<GradientStop Offset="0" Color="White" />
|
||||
<GradientStop Offset="1" Color="Transparent" />
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<Rectangle Height="{Binding ActualHeight, ElementName=PART_ColorCanvas}" Width="{Binding ActualWidth, ElementName=PART_ColorCanvas}">
|
||||
<Rectangle Width="{Binding ActualWidth, ElementName=PART_ColorCanvas}" Height="{Binding ActualHeight, ElementName=PART_ColorCanvas}">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="Transparent" Offset="0" />
|
||||
<GradientStop Color="Black" Offset="1" />
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientStop Offset="0" Color="Transparent" />
|
||||
<GradientStop Offset="1" Color="Black" />
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<Thumb
|
||||
Height="16"
|
||||
Margin="-8,-8,0,0"
|
||||
x:Name="PART_ColorSelector"
|
||||
Width="16"
|
||||
x:Name="PART_ColorSelector">
|
||||
Height="16"
|
||||
Margin="-8,-8,0,0">
|
||||
<Thumb.Template>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Grid>
|
||||
@@ -83,8 +83,8 @@
|
||||
Stroke="{DynamicResource BackgroundFloatingBrush}"
|
||||
StrokeThickness="2" />
|
||||
<Ellipse
|
||||
Fill="Transparent"
|
||||
Margin="1"
|
||||
Fill="Transparent"
|
||||
Stroke="{DynamicResource ControlBackgroundNormalBrush}"
|
||||
StrokeThickness="1" />
|
||||
</Grid>
|
||||
@@ -107,14 +107,14 @@
|
||||
Style="{DynamicResource ColorSliderStyle}"
|
||||
Value="{Binding Hue, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
|
||||
<Slider.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="Red" Offset="0.0" />
|
||||
<GradientStop Color="Yellow" Offset="0.166" />
|
||||
<GradientStop Color="Green" Offset="0.333" />
|
||||
<GradientStop Color="Cyan" Offset="0.5" />
|
||||
<GradientStop Color="Blue" Offset="0.666" />
|
||||
<GradientStop Color="Magenta" Offset="0.833" />
|
||||
<GradientStop Color="Red" Offset="1.0" />
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||||
<GradientStop Offset="0.0" Color="Red" />
|
||||
<GradientStop Offset="0.166" Color="Yellow" />
|
||||
<GradientStop Offset="0.333" Color="Green" />
|
||||
<GradientStop Offset="0.5" Color="Cyan" />
|
||||
<GradientStop Offset="0.666" Color="Blue" />
|
||||
<GradientStop Offset="0.833" Color="Magenta" />
|
||||
<GradientStop Offset="1.0" Color="Red" />
|
||||
</LinearGradientBrush>
|
||||
</Slider.Background>
|
||||
</Slider>
|
||||
@@ -125,8 +125,8 @@
|
||||
Style="{DynamicResource ColorSliderStyle}"
|
||||
Value="{Binding Alpha, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
|
||||
<Slider.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="Transparent" Offset="0.0" />
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||||
<GradientStop Offset="0.0" Color="Transparent" />
|
||||
<GradientStop Offset="1.0">
|
||||
<GradientStop.Color>
|
||||
<Binding
|
||||
@@ -141,13 +141,13 @@
|
||||
</StackPanel>
|
||||
|
||||
<Border
|
||||
Grid.Column="1"
|
||||
Width="36"
|
||||
Height="36"
|
||||
Background="{DynamicResource CheckerboardBrushLarge}"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
Grid.Column="1"
|
||||
Height="36"
|
||||
Width="36">
|
||||
CornerRadius="4">
|
||||
<Rectangle RadiusX="3" RadiusY="3">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
@@ -162,11 +162,11 @@
|
||||
<ColumnDefinition Width="64" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox
|
||||
x:Name="ColorModeComboBox"
|
||||
Grid.Column="0"
|
||||
HorizontalContentAlignment="Center"
|
||||
ItemsSource="{markup:EnumSource EnumType=controls:ColorInputMode}"
|
||||
SelectedItem="{Binding ColorInputMode, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
x:Name="ColorModeComboBox" />
|
||||
SelectedItem="{Binding ColorInputMode, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
|
||||
<ContentControl Grid.Column="1">
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
@@ -186,12 +186,12 @@
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
<TextBox
|
||||
x:Name="AlphaTextBox"
|
||||
Grid.Column="2"
|
||||
HorizontalContentAlignment="Center"
|
||||
Text="{Binding Alpha, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:AlphaToPercentConverter.Instance}, UpdateSourceTrigger=PropertyChanged}"
|
||||
x:Name="AlphaTextBox" />
|
||||
Text="{Binding Alpha, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:AlphaToPercentConverter.Instance}, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid>
|
||||
<ItemsControl ItemsSource="{Binding PresetColors, RelativeSource={RelativeSource TemplatedParent}}" Margin="0,12,0,-6">
|
||||
<ItemsControl Margin="0,12,0,-6" ItemsSource="{Binding PresetColors, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
@@ -200,12 +200,12 @@
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button
|
||||
Command="{Binding SelectPresetColorCommand, RelativeSource={RelativeSource AncestorType=controls:ColorPanel}}"
|
||||
CommandParameter="{Binding}"
|
||||
Width="22"
|
||||
Height="22"
|
||||
Margin="0,0,8,8"
|
||||
ToolTip="{Binding}"
|
||||
Width="22">
|
||||
Command="{Binding SelectPresetColorCommand, RelativeSource={RelativeSource AncestorType=controls:ColorPanel}}"
|
||||
CommandParameter="{Binding}"
|
||||
ToolTip="{Binding}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:assists="clr-namespace:Melskin.Assists"
|
||||
xmlns:controls="clr-namespace:Melskin.Controls"
|
||||
xmlns:effects="clr-namespace:Melskin.Effects"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:effects="clr-namespace:Melskin.Effects">
|
||||
<!-- 两种尺寸的棋盘格 -->
|
||||
<DrawingBrush
|
||||
x:Key="CheckerboardBrushLarge"
|
||||
TileMode="Tile"
|
||||
Viewport="0,0,16,16"
|
||||
ViewportUnits="Absolute"
|
||||
x:Key="CheckerboardBrushLarge">
|
||||
ViewportUnits="Absolute">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="White">
|
||||
@@ -32,10 +32,10 @@
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
<DrawingBrush
|
||||
x:Key="CheckerboardBrushSmall"
|
||||
TileMode="Tile"
|
||||
Viewport="0,0,8,8"
|
||||
ViewportUnits="Absolute"
|
||||
x:Key="CheckerboardBrushSmall">
|
||||
ViewportUnits="Absolute">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="White">
|
||||
@@ -58,7 +58,7 @@
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
|
||||
<Style TargetType="{x:Type RepeatButton}" x:Key="SliderRepeatButtonStyle">
|
||||
<Style x:Key="SliderRepeatButtonStyle" TargetType="{x:Type RepeatButton}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||
@@ -68,7 +68,7 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type Slider}" x:Key="ColorSliderStyle">
|
||||
<Style x:Key="ColorSliderStyle" TargetType="{x:Type Slider}">
|
||||
<Setter Property="Height" Value="16" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
@@ -76,9 +76,9 @@
|
||||
<ControlTemplate TargetType="{x:Type Slider}">
|
||||
<Grid>
|
||||
<Grid
|
||||
x:Name="TrackBackground"
|
||||
Height="8"
|
||||
Margin="6,0"
|
||||
x:Name="TrackBackground">
|
||||
Margin="6,0">
|
||||
<Rectangle
|
||||
Fill="{StaticResource CheckerboardBrushSmall}"
|
||||
RadiusX="4"
|
||||
@@ -97,9 +97,9 @@
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Width="12"
|
||||
Height="12"
|
||||
Width="12">
|
||||
FocusVisualStyle="{x:Null}">
|
||||
<Thumb.Template>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Grid>
|
||||
@@ -110,9 +110,9 @@
|
||||
<Ellipse.Effect>
|
||||
<DropShadowEffect
|
||||
BlurRadius="2"
|
||||
Color="{DynamicResource DarkShadowColor}"
|
||||
Opacity="0.8"
|
||||
ShadowDepth="0" />
|
||||
ShadowDepth="0"
|
||||
Color="{DynamicResource DarkShadowColor}" />
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
</Grid>
|
||||
@@ -139,11 +139,11 @@
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border
|
||||
x:Name="border"
|
||||
Background="{StaticResource CheckerboardBrushLarge}"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
x:Name="border">
|
||||
CornerRadius="4">
|
||||
<Rectangle RadiusX="3" RadiusY="3">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Path=SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:ColorPicker}}" />
|
||||
@@ -164,13 +164,13 @@
|
||||
<effects:BrightnessContrastEffect Brightness="0.08" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Effect" TargetName="border">
|
||||
<Setter TargetName="border" Property="Effect">
|
||||
<Setter.Value>
|
||||
<DropShadowEffect
|
||||
BlurRadius="0"
|
||||
Color="{DynamicResource DarkShadowColor}"
|
||||
Opacity="0.4"
|
||||
ShadowDepth="0" />
|
||||
ShadowDepth="0"
|
||||
Color="{DynamicResource DarkShadowColor}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
@@ -187,18 +187,18 @@
|
||||
</ToggleButton>
|
||||
|
||||
<Popup
|
||||
x:Name="PART_Popup"
|
||||
assists:BehaviorAssist.SimulateNativeBehavior="True"
|
||||
AllowsTransparency="True"
|
||||
IsOpen="{Binding IsChecked, ElementName=PART_Trigger, Mode=TwoWay}"
|
||||
Placement="Bottom"
|
||||
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
|
||||
PopupAnimation="None"
|
||||
StaysOpen="True"
|
||||
assists:BehaviorAssist.SimulateNativeBehavior="True"
|
||||
x:Name="PART_Popup">
|
||||
StaysOpen="True">
|
||||
<Border
|
||||
Margin="4"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Margin="4">
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<controls:ColorPanel
|
||||
Margin="8"
|
||||
PresetColors="{Binding Path=PlacementTarget.PresetColors, RelativeSource={RelativeSource AncestorType=Popup}}"
|
||||
|
||||
Reference in New Issue
Block a user