功能更新

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,523 @@
<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:internal="clr-namespace:Melskin.Converters.Internal"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type controls:ToggleSwitch}" x:Key="FloatToggleSwitchStyle">
<!-- 资源区:定义开关动画 Storyboard -->
<Style.Resources>
<!-- 开关打开动画:圆点滑动到右侧,背景切换为“开”状态 -->
<Storyboard x:Key="ToggleSwitchOn">
<!-- 圆点容器 Margin 动画:从左侧滑到右侧 -->
<ThicknessAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="circleBox"
Storyboard.TargetProperty="Margin">
<LinearThicknessKeyFrame KeyTime="0" Value="0,0,19,0" />
<SplineThicknessKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="0,0,1,0" />
</ThicknessAnimationUsingKeyFrames>
<!-- “关”状态背景渐变消失 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOff"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="1" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<!-- “开”状态背景渐变出现 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOn"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="0" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!-- 开关关闭动画:圆点滑动到左侧,背景切换为“关”状态 -->
<Storyboard x:Key="ToggleSwitchOff">
<!-- 圆点容器 Margin 动画:从右侧滑到左侧 -->
<ThicknessAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="circleBox"
Storyboard.TargetProperty="Margin">
<LinearThicknessKeyFrame KeyTime="0" Value="19,0,0,0" />
<SplineThicknessKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="1,0,0,0" />
</ThicknessAnimationUsingKeyFrames>
<!-- “关”状态背景渐变出现 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOff"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="0" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<!-- “开”状态背景渐变消失 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOn"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="1" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Style.Resources>
<!-- 基础属性设置 -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Margin" Value="4" />
<!--<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />-->
<!-- 控件模板定义 -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<!-- 主容器,固定高度和宽度 -->
<Grid Height="24" Width="42">
<!-- “开”状态背景,初始不可见 -->
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="12"
Opacity="0"
x:Name="borderOn" />
<!-- “关”状态背景,初始可见 -->
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="12"
Opacity="1"
x:Name="borderOff" />
<!-- 圆点容器,初始在左侧 -->
<Grid
Height="20"
HorizontalAlignment="Left"
Margin="1,0,0,0"
Width="20"
x:Name="circleBox">
<!-- 内部圆点,带阴影效果 -->
<Border
Background="{DynamicResource TextAccentBrush}"
CornerRadius="8"
Margin="2"
x:Name="circle">
<Border.Effect>
<DropShadowEffect
BlurRadius="6"
Color="{DynamicResource DarkShadowColor}"
Opacity="0.6"
ShadowDepth="2" />
</Border.Effect>
</Border>
</Grid>
</Grid>
<!-- 状态触发器区 -->
<ControlTemplate.Triggers>
<!-- 默认按钮状态(无特殊效果) -->
<Trigger Property="Button.IsDefaulted" Value="True" />
<!-- 鼠标悬停时,圆点变大并微调边距 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Margin" TargetName="circle" Value="1" />
<Setter Property="CornerRadius" TargetName="circle" Value="9" />
</Trigger>
<!-- 按下时,圆点容器变宽,模拟按压效果 -->
<Trigger Property="IsPressed" Value="True">
<Setter Property="Width" TargetName="circleBox" Value="24" />
</Trigger>
<!-- 选中时,圆点滑到右侧并启动“开”动画,取消选中时启动“关”动画 -->
<Trigger Property="IsChecked" Value="True">
<Setter Property="HorizontalAlignment" TargetName="circleBox" Value="Right" />
<Setter Property="Margin" TargetName="circleBox" Value="0,0,11,0" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ToggleSwitchOn}" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource ToggleSwitchOff}" />
</Trigger.ExitActions>
</Trigger>
<!-- 禁用时,圆点和背景变灰,去除阴影 -->
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="circle" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Effect" TargetName="circle" Value="{x:Null}" />
<Setter Property="Background" TargetName="borderOn" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter Property="Background" TargetName="borderOff" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:ToggleSwitch}">
<!-- 资源区:定义开关动画 Storyboard -->
<Style.Resources>
<!-- 开关打开动画:圆点滑动到右侧,背景切换为“开”状态 -->
<Storyboard x:Key="ToggleSwitchOn">
<!-- 圆点容器 Margin 动画:从左侧滑到右侧 -->
<ThicknessAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="circleBox"
Storyboard.TargetProperty="Margin">
<LinearThicknessKeyFrame KeyTime="0" Value="0,0,19,0" />
<SplineThicknessKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="0,0,1,0" />
</ThicknessAnimationUsingKeyFrames>
<!-- “关”状态背景渐变消失 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOff"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="1" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<!-- “开”状态背景渐变出现 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOn"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="0" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!-- 开关关闭动画:圆点滑动到左侧,背景切换为“关”状态 -->
<Storyboard x:Key="ToggleSwitchOff">
<!-- 圆点容器 Margin 动画:从右侧滑到左侧 -->
<ThicknessAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="circleBox"
Storyboard.TargetProperty="Margin">
<LinearThicknessKeyFrame KeyTime="0" Value="19,0,0,0" />
<SplineThicknessKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="1,0,0,0" />
</ThicknessAnimationUsingKeyFrames>
<!-- “关”状态背景渐变出现 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOff"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="0" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<!-- “开”状态背景渐变消失 -->
<DoubleAnimationUsingKeyFrames
Duration="0:0:0.2"
Storyboard.TargetName="borderOn"
Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame KeyTime="0" Value="1" />
<SplineDoubleKeyFrame
KeySpline="0.8,1 0.8,1"
KeyTime="0:0:0.2"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Style.Resources>
<!-- 基础属性设置 -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="4" />
<!--<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />-->
<!-- 控件模板定义 -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<!-- 主容器,固定高度和宽度 -->
<Grid Height="24" Width="42">
<!-- “开”状态背景,初始不可见 -->
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="12"
Opacity="0"
x:Name="borderOn" />
<!-- “关”状态背景,初始可见 -->
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="12"
Opacity="1"
x:Name="borderOff" />
<!-- 圆点容器,初始在左侧 -->
<Grid
Height="20"
HorizontalAlignment="Left"
Margin="1,0,0,0"
Width="20"
x:Name="circleBox">
<!-- 内部圆点,带阴影效果 -->
<Border
Background="{DynamicResource TextAccentBrush}"
CornerRadius="8"
Margin="2"
x:Name="circle" />
</Grid>
</Grid>
<!-- 状态触发器区 -->
<ControlTemplate.Triggers>
<!-- 默认按钮状态(无特殊效果) -->
<Trigger Property="Button.IsDefaulted" Value="True" />
<!-- 鼠标悬停时,圆点变大并微调边距 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Margin" TargetName="circle" Value="1" />
<Setter Property="CornerRadius" TargetName="circle" Value="9" />
</Trigger>
<!-- 按下时,圆点容器变宽,模拟按压效果 -->
<Trigger Property="IsPressed" Value="True">
<Setter Property="Width" TargetName="circleBox" Value="24" />
</Trigger>
<!--<Trigger Property="IsChecked" Value="False">
<Setter TargetName="circle" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>-->
<!-- 选中时,圆点滑到右侧并启动“开”动画,取消选中时启动“关”动画 -->
<Trigger Property="IsChecked" Value="True">
<Setter Property="HorizontalAlignment" TargetName="circleBox" Value="Right" />
<Setter Property="Margin" TargetName="circleBox" Value="0,0,11,0" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ToggleSwitchOn}" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource ToggleSwitchOff}" />
</Trigger.ExitActions>
</Trigger>
<!-- 禁用时,圆点和背景变灰,去除阴影 -->
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="circle" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" TargetName="borderOn" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter Property="Background" TargetName="borderOff" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:ToggleSwitch}" x:Key="SlotToggleSwitch">
<!-- 基础属性设置 -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
<Setter Property="Margin" Value="4" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<!-- 默认的开关图形尺寸 -->
<Setter Property="MinHeight" Value="24" />
<Setter Property="MinWidth" Value="48" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Background="Transparent" x:Name="templateRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="SwitchContainer">
<Border
Opacity="0"
Visibility="Collapsed"
x:Name="AnimationProxy" />
<!-- 背景层 -->
<decorations:SlotBorder
Background="{TemplateBinding Background}"
CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Intensity="0.3"
Margin="-4"
Padding="0"
x:Name="slot" />
<!-- 内容层 -->
<ContentPresenter
Content="{Binding Path=(assists:ControlAssist.OffContent), RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Right"
Margin="0,0,6,0"
VerticalAlignment="Center"
x:Name="OffContentPresenter">
<ContentPresenter.Opacity>
<Binding
Converter="{x:Static internal:InverseOpacityConverter.Instance}"
ElementName="AnimationProxy"
Path="Opacity" />
</ContentPresenter.Opacity>
</ContentPresenter>
<ContentPresenter
Content="{Binding Path=(assists:ControlAssist.OnContent), RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Left"
Margin="6,0,0,0"
Opacity="{Binding Path=Opacity, ElementName=AnimationProxy}"
VerticalAlignment="Center"
x:Name="OnContentPresenter" />
<!--<Border
x:Name="borderOff"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}" />
<Border
x:Name="borderOn"
Background="{TemplateBinding Foreground}"
CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Opacity="{Binding Path=Opacity, ElementName=AnimationProxy}" />-->
</Grid>
<!-- 滑块层 -->
<Grid
Grid.Column="0"
Height="{Binding Path=ActualHeight, ElementName=SwitchContainer}"
HorizontalAlignment="Left"
Width="{Binding Path=ActualHeight, ElementName=SwitchContainer}"
x:Name="circleBox">
<Grid.RenderTransform>
<TranslateTransform x:Name="circleTranslate">
<TranslateTransform.X>
<MultiBinding Converter="{x:Static internal:ThumbPositionConverter.Instance}">
<Binding ElementName="AnimationProxy" Path="Opacity" />
<Binding ElementName="SwitchContainer" Path="ActualWidth" />
<Binding ElementName="SwitchContainer" Path="ActualHeight" />
</MultiBinding>
</TranslateTransform.X>
</TranslateTransform>
</Grid.RenderTransform>
<decorations:EmbossBorder
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="{Binding Path=ActualHeight, ElementName=SwitchContainer, Converter={x:Static converters:DivideByTwoConverter.Instance}}"
Intensity="0.5"
Margin="-3"
Padding="0"
x:Name="circle">
<!--<Ellipse x:Name="optionMark" Fill="{DynamicResource PrimaryNormalBrush}" />-->
</decorations:EmbossBorder>
</Grid>
<TextBlock
Foreground="{DynamicResource TextPrimaryBrush}"
Grid.Column="1"
Margin="4,0,0,0"
VerticalAlignment="Center"
Visibility="Collapsed"
x:Name="StateTextBlock">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
<Setter Property="Text" Value="{Binding Path=(assists:ControlAssist.OnText), RelativeSource={RelativeSource TemplatedParent}}" />
</DataTrigger>
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
<Setter Property="Text" Value="{Binding Path=(assists:ControlAssist.OffText), RelativeSource={RelativeSource TemplatedParent}}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Effect" TargetName="circle">
<Setter.Value>
<DropShadowEffect
BlurRadius="6"
Color="#33000000"
Opacity="0.25"
ShadowDepth="1" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="circle" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter Property="ShaderEnabled" TargetName="circle" Value="False" />
<Setter Property="Effect" TargetName="circle" Value="{x:Null}" />
<Setter Property="Foreground" TargetName="StateTextBlock" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="OffContentPresenter" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="OnContentPresenter" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" TargetName="slot" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="ShaderEnabled" TargetName="slot" Value="False" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<!--<Setter Property="Opacity" TargetName="AnimationProxy" Value="1.0" />-->
<!--<Setter TargetName="circle" Property="Background" Value="{DynamicResource PrimaryNormalBrush}" />-->
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.25"
Storyboard.TargetName="AnimationProxy"
Storyboard.TargetProperty="Opacity"
To="1.0" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.25"
Storyboard.TargetName="AnimationProxy"
Storyboard.TargetProperty="Opacity"
To="0.0" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="assists:ControlAssist.OnContent" Value="{x:Null}">
<Setter Property="Visibility" TargetName="OnContentPresenter" Value="Collapsed" />
</Trigger>
<Trigger Property="assists:ControlAssist.ShowText" Value="True">
<Setter Property="Visibility" TargetName="StateTextBlock" Value="Visible" />
<Setter Property="MinWidth" Value="64" />
</Trigger>
<Trigger Property="assists:ControlAssist.OffContent" Value="{x:Null}">
<Setter Property="Visibility" TargetName="OffContentPresenter" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>