feat: implement resizing logic.

This commit is contained in:
rabbitism
2024-02-05 22:06:17 +08:00
parent fd85efd895
commit 36c63b6326
6 changed files with 97 additions and 20 deletions

View File

@@ -135,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
@@ -223,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" />

View File

@@ -6,7 +6,8 @@
<Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:CustomDrawerControl">
<Border Margin="8 -1 -1 -1"
<Border Name="PART_Root"
Margin="8 -1 -1 -1"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
@@ -41,5 +42,25 @@
</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

@@ -46,6 +46,30 @@ public partial class OverlayDialogHost
control.Width = this.Bounds.Width;
}
}
private static void ResetDrawerPosition(DrawerControlBase control, Size newSize)
{
if (control.Position == Position.Right)
{
control.Height = newSize.Height;
SetLeft(control, newSize.Width - control.Bounds.Width);
}
else if (control.Position == Position.Left)
{
control.Height = newSize.Height;
SetLeft(control, 0);
}
else if (control.Position == Position.Bottom)
{
control.Width = newSize.Width;
SetTop(control, 0);
}
else
{
control.Width = newSize.Width;
SetTop(control, newSize.Height-control.Bounds.Height);
}
}
private Animation CreateAnimation(Size elementBounds, Position position, bool appear = true)
{

View File

@@ -130,6 +130,10 @@ public partial class OverlayDialogHost: Canvas
{
ResetDialogPosition(d, e.NewSize);
}
else if (_layers[i].Element is DrawerControlBase drawer)
{
ResetDrawerPosition(drawer, e.NewSize);
}
}
}