Merge pull request #546 from irihitech/caption

Redesign CaptionButtons
This commit is contained in:
Dong Bin
2025-01-20 17:01:19 +08:00
committed by GitHub
2 changed files with 61 additions and 36 deletions

View File

@@ -42,4 +42,37 @@
<Setter Property="Width" Value="24" /> <Setter Property="Width" Value="24" />
</Style> </Style>
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="CaptionButton" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Padding" Value="8" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<ContentPresenter
Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}" />
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPointeroverBackground}" />
</Style>
<Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -126,7 +126,6 @@
<u:CaptionButtons <u:CaptionButtons
x:Name="PART_CaptionButtons" x:Name="PART_CaptionButtons"
Grid.Column="3" Grid.Column="3"
Margin="8,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Top" VerticalAlignment="Top"
DockPanel.Dock="Right" DockPanel.Dock="Right"
@@ -139,63 +138,56 @@
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="{x:Type u:CaptionButtons}" TargetType="u:CaptionButtons"> <ControlTheme x:Key="{x:Type u:CaptionButtons}" TargetType="u:CaptionButtons">
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonForeground}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="u:CaptionButtons"> <ControlTemplate TargetType="u:CaptionButtons">
<StackPanel <StackPanel Orientation="Horizontal">
VerticalAlignment="Stretch" <Button Name="PART_FullScreenButton" Theme="{StaticResource CaptionButton}">
Orientation="Horizontal"
Spacing="2"
TextElement.FontSize="10">
<Button x:Name="PART_FullScreenButton" Theme="{DynamicResource CaptionButton}">
<PathIcon <PathIcon
Name="PART_FullScreenButtonIcon" Name="PART_FullScreenButtonIcon"
Width="12" Theme="{StaticResource InnerPathIcon}"
Height="12" Data="{StaticResource WindowExpandGlyph}"
Data="{DynamicResource WindowExpandGlyph}"
Foreground="{Binding $parent[Button].Foreground}" /> Foreground="{Binding $parent[Button].Foreground}" />
</Button> </Button>
<Button x:Name="PART_MinimizeButton" Theme="{DynamicResource CaptionButton}"> <Button Name="PART_MinimizeButton" Theme="{StaticResource CaptionButton}">
<PathIcon <PathIcon
Width="12" Name="PART_MinimizeButtonIcon"
Height="12" Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource WindowMinimizeGlyph}" Data="{StaticResource WindowMinimizeGlyph}"
Foreground="{Binding $parent[Button].Foreground}" /> Foreground="{Binding $parent[Button].Foreground}" />
</Button> </Button>
<Button x:Name="PART_RestoreButton" Theme="{DynamicResource CaptionButton}"> <Button Name="PART_RestoreButton" Theme="{StaticResource CaptionButton}">
<PathIcon <PathIcon
Name="PART_RestoreButtonIcon" Name="PART_RestoreButtonIcon"
Width="12" Theme="{StaticResource InnerPathIcon}"
Height="12" Data="{StaticResource WindowMaximizeGlyph}"
Data="{DynamicResource WindowMaximizeGlyph}"
Foreground="{Binding $parent[Button].Foreground}" /> Foreground="{Binding $parent[Button].Foreground}" />
</Button> </Button>
<Button <Button Name="PART_CloseButton" Theme="{StaticResource CaptionButton}">
x:Name="PART_CloseButton"
Background="{DynamicResource CaptionButtonClosePointeroverBackground}"
BorderBrush="{DynamicResource CaptionButtonClosePressedBackground}"
Theme="{DynamicResource CaptionButton}">
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Foreground" Value="White" />
</Style>
<Style Selector="Button:pressed">
<Setter Property="Foreground" Value="White" />
</Style>
</Button.Styles>
<PathIcon <PathIcon
Width="12" Name="PART_CloseButtonIcon"
Height="12" Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource WindowCloseIconGlyph}" Data="{StaticResource WindowCloseIconGlyph}"
Foreground="{Binding $parent[Button].Foreground}" /> Foreground="{Binding $parent[Button].Foreground}" />
</Button> </Button>
</StackPanel> </StackPanel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^ /template/ Button#PART_CloseButton:pointerover">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePointeroverBackground}" />
</Style>
<Style Selector="^ /template/ Button#PART_CloseButton:pressed">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePressedBackground}" />
</Style>
<Style Selector="^:maximized /template/ PathIcon#PART_RestoreButtonIcon"> <Style Selector="^:maximized /template/ PathIcon#PART_RestoreButtonIcon">
<Setter Property="Data" Value="{DynamicResource WindowRestoreGlyph}" /> <Setter Property="Data" Value="{StaticResource WindowRestoreGlyph}" />
</Style> </Style>
<Style Selector="^:fullscreen /template/ PathIcon#PART_FullScreenButtonIcon"> <Style Selector="^:fullscreen /template/ PathIcon#PART_FullScreenButtonIcon">
<Setter Property="Data" Value="{DynamicResource WindowCollapseGlyph}" /> <Setter Property="Data" Value="{StaticResource WindowCollapseGlyph}" />
</Style> </Style>
</ControlTheme> </ControlTheme>
</ResourceDictionary> </ResourceDictionary>