Merge pull request #93 from irihitech/drawer

Drawer
This commit is contained in:
Dong Bin
2024-02-06 22:13:05 +08:00
committed by GitHub
40 changed files with 1590 additions and 444 deletions

View File

@@ -7,10 +7,16 @@
<ControlTheme x:Key="{x:Type u:OverlayDialogHost}" TargetType="u:OverlayDialogHost">
<Setter Property="OverlayMaskBrush" Value="{DynamicResource OverlayDialogMaskBrush}" />
</ControlTheme>
<ControlTheme x:Key="{x:Type u:DialogControl}" TargetType="u:DialogControl">
<ControlTheme x:Key="{x:Type u:CustomDialogControl}" TargetType="u:CustomDialogControl">
<Setter Property="CornerRadius" Value="12" />
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
</Transitions>
</Setter>
<Setter Property="RenderTransform" Value="scale(1.0)"></Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:DialogControl">
<ControlTemplate TargetType="u:CustomDialogControl">
<Border
Margin="8"
Padding="0"
@@ -30,7 +36,7 @@
Content="{TemplateBinding Content}" />
<Grid Grid.Row="0" ColumnDefinitions="*, Auto">
<Panel
Name="{x:Static u:DialogControl.PART_TitleArea}"
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="2"
Background="Transparent" />
@@ -46,12 +52,14 @@
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^[IsClosed=True]">
<Setter Property="RenderTransform" Value="scale(0.95)"/>
</Style>
<Style Selector="^ /template/ Panel#PART_TitleArea">
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem
Command="{Binding $parent[u:DialogControl].CloseDialog}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Command="{Binding $parent[u:DialogControlBase].Close}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
@@ -67,7 +75,7 @@
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Header="{DynamicResource STRING_MENU_BRING_FORWARD}">
<MenuItem.Icon>
@@ -78,7 +86,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringToFront}"
Header="{DynamicResource STRING_MENU_BRING_TO_FRONT}">
<MenuItem.Icon>
@@ -89,7 +97,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.SendBackward}"
Header="{DynamicResource STRING_MENU_SEND_BACKWARD}">
<MenuItem.Icon>
@@ -100,7 +108,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.SendToBack}"
Header="{DynamicResource STRING_MENU_SEND_TO_BACK}">
<MenuItem.Icon>
@@ -111,8 +119,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].CloseDialog}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Command="{Binding $parent[u:DialogControlBase].Close}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
@@ -128,6 +135,11 @@
<ControlTheme x:Key="{x:Type u:DefaultDialogControl}" TargetType="u:DefaultDialogControl">
<Setter Property="CornerRadius" Value="12" />
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
</Transitions>
</Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:DefaultDialogControl">
<Border
@@ -152,7 +164,7 @@
</ScrollViewer>
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
<Panel
Name="{x:Static u:DialogControl.PART_TitleArea}"
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="3"
Background="Transparent" />
@@ -216,6 +228,9 @@
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^[IsClosed=True]">
<Setter Property="RenderTransform" Value="scale(0.95)"/>
</Style>
<Style Selector="^[Mode=None]">
<Style Selector="^ /template/ PathIcon#PART_Icon">
<Setter Property="IsVisible" Value="False" />
@@ -338,8 +353,7 @@
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem
Command="{Binding $parent[u:DialogControl].CloseDialog}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Command="{Binding $parent[u:DialogControlBase].Close}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
@@ -355,7 +369,7 @@
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Header="{DynamicResource STRING_MENU_BRING_FORWARD}">
<MenuItem.Icon>
@@ -366,7 +380,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringToFront}"
Header="{DynamicResource STRING_MENU_BRING_TO_FRONT}">
<MenuItem.Icon>
@@ -377,7 +391,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.SendBackward}"
Header="{DynamicResource STRING_MENU_SEND_BACKWARD}">
<MenuItem.Icon>
@@ -388,7 +402,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].UpdateLayer}"
Command="{Binding $parent[u:DialogControlBase].UpdateLayer}"
CommandParameter="{x:Static u:DialogLayerChangeType.SendToBack}"
Header="{DynamicResource STRING_MENU_SEND_TO_BACK}">
<MenuItem.Icon>
@@ -399,7 +413,7 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding $parent[u:DialogControl].CloseDialog}"
Command="{Binding $parent[u:DialogControlBase].Close}"
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>

View File

