Files
ShrlAlgoToolkit/AntdWpf/Styles/WindowButtons.xaml
2025-07-12 23:31:32 +08:00

72 lines
4.9 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:AntdWpf.Controls"
xmlns:helpers="clr-namespace:AntdWpf.Helpers">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Converters.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/WindowButton.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="Ant.WindowCloseButton" BasedOn="{StaticResource Ant.WindowButton}" TargetType="{x:Type Button}">
<Setter Property="helpers:AntdControl.MouseOverBackground" Value="{DynamicResource ErrorBrush}" />
<Setter Property="helpers:AntdControl.PressedBackground"
Value="{Binding Path=(helpers:AntdControl.MouseOverBackground), Mode=OneWay, ConverterParameter=7,
RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}}" />
</Style>
<Style TargetType="{x:Type controls:WindowButtons}">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="MinimizeStyle" Value="{StaticResource Ant.WindowButton}" />
<Setter Property="MaximizeStyle" Value="{StaticResource Ant.WindowButton}" />
<Setter Property="CloseStyle" Value="{StaticResource Ant.WindowCloseButton}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:WindowButtons}">
<StackPanel Orientation="Horizontal">
<Button x:Name="PART_Min"
ToolTip="{TemplateBinding Minimize}"
Visibility="{Binding ResizeMode, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type controls:AntdWindow}},
Converter={StaticResource ResizeModeToVisibilityConverter}, ConverterParameter=MIN}">
<Path RenderOptions.EdgeMode="Aliased"
Data="M0,1 L 12,1 12,1.8 0,1.8z"
Fill="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" />
</Button>
<Button x:Name="PART_Max"
ToolTip="{TemplateBinding Maximize}"
Visibility="{Binding ResizeMode, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type controls:AntdWindow}},
Converter={StaticResource ResizeModeToVisibilityConverter}, ConverterParameter=MAX}">
<Path x:Name="PART_MaxPath"
UseLayoutRounding="True"
RenderOptions.EdgeMode="Aliased"
Data="M0,0 L12,0 12,11 0,11z M1,1 L11,1 11,10.5 1,10.5z"
Fill="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" />
</Button>
<Button x:Name="PART_Close"
UseLayoutRounding="True"
ToolTip="{TemplateBinding Close}">
<Grid>
<Line X1="0" X2="11"
Y1="0" Y2="11"
Stroke="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" />
<Line X1="0" X2="11"
Y1="11" Y2="0"
Stroke="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" />
</Grid>
</Button>
</StackPanel>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding WindowState, RelativeSource={RelativeSource AncestorType={x:Type controls:AntdWindow}}}" Value="Maximized">
<Setter TargetName="PART_Max" Property="ToolTip" Value="{Binding Restore, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="PART_MaxPath" Property="Data" Value="M2,2 L2,0 12,0 12,10 10.5,10 10.5,9 11,9 11,1 2.5,1 2.5,2z M0,2 L10.5,2 10.5,11 0,11z M1,2.5 L10,2.5 10,10.5 1,10.5z" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>