Add resize functionality and improve dialog controls

This commit introduces the ability to resize dialogs by adding `CanResize` properties to dialog options and control classes. It also refines dialog controls' behavior and layout, ensuring consistent resizing capabilities across different dialog types. Additionally, it enhances the overlay feedback element's positioning logic and updates the resizer's appearance and visibility handling.
This commit is contained in:
rabbitism
2024-09-17 22:44:35 +08:00
parent a70f7205e9
commit c512cb6e13
11 changed files with 278 additions and 168 deletions

View File

@@ -7,68 +7,72 @@
<ControlTheme x:Key="{x:Type u:OverlayDialogHost}" TargetType="u:OverlayDialogHost">
<Setter Property="OverlayMaskBrush" Value="{DynamicResource OverlayDialogMaskBrush}" />
</ControlTheme>
<ControlTheme x:Key="{x:Type u:CustomDialogControl}" TargetType="u:CustomDialogControl">
<Setter Property="MinWidth" Value="96" />
<Setter Property="MinHeight" Value="96" />
<Setter Property="CornerRadius" Value="{DynamicResource DialogCornerRadius}" />
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
<TransformOperationsTransition Property="RenderTransform" Duration="0.2" />
</Transitions>
</Setter>
<Setter Property="RenderTransform" Value="scale(1.0)"></Setter>
<Setter Property="RenderTransform" Value="scale(1.0)" />
<Setter Property="Template">
<ControlTemplate TargetType="u:CustomDialogControl">
<Border
Name="PART_Border"
Focusable="True"
Padding="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Classes="Shadow"
ClipToBounds="False"
CornerRadius="{TemplateBinding CornerRadius}"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
<Grid RowDefinitions="Auto, *">
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Row="0"
Grid.RowSpan="2"
Content="{TemplateBinding Content}" />
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
<Panel
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="2"
Background="Transparent" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
Grid.Column="1"
Margin="0,24,24,0"
DockPanel.Dock="Right"
Theme="{DynamicResource OverlayCloseButton}" />
<Panel>
<Border
Name="PART_Border"
Padding="0"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Classes="Shadow"
ClipToBounds="False"
CornerRadius="{TemplateBinding CornerRadius}"
Focusable="True"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
<Grid RowDefinitions="Auto, *">
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Row="0"
Grid.RowSpan="2"
Content="{TemplateBinding Content}" />
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
<Panel
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="2"
Background="Transparent" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
Grid.Column="1"
Margin="0,24,24,0"
DockPanel.Dock="Right"
Theme="{DynamicResource OverlayCloseButton}" />
</Grid>
</Grid>
</Grid>
</Border>
</Border>
</Border>
<u:DialogResizer IsVisible="{TemplateBinding CanResize}" />
</Panel>
</ControlTemplate>
</Setter>
<Style Selector="^:full-screen">
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="CornerRadius" Value="0" />
<Style Selector="^ /template/ Border#PART_Border">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Theme" Value="{x:Null}"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}"></Setter>
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Theme" Value="{x:Null}" />
<Setter Property="Margin" Value="0" />
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}" />
</Style>
</Style>
<Style Selector="^ /template/ Panel#PART_TitleArea">
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem
Command="{Binding $parent[u:DialogControlBase].Close}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
@@ -126,9 +130,7 @@
Data="{DynamicResource DialogArrangeSendToBackGlyph}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControlBase].Close}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
@@ -142,112 +144,117 @@
</ControlTheme>
<ControlTheme x:Key="{x:Type u:DefaultDialogControl}" TargetType="u:DefaultDialogControl">
<Setter Property="MinWidth" Value="96" />
<Setter Property="MinHeight" Value="96" />
<Setter Property="CornerRadius" Value="{DynamicResource DialogCornerRadius}" />
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
<TransformOperationsTransition Property="RenderTransform" Duration="0.2" />
</Transitions>
</Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:DefaultDialogControl">
<Border
Name="PART_Border"
Padding="0"
Focusable="True"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
BoxShadow="0 0 8 0 #1A000000"
Classes="Shadow"
ClipToBounds="False"
CornerRadius="{TemplateBinding CornerRadius}"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
<Grid RowDefinitions="Auto, *, Auto">
<ScrollViewer Grid.Row="1">
<ContentPresenter
Name="PART_ContentPresenter"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="24,8"
Content="{TemplateBinding Content}" />
</ScrollViewer>
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
<Panel
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="3"
Background="Transparent" />
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Width="16"
Height="16"
Margin="24,24,8,0"
VerticalAlignment="Center" />
<TextBlock
Name="PART_Title"
Grid.Column="1"
Margin="0,24,0,0"
VerticalAlignment="Center"
FontSize="16"
FontWeight="{DynamicResource TextBlockTitleFontWeight}"
IsHitTestVisible="False"
IsVisible="{TemplateBinding Title,
Converter={x:Static ObjectConverters.IsNotNull}}"
Text="{TemplateBinding Title}"
TextWrapping="Wrap" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
Grid.Column="2"
Margin="0,24,24,0"
DockPanel.Dock="Right"
Theme="{DynamicResource OverlayCloseButton}" />
<Panel>
<Border
Name="PART_Border"
Padding="0"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
BoxShadow="0 0 8 0 #1A000000"
Classes="Shadow"
ClipToBounds="False"
CornerRadius="{TemplateBinding CornerRadius}"
Focusable="True"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
<Grid RowDefinitions="Auto, *, Auto">
<ScrollViewer Grid.Row="1">
<ContentPresenter
Name="PART_ContentPresenter"
Margin="24,8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}" />
</ScrollViewer>
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
<Panel
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="3"
Background="Transparent" />
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Width="16"
Height="16"
Margin="24,24,8,0"
VerticalAlignment="Center" />
<TextBlock
Name="PART_Title"
Grid.Column="1"
Margin="0,24,0,0"
VerticalAlignment="Center"
FontSize="16"
FontWeight="{DynamicResource TextBlockTitleFontWeight}"
IsHitTestVisible="False"
IsVisible="{TemplateBinding Title,
Converter={x:Static ObjectConverters.IsNotNull}}"
Text="{TemplateBinding Title}"
TextWrapping="Wrap" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
Grid.Column="2"
Margin="0,24,24,0"
DockPanel.Dock="Right"
Theme="{DynamicResource OverlayCloseButton}" />
</Grid>
<StackPanel
Grid.Row="2"
Margin="24,0,24,24"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Name="{x:Static u:DefaultDialogControl.PART_CancelButton}"
Margin="8,0,0,0"
Classes="Tertiary"
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}" />
<Button
Name="{x:Static u:DefaultDialogControl.PART_NoButton}"
Margin="8,0,0,0"
Classes="Danger"
Content="{DynamicResource STRING_MENU_DIALOG_NO}"
Theme="{DynamicResource SolidButton}" />
<Button
Name="{x:Static u:DefaultDialogControl.PART_YesButton}"
Margin="8,0,0,0"
Classes="Primary"
Content="{DynamicResource STRING_MENU_DIALOG_YES}"
Theme="{DynamicResource SolidButton}" />
<Button
Name="{x:Static u:DefaultDialogControl.PART_OKButton}"
Margin="8,0,0,0"
Classes="Primary"
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
Theme="{DynamicResource SolidButton}" />
</StackPanel>
</Grid>
<StackPanel
Grid.Row="2"
Margin="24,0,24,24"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Name="{x:Static u:DefaultDialogControl.PART_CancelButton}"
Margin="8,0,0,0"
Classes="Tertiary"
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}" />
<Button
Name="{x:Static u:DefaultDialogControl.PART_NoButton}"
Margin="8,0,0,0"
Classes="Danger"
Content="{DynamicResource STRING_MENU_DIALOG_NO}"
Theme="{DynamicResource SolidButton}" />
<Button
Name="{x:Static u:DefaultDialogControl.PART_YesButton}"
Margin="8,0,0,0"
Classes="Primary"
Content="{DynamicResource STRING_MENU_DIALOG_YES}"
Theme="{DynamicResource SolidButton}" />
<Button
Name="{x:Static u:DefaultDialogControl.PART_OKButton}"
Margin="8,0,0,0"
Classes="Primary"
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
Theme="{DynamicResource SolidButton}" />
</StackPanel>
<u:DialogResizer Grid.Row="0" Grid.RowSpan="3"/>
</Grid>
</Border>
</Border>
</Border>
<u:DialogResizer IsVisible="{TemplateBinding CanResize}"/>
</Panel>
</ControlTemplate>
</Setter>
<Style Selector="^:full-screen">
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="CornerRadius" Value="0" />
</Style>
<Style Selector="^:full-screen /template/ Border#PART_Border">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Theme" Value="{x:Null}"/>
<Setter Property="Margin" Value="0"></Setter>
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}"></Setter>
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Theme" Value="{x:Null}" />
<Setter Property="Margin" Value="0" />
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}" />
</Style>
<Style Selector="^[Mode=None]">
<Style Selector="^ /template/ PathIcon#PART_Icon">
@@ -370,9 +377,7 @@
<Style Selector="^ /template/ Panel#PART_TitleArea">
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem
Command="{Binding $parent[u:DialogControlBase].Close}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
@@ -474,11 +479,12 @@
<ControlTemplate TargetType="u:DialogWindow">
<Panel>
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
<Border Background="{TemplateBinding Background}"
BackgroundSizing="InnerBorderEdge"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsHitTestVisible="False" />
<Border
Background="{TemplateBinding Background}"
BackgroundSizing="InnerBorderEdge"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsHitTestVisible="False" />
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
<VisualLayerManager>
<Grid RowDefinitions="Auto, *">
@@ -506,6 +512,10 @@
Margin="0,24,24,0"
Theme="{DynamicResource CloseButton}" />
</Grid>
<u:WindowResizer
Grid.Row="0"
Grid.RowSpan="2"
IsVisible="{TemplateBinding IsManagedResizerVisible}" />
</Grid>
</VisualLayerManager>
</Panel>
@@ -541,11 +551,12 @@
<ControlTemplate TargetType="u:DefaultDialogWindow">
<Panel>
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
<Border Background="{TemplateBinding Background}"
BackgroundSizing="InnerBorderEdge"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsHitTestVisible="False" />
<Border
Background="{TemplateBinding Background}"
BackgroundSizing="InnerBorderEdge"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsHitTestVisible="False" />
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
<VisualLayerManager>
<Grid RowDefinitions="Auto, *, Auto">
@@ -615,6 +626,10 @@
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
Theme="{DynamicResource SolidButton}" />
</StackPanel>
<u:WindowResizer
Grid.Row="0"
Grid.RowSpan="3"
IsVisible="{TemplateBinding IsManagedResizerVisible}" />
</Grid>
</VisualLayerManager>
</Panel>
@@ -739,4 +754,4 @@
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>