@@ -0,0 +1,167 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<ControlTheme TargetType="u:CustomDrawerControl" x:Key="{x:Type u:CustomDrawerControl}">
<Setter Property="VerticalAlignment" Value="Stretch"></Setter>
<Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:CustomDrawerControl">
<Border Name="PART_Root"
Margin="8 -1 -1 -1"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Classes="Shadow"
ClipToBounds="False"
CornerRadius="12 0 0 12"
BorderThickness="1 0 0 0"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
<Border ClipToBounds="True" CornerRadius="{Binding #PART_Root.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 CloseButton}" />
</Grid>
</Grid>
</Border>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^[Position=Right] /template/ Border#PART_Root">
<Setter Property="Margin" Value="8 0 0 0" />
<Setter Property="CornerRadius" Value="12 0 0 12" />
<Setter Property="BorderThickness" Value="1 0 0 0" />
</Style>
<Style Selector="^[Position=Left] /template/ Border#PART_Root">
<Setter Property="Margin" Value="0 0 8 0" />
<Setter Property="CornerRadius" Value="0 12 12 0" />
<Setter Property="BorderThickness" Value="0 0 1 0" />
</Style>
<Style Selector="^[Position=Top] /template/ Border#PART_Root">
<Setter Property="Margin" Value="0 0 0 8" />
<Setter Property="CornerRadius" Value="0 0 12 12" />
<Setter Property="BorderThickness" Value="0 0 0 1" />
</Style>
<Style Selector="^[Position=Bottom] /template/ Border#PART_Root">
<Setter Property="Margin" Value="0 8 0 0" />
<Setter Property="CornerRadius" Value="12 12 0 0" />
<Setter Property="BorderThickness" Value="0 1 0 0" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:DefaultDrawerControl}" TargetType="u:DefaultDrawerControl">
<Setter Property="VerticalAlignment" Value="Stretch"></Setter>
<Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:DefaultDrawerControl">
<Border Name="PART_Root"
Margin="8 -1 -1 -1"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Classes="Shadow"
ClipToBounds="False"
CornerRadius="12 0 0 12"
BorderThickness="1 0 0 0"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
<Border ClipToBounds="True" CornerRadius="{Binding #PART_Root.CornerRadius}">
<Grid RowDefinitions="Auto, *, Auto">
<ScrollViewer Grid.Row="1">
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Row="1"
Margin="24,8"
Content="{TemplateBinding Content}" />
</ScrollViewer>
<Grid Grid.Row="0" ColumnDefinitions=" *, Auto">
<TextBlock
Name="PART_Title"
Grid.Column="0"
Margin="24,24,0,0"
VerticalAlignment="Center"
FontSize="16"
FontWeight="Bold"
IsHitTestVisible="False"
IsVisible="{TemplateBinding Title,
Converter={x:Static ObjectConverters.IsNotNull}}"
Text="{TemplateBinding Title}"
TextWrapping="Wrap" />
<Button
Name="{x:Static u:DrawerControlBase.PART_CloseButton}"
Grid.Column="1"
Margin="0,24,24,0"
DockPanel.Dock="Right"
Theme="{DynamicResource CloseButton}" />
</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>
</Border>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^[Position=Right] /template/ Border#PART_Root">
<Setter Property="Margin" Value="8 0 0 0" />
<Setter Property="CornerRadius" Value="12 0 0 12" />
<Setter Property="BorderThickness" Value="1 0 0 0" />
</Style>
<Style Selector="^[Position=Left] /template/ Border#PART_Root">
<Setter Property="Margin" Value="0 0 8 0" />
<Setter Property="CornerRadius" Value="0 12 12 0" />
<Setter Property="BorderThickness" Value="0 0 1 0" />
</Style>
<Style Selector="^[Position=Top] /template/ Border#PART_Root">
<Setter Property="Margin" Value="0 0 0 8" />
<Setter Property="CornerRadius" Value="0 0 12 12" />
<Setter Property="BorderThickness" Value="0 0 0 1" />
</Style>
<Style Selector="^[Position=Bottom] /template/ Border#PART_Root">
<Setter Property="Margin" Value="0 8 0 0" />
<Setter Property="CornerRadius" Value="12 12 0 0" />
<Setter Property="BorderThickness" Value="0 1 0 0" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -165,7 +165,7 @@
<Grid RowDefinitions="Auto, *, Auto">
<Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto">
<Panel
Name="{x:Static u:DialogControl.PART_TitleArea}"
Name="{x:Static u:DialogControlBase.PART_TitleArea}"
Grid.Column="0"
Grid.ColumnSpan="3"
Background="Transparent" />
@@ -247,7 +247,7 @@
<Style Selector="^ /template/ Panel#PART_TitleArea">
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem Command="{Binding $parent[u:DialogControl].CloseDialog}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem Command="{Binding $parent[u:CustomDialogControl].CloseDialog}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"

View File

@@ -8,6 +8,7 @@
<ResourceInclude Source="Dialog.axaml" />
<ResourceInclude Source="DialogShared.axaml" />
<ResourceInclude Source="Divider.axaml" />
<ResourceInclude Source="Drawer.axaml" />
<ResourceInclude Source="DualBadge.axaml" />
<ResourceInclude Source="EnumSelector.axaml" />
<ResourceInclude Source="IconButton.axaml" />