2025-07-31 20:12:01 +08:00
|
|
|
<ResourceDictionary
|
|
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
2025-07-31 20:12:24 +08:00
|
|
|
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
|
|
|
|
|
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
|
2025-07-31 20:12:01 +08:00
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
|
|
|
|
|
|
|
|
<ResourceDictionary.MergedDictionaries>
|
2025-07-31 20:12:24 +08:00
|
|
|
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Converters.xaml" />
|
|
|
|
|
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Animations.xaml" />
|
2025-07-31 20:12:01 +08:00
|
|
|
</ResourceDictionary.MergedDictionaries>
|
|
|
|
|
|
|
|
|
|
<Style x:Key="Ant.SwitchFocusVisualStyle">
|
|
|
|
|
<Setter Property="Control.Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="{x:Type Control}">
|
|
|
|
|
<Border
|
2025-07-31 20:12:24 +08:00
|
|
|
BorderBrush="{DynamicResource AntDesign.Brush.Primary}"
|
2025-07-31 20:12:01 +08:00
|
|
|
BorderThickness="2.5"
|
|
|
|
|
CornerRadius="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource DoubleToCornerRadiusConverter}, ConverterParameter=2}"
|
|
|
|
|
Margin="-2"
|
|
|
|
|
Opacity="0.2" />
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
</Style>
|
|
|
|
|
|
|
|
|
|
<Style TargetType="{x:Type controls:Switch}">
|
|
|
|
|
<Setter Property="MinWidth" Value="44" />
|
|
|
|
|
<Setter Property="Padding" Value="6,0" />
|
|
|
|
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
|
|
|
|
<Setter Property="Height" Value="{DynamicResource SwitchHeight}" />
|
|
|
|
|
<Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" />
|
2025-07-31 20:12:24 +08:00
|
|
|
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.TextQuaternary}" />
|
|
|
|
|
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextOnPrimary}" />
|
2025-07-31 20:12:01 +08:00
|
|
|
<Setter Property="FocusVisualStyle" Value="{StaticResource Ant.SwitchFocusVisualStyle}" />
|
2025-07-31 20:12:24 +08:00
|
|
|
<Setter Property="helpers:AntControl.CornerRadius" Value="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource DoubleToCornerRadiusConverter}, ConverterParameter=2}" />
|
2025-07-31 20:12:01 +08:00
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="{x:Type controls:Switch}">
|
|
|
|
|
<Grid>
|
|
|
|
|
<!-- Effect -->
|
|
|
|
|
<Border
|
2025-07-31 20:12:24 +08:00
|
|
|
BorderBrush="{DynamicResource AntDesign.Brush.Primary}"
|
2025-07-31 20:12:01 +08:00
|
|
|
BorderThickness="0"
|
|
|
|
|
CornerRadius="{Binding CornerRadius, Mode=OneWay, ElementName=Border}"
|
|
|
|
|
Focusable="False"
|
|
|
|
|
Margin="-1"
|
|
|
|
|
Opacity="0.4"
|
|
|
|
|
x:Name="Effect" />
|
|
|
|
|
<!-- Border -->
|
|
|
|
|
<Border
|
|
|
|
|
Background="{TemplateBinding Background}"
|
|
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
|
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
2025-07-31 20:12:24 +08:00
|
|
|
CornerRadius="{Binding Path=(helpers:AntControl.CornerRadius), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
|
2025-07-31 20:12:01 +08:00
|
|
|
x:Name="Border" />
|
|
|
|
|
<!-- Content -->
|
|
|
|
|
<ContentPresenter
|
|
|
|
|
Content="{TemplateBinding UnCheckedContent}"
|
|
|
|
|
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
|
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
|
|
|
|
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
|
|
|
|
HorizontalAlignment="Right"
|
|
|
|
|
Margin="{TemplateBinding Padding}"
|
|
|
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
|
|
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
|
|
|
x:Name="Content" />
|
|
|
|
|
<!-- Dot -->
|
|
|
|
|
<Border
|
|
|
|
|
Background="{TemplateBinding Foreground}"
|
|
|
|
|
CornerRadius="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource DoubleToCornerRadiusConverter}, ConverterParameter=2}"
|
|
|
|
|
Focusable="False"
|
|
|
|
|
Height="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource SubtractionConverter}, ConverterParameter=4}"
|
|
|
|
|
HorizontalAlignment="Left"
|
|
|
|
|
RenderTransformOrigin="0,0"
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
Width="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource Self}}"
|
|
|
|
|
x:Name="PART_Dot">
|
|
|
|
|
<Border.Margin>
|
|
|
|
|
<MultiBinding Converter="{StaticResource DoubleToThicknessMultiConverter}" ConverterParameter="2">
|
|
|
|
|
<Binding
|
|
|
|
|
Mode="OneWay"
|
|
|
|
|
Path="ActualWidth"
|
|
|
|
|
RelativeSource="{RelativeSource TemplatedParent}" />
|
|
|
|
|
<Binding
|
|
|
|
|
Mode="OneWay"
|
|
|
|
|
Path="Height"
|
|
|
|
|
RelativeSource="{RelativeSource Self}" />
|
|
|
|
|
</MultiBinding>
|
|
|
|
|
</Border.Margin>
|
|
|
|
|
<Border.Effect>
|
|
|
|
|
<DropShadowEffect
|
|
|
|
|
BlurRadius="4"
|
|
|
|
|
Color="#005317"
|
|
|
|
|
Direction="270"
|
|
|
|
|
Opacity="0.2"
|
|
|
|
|
ShadowDepth="1" />
|
|
|
|
|
</Border.Effect>
|
|
|
|
|
<controls:Icon
|
2025-07-31 20:12:24 +08:00
|
|
|
Foreground="{DynamicResource AntDesign.Brush.TextPrimary}"
|
2025-07-31 20:12:01 +08:00
|
|
|
Type="loading"
|
|
|
|
|
Visibility="{Binding Loading, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
|
|
|
|
|
x:Name="Icon" />
|
|
|
|
|
</Border>
|
|
|
|
|
<VisualStateManager.VisualStateGroups>
|
|
|
|
|
<VisualStateGroup x:Name="CommonStates">
|
|
|
|
|
<VisualStateGroup.Transitions>
|
|
|
|
|
<VisualTransition From="Pressed">
|
|
|
|
|
<Storyboard>
|
|
|
|
|
<ThicknessAnimation
|
|
|
|
|
Duration="0:0:0.36"
|
|
|
|
|
EasingFunction="{StaticResource EaseInOutCirc}"
|
|
|
|
|
Storyboard.TargetName="PART_Dot"
|
|
|
|
|
Storyboard.TargetProperty="Margin" />
|
|
|
|
|
<DoubleAnimation
|
|
|
|
|
Duration="0:0:0.36"
|
|
|
|
|
EasingFunction="{StaticResource EaseInOutCirc}"
|
|
|
|
|
Storyboard.TargetName="PART_Dot"
|
|
|
|
|
Storyboard.TargetProperty="Width" />
|
|
|
|
|
</Storyboard>
|
|
|
|
|
</VisualTransition>
|
|
|
|
|
</VisualStateGroup.Transitions>
|
|
|
|
|
<VisualState x:Name="Normal" />
|
|
|
|
|
<VisualState x:Name="MouseOver" />
|
|
|
|
|
<VisualState x:Name="Pressed" />
|
|
|
|
|
<VisualState x:Name="Disabled" />
|
|
|
|
|
</VisualStateGroup>
|
|
|
|
|
<VisualStateGroup x:Name="CheckStates">
|
|
|
|
|
<VisualState x:Name="Checked">
|
|
|
|
|
<Storyboard>
|
|
|
|
|
<ThicknessAnimation
|
|
|
|
|
Duration="0:0:0.36"
|
|
|
|
|
EasingFunction="{StaticResource EaseInOutCirc}"
|
|
|
|
|
Storyboard.TargetName="PART_Dot"
|
|
|
|
|
Storyboard.TargetProperty="(FrameworkElement.Margin)" />
|
|
|
|
|
</Storyboard>
|
|
|
|
|
</VisualState>
|
|
|
|
|
<VisualState x:Name="Unchecked">
|
|
|
|
|
<Storyboard>
|
|
|
|
|
<ThicknessAnimation
|
|
|
|
|
Duration="0:0:0.36"
|
|
|
|
|
EasingFunction="{StaticResource EaseInOutCirc}"
|
|
|
|
|
Storyboard.TargetName="PART_Dot"
|
|
|
|
|
Storyboard.TargetProperty="(FrameworkElement.Margin)"
|
|
|
|
|
To="3 0 0 0" />
|
|
|
|
|
</Storyboard>
|
|
|
|
|
</VisualState>
|
|
|
|
|
<VisualState x:Name="Indeterminate" />
|
|
|
|
|
</VisualStateGroup>
|
|
|
|
|
</VisualStateManager.VisualStateGroups>
|
|
|
|
|
</Grid>
|
|
|
|
|
<ControlTemplate.Triggers>
|
|
|
|
|
<Trigger Property="IsChecked" Value="True">
|
|
|
|
|
<Setter Property="HorizontalAlignment" TargetName="Content" Value="Left" />
|
|
|
|
|
<Setter Property="RenderTransformOrigin" TargetName="PART_Dot" Value="1,0" />
|
2025-07-31 20:12:24 +08:00
|
|
|
<Setter Property="Foreground" TargetName="Icon" Value="{DynamicResource AntDesign.Brush.Primary}" />
|
|
|
|
|
<Setter Property="Background" TargetName="Border" Value="{DynamicResource AntDesign.Brush.Primary}" />
|
2025-07-31 20:12:01 +08:00
|
|
|
<Setter Property="Content" TargetName="Content" Value="{Binding Content, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="Size" Value="Small">
|
|
|
|
|
<Setter Property="RenderTransform" TargetName="Icon">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ScaleTransform ScaleX="0.75" ScaleY="0.75" />
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
<Setter Property="Spin" TargetName="Icon" Value="True" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<EventTrigger RoutedEvent="ButtonBase.Click">
|
|
|
|
|
<BeginStoryboard Storyboard="{StaticResource Ant.ClickAnimating}" />
|
|
|
|
|
</EventTrigger>
|
|
|
|
|
</ControlTemplate.Triggers>
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<Trigger Property="Loading" Value="True">
|
|
|
|
|
<Setter Property="IsEnabled" Value="False" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
|
|
|
<Setter Property="Opacity" Value="{DynamicResource SwitchDisabledOpacity}" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="Size" Value="Small">
|
|
|
|
|
<Setter Property="Padding" Value="3,0" />
|
|
|
|
|
<Setter Property="MinWidth" Value="28" />
|
|
|
|
|
<Setter Property="Height" Value="{DynamicResource SwitchHeightSmall}" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
|
|
|
|
|
</ResourceDictionary>
|