Files
ShrlAlgoToolkit/AntDesignWPF/Controls/AntWindow/AntWindow.xaml
2025-07-31 20:12:24 +08:00

203 lines
11 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:AntdShell="clr-namespace:AntDesignWPF.Microsoft.Windows.Shell"
xmlns:Shell="clr-namespace:Microsoft.Windows.Shell"
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Converters.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Dark.xaml" />-->
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Thumb}" x:Key="Ant.TitleBarThumb">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:AntWindow}">
<Setter Property="WindowStyle" Value="None" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<!--<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />-->
<Setter Property="Icon" Value="{StaticResource AntDesignDrawingImage}" />
<!--<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />-->
<Setter Property="FontSize" Value="{DynamicResource FontSizeBase}" />
<!--<Setter Property="Template" Value="{StaticResource Ant.WindowTemplate}" />-->
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.BackgroundContainer}" />
<Setter Property="TitleBarForeground" Value="{DynamicResource AntDesign.Brush.TextOnPrimary}" />
<Setter Property="TitleBarBackground" Value="{DynamicResource AntDesign.Brush.Primary}" />
<Setter Property="IconTemplate">
<Setter.Value>
<DataTemplate>
<Image
Source="{TemplateBinding Content}"
Stretch="None"
VerticalAlignment="Center" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="TitleTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock
FontSize="{DynamicResource FontSizeSmall}"
Margin="8,0"
Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="AntdShell:WindowChrome.WindowChrome">
<Setter.Value>
<AntdShell:WindowChrome
CaptionHeight="0"
CornerRadius="0"
GlassFrameThickness="0 0 0 0.1"
UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:AntWindow}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
LayoutTransform="{TemplateBinding LayoutTransform}"
Margin="{Binding WindowNonClientFrameThickness, Source={x:Static Shell:SystemParameters2.Current}}"
RenderTransform="{TemplateBinding RenderTransform}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<AdornerDecorator>
<Grid UseLayoutRounding="False" x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<!-- icon -->
<ColumnDefinition Width="Auto" />
<!-- left window commands -->
<ColumnDefinition Width="Auto" />
<!-- title -->
<ColumnDefinition Width="*" />
<!-- right window commands -->
<ColumnDefinition Width="Auto" />
<!-- min,max,close buttons -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- title bar -->
<Rectangle
Fill="{TemplateBinding TitleBarBackground}"
Focusable="False"
Grid.ColumnSpan="5"
Height="{TemplateBinding TitleBarHeight}"
StrokeThickness="0"
x:Name="PART_TitleBar" />
<!--
Note:
thumb 元素必须放在标题栏背景之后,
否则会影响双击标题栏窗口以最大化
-->
<controls:Thumb
Grid.ColumnSpan="5"
Style="{StaticResource Ant.TitleBarThumb}"
x:Name="PART_TitleBarThumb" />
<!-- icon -->
<ContentPresenter
Content="{TemplateBinding Icon}"
ContentTemplate="{TemplateBinding IconTemplate}"
Focusable="False"
Height="{TemplateBinding TitleBarHeight}"
VerticalAlignment="Top"
x:Name="PART_Icon" />
<!-- 左侧窗口命令 -->
<ContentPresenter
Content="{TemplateBinding LeftWindowCommands}"
Focusable="False"
Grid.Column="1"
Height="{TemplateBinding TitleBarHeight}"
VerticalAlignment="Top"
x:Name="PART_LeftWindowCommands" />
<!-- title -->
<controls:ThumbContentControl
Content="{TemplateBinding Title}"
ContentCharacterCasing="{TemplateBinding TitleCharacterCasing}"
ContentTemplate="{TemplateBinding TitleTemplate}"
Focusable="False"
Foreground="{TemplateBinding TitleBarForeground}"
Grid.Column="2"
Height="{TemplateBinding TitleBarHeight}"
HorizontalAlignment="{TemplateBinding TitleAlignment}"
x:Name="PART_Title" />
<!-- 右侧窗口命令 -->
<ContentPresenter
Content="{TemplateBinding RightWindowCommands}"
Focusable="False"
Grid.Column="3"
Height="{TemplateBinding TitleBarHeight}"
VerticalAlignment="Top"
x:Name="PART_RightWindowCommands" />
<!-- Window 按钮命令 -->
<ContentPresenter
Content="{TemplateBinding WindowButtons}"
Focusable="False"
Grid.Column="4"
Height="{TemplateBinding TitleBarHeight}"
VerticalAlignment="Top"
x:Name="PART_WindowButtons" />
<!-- 主窗口内容 -->
<ContentPresenter
Focusable="False"
Grid.ColumnSpan="5"
Grid.Row="1" />
<!-- ResizeGrip -->
<ResizeGrip
Grid.ColumnSpan="5"
Grid.Row="1"
HorizontalAlignment="Right"
IsTabStop="False"
UseLayoutRounding="True"
VerticalAlignment="Bottom"
Visibility="Collapsed"
x:Name="WindowResizeGrip" />
</Grid>
</AdornerDecorator>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UseNoneWindowStyle" Value="True">
<Setter Property="Grid.RowSpan" TargetName="PART_TitleBarThumb" Value="2" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" TargetName="PART_Icon" Value="Collapsed" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IgnoreTaskbar" Value="False" />
<Condition Property="WindowState" Value="Maximized" />
</MultiTrigger.Conditions>
<Setter Property="Margin" TargetName="LayoutRoot" Value="7" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip" />
<Condition Property="WindowState" Value="Normal" />
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>