697 lines
44 KiB
XML
697 lines
44 KiB
XML
<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:decorations="clr-namespace:Melskin.Controls.Decorations"
|
||
xmlns:markup="clr-namespace:Melskin.Markup">
|
||
<ResourceDictionary.MergedDictionaries>
|
||
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
|
||
</ResourceDictionary.MergedDictionaries>
|
||
<!-- 按钮高亮 -->
|
||
<Storyboard x:Key="Button.FocusEffect">
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="Intensity"
|
||
To="1"
|
||
Duration="0:0:0.2" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
|
||
To="1.01"
|
||
Duration="0" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
|
||
To="1.01"
|
||
Duration="0" />
|
||
<BooleanAnimationUsingKeyFrames
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="ShaderEnabled"
|
||
Duration="0">
|
||
<DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
|
||
</BooleanAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
<!-- 按钮取消高亮 -->
|
||
<Storyboard x:Key="Button.LeaveEffect">
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="Intensity"
|
||
To="0"
|
||
Duration="0:0:0.2" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
|
||
To="1"
|
||
Duration="0" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
|
||
To="1"
|
||
Duration="0" />
|
||
<BooleanAnimationUsingKeyFrames
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="ShaderEnabled"
|
||
Duration="0:0:0.2">
|
||
<DiscreteBooleanKeyFrame KeyTime="0:0:0.2" Value="False" />
|
||
</BooleanAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
<!-- 按钮按下 -->
|
||
<Storyboard x:Key="Button.PressEffect">
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
|
||
To="0.99"
|
||
Duration="0" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
|
||
To="0.99"
|
||
Duration="0" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="border"
|
||
Storyboard.TargetProperty="Intensity"
|
||
To="0.5"
|
||
Duration="0" />
|
||
</Storyboard>
|
||
|
||
|
||
|
||
|
||
|
||
<!-- 普通按钮,浮动 -->
|
||
<Style x:Key="FloatButtonStyle" TargetType="{x:Type ButtonBase}">
|
||
<Setter Property="assists:ControlAssist.AppearanceType" Value="None" />
|
||
<Setter Property="assists:ControlAssist.IconPlacement" Value="Left" />
|
||
<Setter Property="assists:ControlAssist.IsRunning" Value="False" />
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource LightShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledBackground" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{DynamicResource TextDisabledBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightedBorder" Value="{DynamicResource BorderGradientBrush}" />
|
||
<Setter Property="BorderThickness" Value="1" />
|
||
<Setter Property="FontSize" Value="14" />
|
||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||
<Setter Property="Padding" Value="10,4" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type ButtonBase}">
|
||
<decorations:EmbossBorder
|
||
x:Name="border"
|
||
Margin="0"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4"
|
||
DarkShadowBrush="{Binding Path=(assists:ShadingAssist.DarkShadowBrush), RelativeSource={RelativeSource TemplatedParent}}"
|
||
Intensity="0"
|
||
LightShadowBrush="{Binding Path=(assists:ShadingAssist.LightShadowBrush), RelativeSource={RelativeSource TemplatedParent}}"
|
||
RenderTransformOrigin="0.5,0.5"
|
||
ShaderEnabled="False"
|
||
SnapsToDevicePixels="True">
|
||
<DockPanel
|
||
Margin="{TemplateBinding Padding}"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||
<!-- 图标 -->
|
||
<ContentPresenter
|
||
x:Name="Icon"
|
||
Margin="0,0,5,0"
|
||
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
|
||
DockPanel.Dock="{Binding Path=(assists:ControlAssist.IconPlacement), RelativeSource={RelativeSource TemplatedParent}}"
|
||
Focusable="False"
|
||
RenderTransformOrigin="0.5,0.5">
|
||
<ContentPresenter.RenderTransform>
|
||
<RotateTransform />
|
||
</ContentPresenter.RenderTransform>
|
||
</ContentPresenter>
|
||
<!-- 内容 -->
|
||
<ContentPresenter
|
||
x:Name="contentPresenter"
|
||
Focusable="False"
|
||
RecognizesAccessKey="True"
|
||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||
</DockPanel>
|
||
<decorations:EmbossBorder.RenderTransform>
|
||
<TransformGroup>
|
||
<ScaleTransform />
|
||
<SkewTransform />
|
||
<RotateTransform />
|
||
<TranslateTransform />
|
||
</TransformGroup>
|
||
</decorations:EmbossBorder.RenderTransform>
|
||
</decorations:EmbossBorder>
|
||
|
||
<ControlTemplate.Triggers>
|
||
<!-- 前缀图标可见性 -->
|
||
<Trigger Property="assists:ControlAssist.Icon" Value="{x:Null}">
|
||
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
|
||
</Trigger>
|
||
<!-- 切换边框效果,显示阴影 -->
|
||
<Trigger Property="IsMouseOver" Value="True">
|
||
<Setter TargetName="border" Property="BorderBrush" Value="{Binding Path=(assists:ShadingAssist.LightedBorder), RelativeSource={RelativeSource TemplatedParent}}" />
|
||
<Trigger.EnterActions>
|
||
<BeginStoryboard x:Name="showEffectBegin" Storyboard="{StaticResource Button.FocusEffect}" />
|
||
</Trigger.EnterActions>
|
||
<Trigger.ExitActions>
|
||
<BeginStoryboard Storyboard="{StaticResource Button.LeaveEffect}" />
|
||
</Trigger.ExitActions>
|
||
</Trigger>
|
||
<!-- 缩减阴影,下压效果 -->
|
||
<Trigger Property="IsPressed" Value="True">
|
||
<Trigger.EnterActions>
|
||
<BeginStoryboard x:Name="pressBegin" Storyboard="{StaticResource Button.PressEffect}" />
|
||
</Trigger.EnterActions>
|
||
<Trigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="pressBegin" />
|
||
</Trigger.ExitActions>
|
||
</Trigger>
|
||
<!-- 按钮禁用效果 -->
|
||
<Trigger Property="IsEnabled" Value="false">
|
||
<Setter TargetName="border" Property="Background" Value="{Binding Path=(assists:ShadingAssist.DisabledBackground), RelativeSource={RelativeSource TemplatedParent}}" />
|
||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{Binding Path=(assists:ShadingAssist.DisabledForeground), RelativeSource={RelativeSource TemplatedParent}}" />
|
||
</Trigger>
|
||
|
||
<DataTrigger Binding="{Binding Path=(assists:ControlAssist.IsRunning), RelativeSource={RelativeSource Self}}" Value="True">
|
||
<Setter Property="assists:ControlAssist.Icon" Value="{markup:Icon SymbolValue=ProgressActivity}" />
|
||
<Setter Property="assists:ControlAssist.IconPlacement" Value="Right" />
|
||
<DataTrigger.EnterActions>
|
||
<BeginStoryboard Storyboard="{StaticResource LoadingAnimation}" />
|
||
</DataTrigger.EnterActions>
|
||
<DataTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="LoadingAnimation" />
|
||
</DataTrigger.ExitActions>
|
||
</DataTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
<Style.Triggers>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Primary}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource PrimaryLightShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource PrimaryDarkShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledBackground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
<!--<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{DynamicResource TextDisabledBrush}" />-->
|
||
<Setter Property="assists:ShadingAssist.LightedBorder">
|
||
<Setter.Value>
|
||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||
<GradientStop Offset="0" Color="{DynamicResource PrimaryNormalColor}" />
|
||
<GradientStop Offset="0.5" Color="Transparent" />
|
||
<LinearGradientBrush.RelativeTransform>
|
||
<RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
|
||
</LinearGradientBrush.RelativeTransform>
|
||
</LinearGradientBrush>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Info}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource InfoBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource InfoLightShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource InfoDarkShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledBackground" Value="{DynamicResource InfoDisabledBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightedBorder">
|
||
<Setter.Value>
|
||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||
<GradientStop Offset="0" Color="{DynamicResource InfoColor}" />
|
||
<GradientStop Offset="0.5" Color="Transparent" />
|
||
<LinearGradientBrush.RelativeTransform>
|
||
<RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
|
||
</LinearGradientBrush.RelativeTransform>
|
||
</LinearGradientBrush>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Error}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource ErrorBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource ErrorLightShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource ErrorDarkShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledBackground" Value="{DynamicResource ErrorDisabledBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightedBorder">
|
||
<Setter.Value>
|
||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||
<GradientStop Offset="0" Color="{DynamicResource ErrorColor}" />
|
||
<GradientStop Offset="0.5" Color="Transparent" />
|
||
<LinearGradientBrush.RelativeTransform>
|
||
<RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
|
||
</LinearGradientBrush.RelativeTransform>
|
||
</LinearGradientBrush>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Warning}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource WarningBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource WarningLightShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource WarningDarkShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledBackground" Value="{DynamicResource WarningDisabledBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightedBorder">
|
||
<Setter.Value>
|
||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||
<GradientStop Offset="0" Color="{DynamicResource WarningColor}" />
|
||
<GradientStop Offset="0.5" Color="Transparent" />
|
||
<LinearGradientBrush.RelativeTransform>
|
||
<RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
|
||
</LinearGradientBrush.RelativeTransform>
|
||
</LinearGradientBrush>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Success}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource SuccessBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource SuccessLightShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource SuccessDarkShadowBrush}" />
|
||
<Setter Property="assists:ShadingAssist.DisabledBackground" Value="{DynamicResource SuccessDisabledBrush}" />
|
||
<Setter Property="assists:ShadingAssist.LightedBorder">
|
||
<Setter.Value>
|
||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||
<GradientStop Offset="0" Color="{DynamicResource SuccessColor}" />
|
||
<GradientStop Offset="0.5" Color="Transparent" />
|
||
<LinearGradientBrush.RelativeTransform>
|
||
<RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
|
||
</LinearGradientBrush.RelativeTransform>
|
||
</LinearGradientBrush>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Trigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
|
||
<Style x:Key="EmbossIconButtonStyle" TargetType="Button">
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||
<Setter Property="assists:ControlAssist.Icon" Value="{x:Null}" />
|
||
<Setter Property="BorderThickness" Value="0" />
|
||
<Setter Property="FontSize" Value="14" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type Button}">
|
||
<Grid>
|
||
<decorations:EmbossBorder
|
||
x:Name="emboss"
|
||
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
|
||
Intensity="0.8"
|
||
ShaderEnabled="True" />
|
||
<decorations:SlotBorder
|
||
x:Name="slot"
|
||
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
|
||
Height="{TemplateBinding Width}"
|
||
Margin="0"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
|
||
Intensity="0"
|
||
ShaderEnabled="False">
|
||
<ContentPresenter
|
||
x:Name="contentPresenter"
|
||
Margin="{TemplateBinding Padding}"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
|
||
Focusable="False"
|
||
RecognizesAccessKey="True"
|
||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||
</decorations:SlotBorder>
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="Button.IsDefaulted" Value="True" />
|
||
<Trigger Property="IsMouseOver" Value="True">
|
||
<Setter TargetName="emboss" Property="Intensity" Value="1" />
|
||
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsPressed" Value="True">
|
||
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
|
||
<Setter TargetName="slot" Property="Intensity" Value="0.6" />
|
||
<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />
|
||
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter TargetName="emboss" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||
<!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />-->
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<!-- 拟态按钮,按下后显示深度效果 -->
|
||
<Style x:Key="EmbossButtonStyle" TargetType="{x:Type Button}">
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||
<Setter Property="BorderThickness" Value="0" />
|
||
<Setter Property="Padding" Value="10,4" />
|
||
<Setter Property="FontSize" Value="14" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type Button}">
|
||
<Grid>
|
||
<decorations:EmbossBorder
|
||
x:Name="emboss"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Intensity="0.8"
|
||
ShaderEnabled="True" />
|
||
<decorations:SlotBorder
|
||
x:Name="slot"
|
||
Margin="0"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Intensity="0"
|
||
ShaderEnabled="False">
|
||
<ContentPresenter
|
||
x:Name="contentPresenter"
|
||
Margin="{TemplateBinding Padding}"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||
Focusable="False"
|
||
RecognizesAccessKey="True"
|
||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||
</decorations:SlotBorder>
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="Button.IsDefaulted" Value="True" />
|
||
|
||
<Trigger Property="IsMouseOver" Value="True">
|
||
<Setter TargetName="emboss" Property="Intensity" Value="0.4" />
|
||
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsPressed" Value="True">
|
||
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
|
||
<Setter TargetName="slot" Property="Intensity" Value="0.6" />
|
||
<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />
|
||
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter TargetName="emboss" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||
<!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />-->
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<Style x:Key="LightedButtonStyle" TargetType="{x:Type Button}">
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||
<Setter Property="BorderThickness" Value="0" />
|
||
<Setter Property="Padding" Value="10,4" />
|
||
<Setter Property="FontSize" Value="14" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type Button}">
|
||
<Grid>
|
||
<decorations:LightedSurface
|
||
x:Name="surface"
|
||
Margin="0"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}">
|
||
<ContentPresenter
|
||
x:Name="contentPresenter"
|
||
Margin="{TemplateBinding Padding}"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||
Focusable="False"
|
||
RecognizesAccessKey="True"
|
||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||
</decorations:LightedSurface>
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="Button.IsDefaulted" Value="True" />
|
||
<Trigger Property="IsMouseOver" Value="True">
|
||
<Setter TargetName="surface" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsPressed" Value="True">
|
||
<Setter TargetName="surface" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter TargetName="surface" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<Style x:Key="IconButtonStyle" TargetType="Button">
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||
<Setter Property="assists:ControlAssist.Icon" Value="{x:Null}" />
|
||
<Setter Property="BorderThickness" Value="1" />
|
||
<Setter Property="FontSize" Value="14" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type Button}">
|
||
<Border
|
||
x:Name="Border"
|
||
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
|
||
Height="{TemplateBinding Width}"
|
||
Margin="0"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}">
|
||
<ContentPresenter
|
||
x:Name="contentPresenter"
|
||
Margin="{TemplateBinding Padding}"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
|
||
Focusable="False"
|
||
RecognizesAccessKey="True"
|
||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="Button.IsDefaulted" Value="True" />
|
||
<Trigger Property="IsMouseOver" Value="True">
|
||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsPressed" Value="True">
|
||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PrimaryPressedBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<Style x:Key="ButtonBaseStyle" TargetType="{x:Type ButtonBase}">
|
||
<!-- ================= 基础属性设置 ================= -->
|
||
<Setter Property="assists:ControlAssist.AppearanceType" Value="None" />
|
||
<Setter Property="assists:ControlAssist.IconPlacement" Value="Left" />
|
||
<Setter Property="assists:ControlAssist.IsRunning" Value="False" />
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
<Setter Property="BorderThickness" Value="1" />
|
||
<Setter Property="FontSize" Value="14" />
|
||
<Setter Property="VerticalAlignment" Value="Center" />
|
||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||
<Setter Property="Padding" Value="12,8" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type ButtonBase}">
|
||
<!-- 根 Grid:用于图层叠加 -->
|
||
<Grid x:Name="RootGrid">
|
||
<!-- 1. 底色层:显示按钮实际颜色 -->
|
||
<Border
|
||
x:Name="border"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4"
|
||
SnapsToDevicePixels="True" />
|
||
|
||
<!-- 2. 交互遮罩层:用于变深/变浅 -->
|
||
<!-- 默认为透明。Hover时变黑(加深),Press时变白(减淡) -->
|
||
<Border
|
||
x:Name="Overlay"
|
||
Background="Black"
|
||
CornerRadius="4"
|
||
IsHitTestVisible="False"
|
||
Opacity="0" />
|
||
|
||
<!-- 3. 内容层:文字和图标 -->
|
||
<!-- 放在最上层,保证文字不被遮罩影响清晰度,且 Margin 绑定 Padding 撑开大小 -->
|
||
<DockPanel
|
||
Margin="{TemplateBinding Padding}"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||
|
||
<ContentPresenter
|
||
x:Name="Icon"
|
||
Margin="0,0,5,0"
|
||
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
|
||
DockPanel.Dock="{Binding Path=(assists:ControlAssist.IconPlacement), RelativeSource={RelativeSource TemplatedParent}}"
|
||
Focusable="False"
|
||
RenderTransformOrigin="0.5,0.5">
|
||
<ContentPresenter.RenderTransform>
|
||
<RotateTransform />
|
||
</ContentPresenter.RenderTransform>
|
||
</ContentPresenter>
|
||
<ContentPresenter
|
||
x:Name="contentPresenter"
|
||
Focusable="False"
|
||
RecognizesAccessKey="True"
|
||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||
</DockPanel>
|
||
|
||
<VisualStateManager.VisualStateGroups>
|
||
<VisualStateGroup x:Name="CommonStates">
|
||
<!-- 正常状态 -->
|
||
<VisualState x:Name="Normal">
|
||
<Storyboard>
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="Overlay"
|
||
Storyboard.TargetProperty="Opacity"
|
||
To="0"
|
||
Duration="0:0:0.15" />
|
||
</Storyboard>
|
||
</VisualState>
|
||
|
||
<!-- 悬停状态:颜色加深 -->
|
||
<VisualState x:Name="MouseOver">
|
||
<Storyboard>
|
||
<!-- 遮罩设为黑色,透明度 0.1 => 整体变暗 -->
|
||
<ColorAnimation
|
||
Storyboard.TargetName="Overlay"
|
||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
|
||
To="Black"
|
||
Duration="0" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="Overlay"
|
||
Storyboard.TargetProperty="Opacity"
|
||
To="0.1"
|
||
Duration="0:0:0.15" />
|
||
</Storyboard>
|
||
</VisualState>
|
||
|
||
<!-- 按下状态:颜色减淡 -->
|
||
<VisualState x:Name="Pressed">
|
||
<Storyboard>
|
||
<!-- 遮罩设为白色,透明度 0.2 => 整体变亮/发白 -->
|
||
<ColorAnimation
|
||
Storyboard.TargetName="Overlay"
|
||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
|
||
To="White"
|
||
Duration="0" />
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="Overlay"
|
||
Storyboard.TargetProperty="Opacity"
|
||
To="0.2"
|
||
Duration="0" />
|
||
</Storyboard>
|
||
</VisualState>
|
||
|
||
<VisualState x:Name="Disabled">
|
||
<Storyboard>
|
||
<DoubleAnimation
|
||
Storyboard.TargetName="Overlay"
|
||
Storyboard.TargetProperty="Opacity"
|
||
To="0"
|
||
Duration="0" />
|
||
</Storyboard>
|
||
</VisualState>
|
||
</VisualStateGroup>
|
||
</VisualStateManager.VisualStateGroups>
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="assists:ControlAssist.Icon" Value="{x:Null}">
|
||
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
|
||
</Trigger>
|
||
|
||
<Trigger Property="IsEnabled" Value="false">
|
||
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||
<Setter TargetName="Icon" Property="Opacity" Value="0.5" />
|
||
</Trigger>
|
||
|
||
<DataTrigger Binding="{Binding Path=(assists:ControlAssist.IsRunning), RelativeSource={RelativeSource Self}}" Value="True">
|
||
<Setter Property="assists:ControlAssist.Icon" Value="{markup:Icon SymbolValue=ProgressActivity}" />
|
||
<Setter Property="assists:ControlAssist.IconPlacement" Value="Right" />
|
||
<DataTrigger.EnterActions>
|
||
<BeginStoryboard Storyboard="{StaticResource LoadingAnimation}" />
|
||
</DataTrigger.EnterActions>
|
||
<DataTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="LoadingAnimation" />
|
||
</DataTrigger.ExitActions>
|
||
</DataTrigger>
|
||
</ControlTemplate.Triggers>
|
||
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
|
||
<Style.Triggers>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Primary}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Info}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource InfoBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Error}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource ErrorBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Warning}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource WarningBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="assists:ControlAssist.AppearanceType" Value="{x:Static controls:AppearanceType.Success}">
|
||
<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource SuccessBrush}" />
|
||
</Trigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
<!-- 重复按钮 -->
|
||
<Style BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}" />
|
||
<Style BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type RepeatButton}" />
|
||
|
||
</ResourceDictionary> |