Files
Shrlalgo.RvKits/Melskin/Controls/RadioButton.xaml
2026-02-12 21:29:00 +08:00

236 lines
14 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type RadioButton}" x:Key="EmbossRadioButtonStyle">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid
Background="Transparent"
SnapsToDevicePixels="True"
x:Name="templateRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<decorations:EmbossBorder
Background="{TemplateBinding Background}"
CornerRadius="8"
Height="24"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Intensity="0.4"
RenderTransformOrigin="0.5,0.5"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Width="24"
x:Name="radioButtonBorder" />
<decorations:SlotBorder
Background="{TemplateBinding Background}"
CornerRadius="8"
Grid.Column="0"
Height="24"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Intensity="0.2"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed"
Width="24"
x:Name="markSlot">
<Ellipse
Fill="{DynamicResource PrimaryNormalBrush}"
Margin="1"
MinHeight="6"
MinWidth="6"
x:Name="optionMark" />
</decorations:SlotBorder>
<ContentPresenter
Focusable="False"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="Visibility" TargetName="radioButtonBorder" Value="Collapsed" />
<Setter Property="Visibility" TargetName="markSlot" Value="Visible" />
</Trigger>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{DynamicResource OptionMarkFocusVisual}" />
<Setter Property="Padding" Value="4,-1,0,0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter Property="Fill" TargetName="optionMark" Value="{DynamicResource PrimaryFocusedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="ShaderEnabled" TargetName="radioButtonBorder" Value="False" />
<Setter Property="Background" TargetName="radioButtonBorder" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="ShaderEnabled" TargetName="markSlot" Value="False" />
<Setter Property="ShaderEnabled" TargetName="markSlot" Value="False" />
<Setter Property="Background" TargetName="markSlot" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="Fill" TargetName="optionMark" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="RenderTransform" TargetName="radioButtonBorder">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="0.9" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type RadioButton}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid
Background="Transparent"
SnapsToDevicePixels="True"
x:Name="templateRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="9"
Height="18"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="3,2"
RenderTransformOrigin="0.5,0.5"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Width="18"
x:Name="radioButtonBorder">
<Grid Margin="3" x:Name="markGrid">
<Ellipse
Fill="{DynamicResource PrimaryNormalBrush}"
MinHeight="6"
MinWidth="6"
Opacity="0"
x:Name="optionMark" />
<Ellipse
MinHeight="6"
MinWidth="6"
Opacity="0"
Stroke="{DynamicResource PrimaryNormalBrush}"
StrokeThickness="2"
x:Name="indeterminateMark" />
</Grid>
</Border>
<ContentPresenter
Focusable="False"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Opacity" TargetName="optionMark" Value="1" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter Property="Opacity" TargetName="indeterminateMark" Value="1" />
</Trigger>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{DynamicResource OptionMarkFocusVisual}" />
<Setter Property="Padding" Value="4,-1,0,0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter Property="Fill" TargetName="optionMark" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter Property="Stroke" TargetName="indeterminateMark" Value="{DynamicResource PrimaryFocusedBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="RenderTransform" TargetName="radioButtonBorder">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="0.9" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{DynamicResource BorderDisabledBrush}" />
<Setter Property="Stroke" TargetName="indeterminateMark" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter Property="Fill" TargetName="optionMark" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type RadioButton}" x:Key="{x:Static ToolBar.RadioButtonStyleKey}">
<Setter Property="Margin" Value="1,3" />
<Setter Property="Padding" Value="4,1" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
x:Name="border">
<ContentPresenter
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}" />
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundPressedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>