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:
@@ -7,68 +7,72 @@
|
|||||||
<ControlTheme x:Key="{x:Type u:OverlayDialogHost}" TargetType="u:OverlayDialogHost">
|
<ControlTheme x:Key="{x:Type u:OverlayDialogHost}" TargetType="u:OverlayDialogHost">
|
||||||
<Setter Property="OverlayMaskBrush" Value="{DynamicResource OverlayDialogMaskBrush}" />
|
<Setter Property="OverlayMaskBrush" Value="{DynamicResource OverlayDialogMaskBrush}" />
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:CustomDialogControl}" TargetType="u:CustomDialogControl">
|
<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="CornerRadius" Value="{DynamicResource DialogCornerRadius}" />
|
||||||
<Setter Property="Transitions">
|
<Setter Property="Transitions">
|
||||||
<Transitions>
|
<Transitions>
|
||||||
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
|
<TransformOperationsTransition Property="RenderTransform" Duration="0.2" />
|
||||||
</Transitions>
|
</Transitions>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Setter Property="RenderTransform" Value="scale(1.0)"></Setter>
|
<Setter Property="RenderTransform" Value="scale(1.0)" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:CustomDialogControl">
|
<ControlTemplate TargetType="u:CustomDialogControl">
|
||||||
<Border
|
<Panel>
|
||||||
Name="PART_Border"
|
<Border
|
||||||
Focusable="True"
|
Name="PART_Border"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||||
Classes="Shadow"
|
Classes="Shadow"
|
||||||
ClipToBounds="False"
|
ClipToBounds="False"
|
||||||
CornerRadius="{TemplateBinding CornerRadius}"
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
IsHitTestVisible="True"
|
Focusable="True"
|
||||||
Theme="{DynamicResource CardBorder}">
|
IsHitTestVisible="True"
|
||||||
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
|
Theme="{DynamicResource CardBorder}">
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
|
||||||
<ContentPresenter
|
<Grid RowDefinitions="Auto, *">
|
||||||
Name="PART_ContentPresenter"
|
<ContentPresenter
|
||||||
Grid.Row="0"
|
Name="PART_ContentPresenter"
|
||||||
Grid.RowSpan="2"
|
Grid.Row="0"
|
||||||
Content="{TemplateBinding Content}" />
|
Grid.RowSpan="2"
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
|
Content="{TemplateBinding Content}" />
|
||||||
<Panel
|
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
|
||||||
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
|
<Panel
|
||||||
Grid.Column="0"
|
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
|
||||||
Grid.ColumnSpan="2"
|
Grid.Column="0"
|
||||||
Background="Transparent" />
|
Grid.ColumnSpan="2"
|
||||||
<Button
|
Background="Transparent" />
|
||||||
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
<Button
|
||||||
Grid.Column="1"
|
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
||||||
Margin="0,24,24,0"
|
Grid.Column="1"
|
||||||
DockPanel.Dock="Right"
|
Margin="0,24,24,0"
|
||||||
Theme="{DynamicResource OverlayCloseButton}" />
|
DockPanel.Dock="Right"
|
||||||
|
Theme="{DynamicResource OverlayCloseButton}" />
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Border>
|
||||||
</Border>
|
</Border>
|
||||||
</Border>
|
<u:DialogResizer IsVisible="{TemplateBinding CanResize}" />
|
||||||
|
</Panel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Style Selector="^:full-screen">
|
<Style Selector="^:full-screen">
|
||||||
<Setter Property="CornerRadius" Value="0"/>
|
<Setter Property="CornerRadius" Value="0" />
|
||||||
<Style Selector="^ /template/ Border#PART_Border">
|
<Style Selector="^ /template/ Border#PART_Border">
|
||||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||||
<Setter Property="Theme" Value="{x:Null}"/>
|
<Setter Property="Theme" Value="{x:Null}" />
|
||||||
<Setter Property="Margin" Value="0"/>
|
<Setter Property="Margin" Value="0" />
|
||||||
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}"></Setter>
|
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}" />
|
||||||
</Style>
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="^ /template/ Panel#PART_TitleArea">
|
<Style Selector="^ /template/ Panel#PART_TitleArea">
|
||||||
<Setter Property="ContextFlyout">
|
<Setter Property="ContextFlyout">
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuItem
|
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
|
||||||
Command="{Binding $parent[u:DialogControlBase].Close}"
|
|
||||||
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
|
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<PathIcon
|
<PathIcon
|
||||||
Width="12"
|
Width="12"
|
||||||
@@ -126,9 +130,7 @@
|
|||||||
Data="{DynamicResource DialogArrangeSendToBackGlyph}" />
|
Data="{DynamicResource DialogArrangeSendToBackGlyph}" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
|
||||||
Command="{Binding $parent[u:DialogControlBase].Close}"
|
|
||||||
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
|
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<PathIcon
|
<PathIcon
|
||||||
Width="12"
|
Width="12"
|
||||||
@@ -142,112 +144,117 @@
|
|||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:DefaultDialogControl}" TargetType="u:DefaultDialogControl">
|
<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="CornerRadius" Value="{DynamicResource DialogCornerRadius}" />
|
||||||
<Setter Property="Transitions">
|
<Setter Property="Transitions">
|
||||||
<Transitions>
|
<Transitions>
|
||||||
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
|
<TransformOperationsTransition Property="RenderTransform" Duration="0.2" />
|
||||||
</Transitions>
|
</Transitions>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:DefaultDialogControl">
|
<ControlTemplate TargetType="u:DefaultDialogControl">
|
||||||
<Border
|
<Panel>
|
||||||
Name="PART_Border"
|
<Border
|
||||||
Padding="0"
|
Name="PART_Border"
|
||||||
Focusable="True"
|
Padding="0"
|
||||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||||
BoxShadow="0 0 8 0 #1A000000"
|
BoxShadow="0 0 8 0 #1A000000"
|
||||||
Classes="Shadow"
|
Classes="Shadow"
|
||||||
ClipToBounds="False"
|
ClipToBounds="False"
|
||||||
CornerRadius="{TemplateBinding CornerRadius}"
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
IsHitTestVisible="True"
|
Focusable="True"
|
||||||
Theme="{DynamicResource CardBorder}">
|
IsHitTestVisible="True"
|
||||||
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
|
Theme="{DynamicResource CardBorder}">
|
||||||
<Grid RowDefinitions="Auto, *, Auto">
|
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
|
||||||
<ScrollViewer Grid.Row="1">
|
<Grid RowDefinitions="Auto, *, Auto">
|
||||||
<ContentPresenter
|
<ScrollViewer Grid.Row="1">
|
||||||
Name="PART_ContentPresenter"
|
<ContentPresenter
|
||||||
HorizontalAlignment="Center"
|
Name="PART_ContentPresenter"
|
||||||
VerticalAlignment="Center"
|
Margin="24,8"
|
||||||
Margin="24,8"
|
HorizontalAlignment="Center"
|
||||||
Content="{TemplateBinding Content}" />
|
VerticalAlignment="Center"
|
||||||
</ScrollViewer>
|
Content="{TemplateBinding Content}" />
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
|
</ScrollViewer>
|
||||||
<Panel
|
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
|
||||||
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
|
<Panel
|
||||||
Grid.Column="0"
|
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
|
||||||
Grid.ColumnSpan="3"
|
Grid.Column="0"
|
||||||
Background="Transparent" />
|
Grid.ColumnSpan="3"
|
||||||
<PathIcon
|
Background="Transparent" />
|
||||||
Name="PART_Icon"
|
<PathIcon
|
||||||
Grid.Column="0"
|
Name="PART_Icon"
|
||||||
Width="16"
|
Grid.Column="0"
|
||||||
Height="16"
|
Width="16"
|
||||||
Margin="24,24,8,0"
|
Height="16"
|
||||||
VerticalAlignment="Center" />
|
Margin="24,24,8,0"
|
||||||
<TextBlock
|
VerticalAlignment="Center" />
|
||||||
Name="PART_Title"
|
<TextBlock
|
||||||
Grid.Column="1"
|
Name="PART_Title"
|
||||||
Margin="0,24,0,0"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
Margin="0,24,0,0"
|
||||||
FontSize="16"
|
VerticalAlignment="Center"
|
||||||
FontWeight="{DynamicResource TextBlockTitleFontWeight}"
|
FontSize="16"
|
||||||
IsHitTestVisible="False"
|
FontWeight="{DynamicResource TextBlockTitleFontWeight}"
|
||||||
IsVisible="{TemplateBinding Title,
|
IsHitTestVisible="False"
|
||||||
Converter={x:Static ObjectConverters.IsNotNull}}"
|
IsVisible="{TemplateBinding Title,
|
||||||
Text="{TemplateBinding Title}"
|
Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||||
TextWrapping="Wrap" />
|
Text="{TemplateBinding Title}"
|
||||||
<Button
|
TextWrapping="Wrap" />
|
||||||
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
<Button
|
||||||
Grid.Column="2"
|
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
|
||||||
Margin="0,24,24,0"
|
Grid.Column="2"
|
||||||
DockPanel.Dock="Right"
|
Margin="0,24,24,0"
|
||||||
Theme="{DynamicResource OverlayCloseButton}" />
|
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>
|
</Grid>
|
||||||
<StackPanel
|
</Border>
|
||||||
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>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Style Selector="^:full-screen">
|
<Style Selector="^:full-screen">
|
||||||
<Setter Property="CornerRadius" Value="0"/>
|
<Setter Property="CornerRadius" Value="0" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="^:full-screen /template/ Border#PART_Border">
|
<Style Selector="^:full-screen /template/ Border#PART_Border">
|
||||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||||
<Setter Property="Theme" Value="{x:Null}"/>
|
<Setter Property="Theme" Value="{x:Null}" />
|
||||||
<Setter Property="Margin" Value="0"></Setter>
|
<Setter Property="Margin" Value="0" />
|
||||||
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}"></Setter>
|
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="^[Mode=None]">
|
<Style Selector="^[Mode=None]">
|
||||||
<Style Selector="^ /template/ PathIcon#PART_Icon">
|
<Style Selector="^ /template/ PathIcon#PART_Icon">
|
||||||
@@ -370,9 +377,7 @@
|
|||||||
<Style Selector="^ /template/ Panel#PART_TitleArea">
|
<Style Selector="^ /template/ Panel#PART_TitleArea">
|
||||||
<Setter Property="ContextFlyout">
|
<Setter Property="ContextFlyout">
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuItem
|
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
|
||||||
Command="{Binding $parent[u:DialogControlBase].Close}"
|
|
||||||
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
|
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<PathIcon
|
<PathIcon
|
||||||
Width="12"
|
Width="12"
|
||||||
@@ -474,11 +479,12 @@
|
|||||||
<ControlTemplate TargetType="u:DialogWindow">
|
<ControlTemplate TargetType="u:DialogWindow">
|
||||||
<Panel>
|
<Panel>
|
||||||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||||
<Border Background="{TemplateBinding Background}"
|
<Border
|
||||||
BackgroundSizing="InnerBorderEdge"
|
Background="{TemplateBinding Background}"
|
||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
BackgroundSizing="InnerBorderEdge"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
IsHitTestVisible="False" />
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
IsHitTestVisible="False" />
|
||||||
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||||
<VisualLayerManager>
|
<VisualLayerManager>
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *">
|
||||||
@@ -506,6 +512,10 @@
|
|||||||
Margin="0,24,24,0"
|
Margin="0,24,24,0"
|
||||||
Theme="{DynamicResource CloseButton}" />
|
Theme="{DynamicResource CloseButton}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<u:WindowResizer
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
IsVisible="{TemplateBinding IsManagedResizerVisible}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</VisualLayerManager>
|
</VisualLayerManager>
|
||||||
</Panel>
|
</Panel>
|
||||||
@@ -541,11 +551,12 @@
|
|||||||
<ControlTemplate TargetType="u:DefaultDialogWindow">
|
<ControlTemplate TargetType="u:DefaultDialogWindow">
|
||||||
<Panel>
|
<Panel>
|
||||||
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||||
<Border Background="{TemplateBinding Background}"
|
<Border
|
||||||
BackgroundSizing="InnerBorderEdge"
|
Background="{TemplateBinding Background}"
|
||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
BackgroundSizing="InnerBorderEdge"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
IsHitTestVisible="False" />
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
IsHitTestVisible="False" />
|
||||||
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||||
<VisualLayerManager>
|
<VisualLayerManager>
|
||||||
<Grid RowDefinitions="Auto, *, Auto">
|
<Grid RowDefinitions="Auto, *, Auto">
|
||||||
@@ -615,6 +626,10 @@
|
|||||||
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
|
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
|
||||||
Theme="{DynamicResource SolidButton}" />
|
Theme="{DynamicResource SolidButton}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<u:WindowResizer
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="3"
|
||||||
|
IsVisible="{TemplateBinding IsManagedResizerVisible}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</VisualLayerManager>
|
</VisualLayerManager>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme TargetType="u:DialogResizerThumb" x:Key="{x:Type u:DialogResizerThumb}">
|
<ControlTheme TargetType="u:DialogResizerThumb" x:Key="{x:Type u:DialogResizerThumb}">
|
||||||
<Setter Property="Background" Value="Red" />
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:DialogResizerThumb">
|
<ControlTemplate TargetType="u:DialogResizerThumb">
|
||||||
<iri:PureRectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}"/>
|
<Panel>
|
||||||
|
<iri:PureRectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}"/>
|
||||||
|
</Panel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|||||||
@@ -205,6 +205,8 @@ public static class Dialog
|
|||||||
window.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
window.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||||
window.ShowInTaskbar = options.ShowInTaskBar;
|
window.ShowInTaskbar = options.ShowInTaskBar;
|
||||||
window.CanDragMove = options.CanDragMove;
|
window.CanDragMove = options.CanDragMove;
|
||||||
|
window.CanResize = options.CanResize;
|
||||||
|
window.IsManagedResizerVisible = options.CanResize;
|
||||||
if (options.StartupLocation == WindowStartupLocation.Manual)
|
if (options.StartupLocation == WindowStartupLocation.Manual)
|
||||||
{
|
{
|
||||||
if (options.Position is not null)
|
if (options.Position is not null)
|
||||||
@@ -229,6 +231,8 @@ public static class Dialog
|
|||||||
window.ShowInTaskbar = options.ShowInTaskBar;
|
window.ShowInTaskbar = options.ShowInTaskBar;
|
||||||
window.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
window.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||||
window.CanDragMove = options.CanDragMove;
|
window.CanDragMove = options.CanDragMove;
|
||||||
|
window.IsManagedResizerVisible = options.CanResize;
|
||||||
|
window.CanResize = options.CanResize;
|
||||||
if (options.StartupLocation == WindowStartupLocation.Manual)
|
if (options.StartupLocation == WindowStartupLocation.Manual)
|
||||||
{
|
{
|
||||||
if (options.Position is not null)
|
if (options.Position is not null)
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
|||||||
AvaloniaProperty.RegisterDirect<DialogControlBase, bool>(
|
AvaloniaProperty.RegisterDirect<DialogControlBase, bool>(
|
||||||
nameof(IsFullScreen), o => o.IsFullScreen, (o, v) => o.IsFullScreen = v);
|
nameof(IsFullScreen), o => o.IsFullScreen, (o, v) => o.IsFullScreen = v);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<bool> CanResizeProperty = AvaloniaProperty.Register<DialogControlBase, bool>(
|
||||||
|
nameof(CanResize));
|
||||||
|
|
||||||
protected internal Button? _closeButton;
|
protected internal Button? _closeButton;
|
||||||
|
|
||||||
private bool _isFullScreen;
|
private bool _isFullScreen;
|
||||||
@@ -36,6 +39,12 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
|||||||
IsFullScreenProperty.AffectsPseudoClass<DialogControlBase>(PC_FullScreen);
|
IsFullScreenProperty.AffectsPseudoClass<DialogControlBase>(PC_FullScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanResize
|
||||||
|
{
|
||||||
|
get => GetValue(CanResizeProperty);
|
||||||
|
set => SetValue(CanResizeProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
internal HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
internal HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||||
internal VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
internal VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||||
internal HorizontalPosition ActualHorizontalAnchor { get; set; }
|
internal HorizontalPosition ActualHorizontalAnchor { get; set; }
|
||||||
|
|||||||
@@ -17,8 +17,17 @@ public class DialogWindow : Window
|
|||||||
public const string PART_TitleArea = "PART_TitleArea";
|
public const string PART_TitleArea = "PART_TitleArea";
|
||||||
|
|
||||||
protected internal Button? _closeButton;
|
protected internal Button? _closeButton;
|
||||||
|
|
||||||
private Panel? _titleArea;
|
private Panel? _titleArea;
|
||||||
public bool CanDragMove { get; set; } = true;
|
|
||||||
|
public static readonly StyledProperty<bool> IsManagedResizerVisibleProperty = AvaloniaProperty.Register<DialogWindow, bool>(
|
||||||
|
nameof(IsManagedResizerVisible));
|
||||||
|
|
||||||
|
public bool IsManagedResizerVisible
|
||||||
|
{
|
||||||
|
get => GetValue(IsManagedResizerVisibleProperty);
|
||||||
|
set => SetValue(IsManagedResizerVisibleProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
static DialogWindow()
|
static DialogWindow()
|
||||||
{
|
{
|
||||||
@@ -26,9 +35,11 @@ public class DialogWindow : Window
|
|||||||
window.OnDataContextChange(e));
|
window.OnDataContextChange(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanDragMove { get; set; } = true;
|
||||||
|
internal bool? IsCloseButtonVisible { get; set; }
|
||||||
|
|
||||||
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
|
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
|
||||||
|
|
||||||
internal bool? IsCloseButtonVisible { get; set; }
|
|
||||||
|
|
||||||
private void OnDataContextChange(AvaloniaPropertyChangedEventArgs<object?> args)
|
private void OnDataContextChange(AvaloniaPropertyChangedEventArgs<object?> args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,4 +30,6 @@ public class DialogOptions
|
|||||||
public bool ShowInTaskBar { get; set; } = true;
|
public bool ShowInTaskBar { get; set; } = true;
|
||||||
|
|
||||||
public bool CanDragMove { get; set; } = true;
|
public bool CanDragMove { get; set; } = true;
|
||||||
|
|
||||||
|
public bool CanResize { get; set; }
|
||||||
}
|
}
|
||||||
@@ -62,4 +62,6 @@ public class OverlayDialogOptions
|
|||||||
/// id.
|
/// id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? TopLevelHashCode { get; set; }
|
public int? TopLevelHashCode { get; set; }
|
||||||
|
|
||||||
|
public bool CanResize { get; set; }
|
||||||
}
|
}
|
||||||
@@ -204,6 +204,7 @@ public static class OverlayDialog
|
|||||||
options.VerticalAnchor == VerticalPosition.Center ? null : options.VerticalOffset;
|
options.VerticalAnchor == VerticalPosition.Center ? null : options.VerticalOffset;
|
||||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||||
control.CanLightDismiss = options.CanLightDismiss;
|
control.CanLightDismiss = options.CanLightDismiss;
|
||||||
|
control.CanResize = options.CanResize;
|
||||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +230,7 @@ public static class OverlayDialog
|
|||||||
control.Title = options.Title;
|
control.Title = options.Title;
|
||||||
control.CanLightDismiss = options.CanLightDismiss;
|
control.CanLightDismiss = options.CanLightDismiss;
|
||||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||||
|
control.CanResize = options.CanResize;
|
||||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,10 +149,14 @@ public abstract class OverlayFeedbackElement : ContentControl
|
|||||||
{
|
{
|
||||||
if (containerBounds is not null)
|
if (containerBounds is not null)
|
||||||
{
|
{
|
||||||
var minX = -left;
|
var minX = windowEdge is WindowEdge.West or WindowEdge.NorthWest or WindowEdge.SouthWest
|
||||||
var minY = -top;
|
? -left
|
||||||
var maxX = containerBounds.Value.Width - left - width;
|
: double.NegativeInfinity;
|
||||||
var maxY = containerBounds.Value.Height - top - height;
|
var minY = windowEdge is WindowEdge.North or WindowEdge.NorthEast or WindowEdge.NorthWest
|
||||||
|
? -top
|
||||||
|
: double.NegativeInfinity;
|
||||||
|
var maxX = containerBounds.Value.Width - left - MinWidth;
|
||||||
|
var maxY = containerBounds.Value.Height - top - MinHeight;
|
||||||
diff = new Point(MathHelpers.SafeClamp(diff.X, minX, maxX), MathHelpers.SafeClamp(diff.Y, minY, maxY));
|
diff = new Point(MathHelpers.SafeClamp(diff.X, minX, maxX), MathHelpers.SafeClamp(diff.Y, minY, maxY));
|
||||||
}
|
}
|
||||||
switch (windowEdge)
|
switch (windowEdge)
|
||||||
|
|||||||
@@ -1,10 +1,30 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Irihi.Avalonia.Shared.Helpers;
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
public class DialogResizer: TemplatedControl
|
public class DialogResizer: TemplatedControl
|
||||||
{
|
{
|
||||||
|
public const string PART_Top = "PART_Top";
|
||||||
|
public const string PART_Bottom = "PART_Bottom";
|
||||||
|
public const string PART_Left = "PART_Left";
|
||||||
|
public const string PART_Right = "PART_Right";
|
||||||
|
public const string PART_TopLeft = "PART_TopLeft";
|
||||||
|
public const string PART_TopRight = "PART_TopRight";
|
||||||
|
public const string PART_BottomLeft = "PART_BottomLeft";
|
||||||
|
public const string PART_BottomRight = "PART_BottomRight";
|
||||||
|
|
||||||
|
private Thumb? _top;
|
||||||
|
private Thumb? _bottom;
|
||||||
|
private Thumb? _left;
|
||||||
|
private Thumb? _right;
|
||||||
|
private Thumb? _topLeft;
|
||||||
|
private Thumb? _topRight;
|
||||||
|
private Thumb? _bottomLeft;
|
||||||
|
private Thumb? _bottomRight;
|
||||||
|
|
||||||
public static readonly StyledProperty<ResizeDirection> ResizeDirectionProperty = AvaloniaProperty.Register<DialogResizer, ResizeDirection>(
|
public static readonly StyledProperty<ResizeDirection> ResizeDirectionProperty = AvaloniaProperty.Register<DialogResizer, ResizeDirection>(
|
||||||
nameof(ResizeDirection));
|
nameof(ResizeDirection));
|
||||||
|
|
||||||
@@ -16,4 +36,39 @@ public class DialogResizer: TemplatedControl
|
|||||||
get => GetValue(ResizeDirectionProperty);
|
get => GetValue(ResizeDirectionProperty);
|
||||||
set => SetValue(ResizeDirectionProperty, value);
|
set => SetValue(ResizeDirectionProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DialogResizer()
|
||||||
|
{
|
||||||
|
ResizeDirectionProperty.Changed.AddClassHandler<DialogResizer, ResizeDirection>((resizer, e) => resizer.OnResizeDirectionChanged(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnResizeDirectionChanged(AvaloniaPropertyChangedEventArgs<ResizeDirection> args)
|
||||||
|
{
|
||||||
|
UpdateThumbVisibility(args.NewValue.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnApplyTemplate(e);
|
||||||
|
_top = e.NameScope.Find<Thumb>(PART_Top);
|
||||||
|
_bottom = e.NameScope.Find<Thumb>(PART_Bottom);
|
||||||
|
_left = e.NameScope.Find<Thumb>(PART_Left);
|
||||||
|
_right = e.NameScope.Find<Thumb>(PART_Right);
|
||||||
|
_topLeft = e.NameScope.Find<Thumb>(PART_TopLeft);
|
||||||
|
_topRight = e.NameScope.Find<Thumb>(PART_TopRight);
|
||||||
|
_bottomLeft = e.NameScope.Find<Thumb>(PART_BottomLeft);
|
||||||
|
_bottomRight = e.NameScope.Find<Thumb>(PART_BottomRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateThumbVisibility(ResizeDirection direction)
|
||||||
|
{
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.Top), _top);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.Bottom), _bottom);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.Left), _left);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.Right), _right);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.TopLeft), _topLeft);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.TopRight), _topRight);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.BottomLeft), _bottomLeft);
|
||||||
|
IsVisibleProperty.SetValue(direction.HasFlag(ResizeDirection.BottomRight), _bottomRight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,12 +3,16 @@ namespace Ursa.Controls;
|
|||||||
[Flags]
|
[Flags]
|
||||||
public enum ResizeDirection
|
public enum ResizeDirection
|
||||||
{
|
{
|
||||||
Top,
|
Top = 1,
|
||||||
Bottom,
|
Bottom = 2,
|
||||||
Left,
|
Left = 4,
|
||||||
Right,
|
Right = 8,
|
||||||
TopLeft,
|
TopLeft = 16,
|
||||||
TopRight,
|
TopRight = 32,
|
||||||
BottomLeft,
|
BottomLeft = 64,
|
||||||
BottomRight,
|
BottomRight = 128,
|
||||||
|
|
||||||
|
Sides = Top | Bottom | Left | Right,
|
||||||
|
Corners = TopLeft | TopRight | BottomLeft | BottomRight,
|
||||||
|
All = Sides | Corners,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user