功能更新

This commit is contained in:
GG Z
2026-02-12 21:29:00 +08:00
parent a9faf251be
commit b3479d1f39
342 changed files with 4671 additions and 2223 deletions

View File

@@ -0,0 +1,695 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- 按钮高亮 -->
<Storyboard x:Key="Button.FocusEffect">
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="border"
Storyboard.TargetProperty="Intensity"
To="1" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
To="1.01" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
To="1.01" />
<BooleanAnimationUsingKeyFrames
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="ShaderEnabled">
<DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
<!-- 按钮取消高亮 -->
<Storyboard x:Key="Button.LeaveEffect">
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="border"
Storyboard.TargetProperty="Intensity"
To="0" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
To="1" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
To="1" />
<BooleanAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="border"
Storyboard.TargetProperty="ShaderEnabled">
<DiscreteBooleanKeyFrame KeyTime="0:0:0.2" Value="False" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
<!-- 按钮按下 -->
<Storyboard x:Key="Button.PressEffect">
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
To="0.99" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
To="0.99" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="border"
Storyboard.TargetProperty="Intensity"
To="0.5" />
</Storyboard>
<!-- 普通按钮,浮动 -->
<Style TargetType="{x:Type ButtonBase}" x:Key="FloatButtonStyle">
<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
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}}"
Margin="0"
RenderTransformOrigin="0.5,0.5"
ShaderEnabled="False"
SnapsToDevicePixels="True"
x:Name="border">
<DockPanel
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<!-- 图标 -->
<ContentPresenter
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
DockPanel.Dock="{Binding Path=(assists:ControlAssist.IconPlacement), RelativeSource={RelativeSource TemplatedParent}}"
Focusable="False"
Margin="0,0,5,0"
RenderTransformOrigin="0.5,0.5"
x:Name="Icon">
<ContentPresenter.RenderTransform>
<RotateTransform />
</ContentPresenter.RenderTransform>
</ContentPresenter>
<!-- 内容 -->
<ContentPresenter
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}"
x:Name="contentPresenter" />
</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 Property="Visibility" TargetName="Icon" Value="Collapsed" />
</Trigger>
<!-- 切换边框效果,显示阴影 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="border" Value="{Binding Path=(assists:ShadingAssist.LightedBorder), RelativeSource={RelativeSource TemplatedParent}}" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Button.FocusEffect}" x:Name="showEffectBegin" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource Button.LeaveEffect}" />
</Trigger.ExitActions>
</Trigger>
<!-- 缩减阴影,下压效果 -->
<Trigger Property="IsPressed" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Button.PressEffect}" x:Name="pressBegin" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="pressBegin" />
</Trigger.ExitActions>
</Trigger>
<!-- 按钮禁用效果 -->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{Binding Path=(assists:ShadingAssist.DisabledBackground), RelativeSource={RelativeSource TemplatedParent}}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" 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 EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource PrimaryNormalColor}" Offset="0" />
<GradientStop Color="Transparent" Offset="0.5" />
<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 EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource InfoColor}" Offset="0" />
<GradientStop Color="Transparent" Offset="0.5" />
<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 EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource ErrorColor}" Offset="0" />
<GradientStop Color="Transparent" Offset="0.5" />
<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 EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource WarningColor}" Offset="0" />
<GradientStop Color="Transparent" Offset="0.5" />
<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 EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource SuccessColor}" Offset="0" />
<GradientStop Color="Transparent" Offset="0.5" />
<LinearGradientBrush.RelativeTransform>
<RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
</LinearGradientBrush.RelativeTransform>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="Button" x:Key="EmbossIconButtonStyle">
<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
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"
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
x:Name="emboss" />
<decorations:SlotBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Height="{TemplateBinding Width}"
Intensity="0"
Margin="0"
ShaderEnabled="False"
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
x:Name="slot">
<ContentPresenter
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</decorations:SlotBorder>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="True" />
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Intensity" TargetName="emboss" Value="1" />
<Setter Property="Foreground" TargetName="slot" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="ShaderEnabled" TargetName="slot" Value="True" />
<Setter Property="Intensity" TargetName="slot" Value="0.6" />
<Setter Property="ShaderEnabled" TargetName="emboss" Value="False" />
<Setter Property="Foreground" TargetName="slot" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="emboss" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
<!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 拟态按钮,按下后显示深度效果 -->
<Style TargetType="{x:Type Button}" x:Key="EmbossButtonStyle">
<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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.8"
ShaderEnabled="True"
x:Name="emboss" />
<decorations:SlotBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0"
Margin="0"
ShaderEnabled="False"
x:Name="slot">
<ContentPresenter
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</decorations:SlotBorder>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="True" />
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Intensity" TargetName="emboss" Value="0.4" />
<Setter Property="Foreground" TargetName="slot" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="ShaderEnabled" TargetName="slot" Value="True" />
<Setter Property="Intensity" TargetName="slot" Value="0.6" />
<Setter Property="ShaderEnabled" TargetName="emboss" Value="False" />
<Setter Property="Foreground" TargetName="slot" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="emboss" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
<!--<Setter TargetName="emboss" Property="ShaderEnabled" Value="False" />-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Button}" x:Key="LightedButtonStyle">
<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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="0"
x:Name="surface">
<ContentPresenter
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</decorations:LightedSurface>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="True" />
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" TargetName="surface" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" TargetName="surface" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="surface" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button" x:Key="IconButtonStyle">
<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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Height="{TemplateBinding Width}"
Margin="0"
Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight}"
x:Name="Border">
<ContentPresenter
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="True" />
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Border" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="Border" Value="{DynamicResource PrimaryPressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="Border" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ButtonBase}" x:Key="ButtonBaseStyle">
<!-- ================= 基础属性设置 ================= -->
<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="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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="True"
x:Name="border" />
<!-- 2. 交互遮罩层:用于变深/变浅 -->
<!-- 默认为透明。Hover时变黑(加深)Press时变白(减淡) -->
<Border
Background="Black"
CornerRadius="4"
IsHitTestVisible="False"
Opacity="0"
x:Name="Overlay" />
<!-- 3. 内容层:文字和图标 -->
<!-- 放在最上层,保证文字不被遮罩影响清晰度,且 Margin 绑定 Padding 撑开大小 -->
<DockPanel
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<ContentPresenter
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"
x:Name="Icon">
<ContentPresenter.RenderTransform>
<RotateTransform />
</ContentPresenter.RenderTransform>
</ContentPresenter>
<ContentPresenter
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}"
x:Name="contentPresenter" />
</DockPanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<!-- 正常状态 -->
<VisualState x:Name="Normal">
<Storyboard>
<DoubleAnimation
Duration="0:0:0.15"
Storyboard.TargetName="Overlay"
Storyboard.TargetProperty="Opacity"
To="0" />
</Storyboard>
</VisualState>
<!-- 悬停状态:颜色加深 -->
<VisualState x:Name="MouseOver">
<Storyboard>
<!-- 遮罩设为黑色,透明度 0.1 => 整体变暗 -->
<ColorAnimation
Duration="0"
Storyboard.TargetName="Overlay"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="Black" />
<DoubleAnimation
Duration="0:0:0.15"
Storyboard.TargetName="Overlay"
Storyboard.TargetProperty="Opacity"
To="0.1" />
</Storyboard>
</VisualState>
<!-- 按下状态:颜色减淡 -->
<VisualState x:Name="Pressed">
<Storyboard>
<!-- 遮罩设为白色,透明度 0.2 => 整体变亮/发白 -->
<ColorAnimation
Duration="0"
Storyboard.TargetName="Overlay"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="White" />
<DoubleAnimation
Duration="0"
Storyboard.TargetName="Overlay"
Storyboard.TargetProperty="Opacity"
To="0.2" />
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation
Duration="0"
Storyboard.TargetName="Overlay"
Storyboard.TargetProperty="Opacity"
To="0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="assists:ControlAssist.Icon" Value="{x:Null}">
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Opacity" TargetName="Icon" 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>