diff --git a/demo/Ursa.Demo/Pages/DialogDemo.axaml b/demo/Ursa.Demo/Pages/DialogDemo.axaml
index 0331fa4..2b4fe18 100644
--- a/demo/Ursa.Demo/Pages/DialogDemo.axaml
+++ b/demo/Ursa.Demo/Pages/DialogDemo.axaml
@@ -50,6 +50,7 @@
IsChecked="{Binding IsCloseButtonVisible}"
IsThreeState="True" />
+
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Controls/Dialog.axaml b/src/Ursa.Themes.Semi/Controls/Dialog.axaml
index d096126..6b8bfc6 100644
--- a/src/Ursa.Themes.Semi/Controls/Dialog.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Dialog.axaml
@@ -7,68 +7,72 @@
+
+
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
+
-
+
\ No newline at end of file
diff --git a/src/Ursa.Themes.Semi/Controls/Drawer.axaml b/src/Ursa.Themes.Semi/Controls/Drawer.axaml
index 66bb9d9..3800d0f 100644
--- a/src/Ursa.Themes.Semi/Controls/Drawer.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Drawer.axaml
@@ -1,154 +1,60 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Controls/Resizer.axaml b/src/Ursa.Themes.Semi/Controls/Resizer.axaml
index 59e5ced..31556fc 100644
--- a/src/Ursa.Themes.Semi/Controls/Resizer.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Resizer.axaml
@@ -1,29 +1,144 @@
-
-
-
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Dialog.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Dialog.axaml
index f3c6409..eda0add 100644
--- a/src/Ursa.Themes.Semi/Themes/Shared/Dialog.axaml
+++ b/src/Ursa.Themes.Semi/Themes/Shared/Dialog.axaml
@@ -6,4 +6,6 @@
M2,2H16V16H2V2M22,8V22H8V18H18V8H22M4,4V14H14V4H4Z
M2,2H11V11H2V2M9,4H4V9H9V4M22,13V22H13V13H22M15,20H20V15H15V20M16,8V11H13V8H16M11,16H8V13H11V16Z
12
+ 48
+ 48
diff --git a/src/Ursa/Controls/Dialog/Dialog.cs b/src/Ursa/Controls/Dialog/Dialog.cs
index 08deb07..be9d516 100644
--- a/src/Ursa/Controls/Dialog/Dialog.cs
+++ b/src/Ursa/Controls/Dialog/Dialog.cs
@@ -205,6 +205,8 @@ public static class Dialog
window.IsCloseButtonVisible = options.IsCloseButtonVisible;
window.ShowInTaskbar = options.ShowInTaskBar;
window.CanDragMove = options.CanDragMove;
+ window.CanResize = options.CanResize;
+ window.IsManagedResizerVisible = options.CanResize;
if (options.StartupLocation == WindowStartupLocation.Manual)
{
if (options.Position is not null)
@@ -229,6 +231,8 @@ public static class Dialog
window.ShowInTaskbar = options.ShowInTaskBar;
window.IsCloseButtonVisible = options.IsCloseButtonVisible;
window.CanDragMove = options.CanDragMove;
+ window.IsManagedResizerVisible = options.CanResize;
+ window.CanResize = options.CanResize;
if (options.StartupLocation == WindowStartupLocation.Manual)
{
if (options.Position is not null)
diff --git a/src/Ursa/Controls/Dialog/DialogControlBase.cs b/src/Ursa/Controls/Dialog/DialogControlBase.cs
index aa0cabb..7ebcd23 100644
--- a/src/Ursa/Controls/Dialog/DialogControlBase.cs
+++ b/src/Ursa/Controls/Dialog/DialogControlBase.cs
@@ -24,10 +24,16 @@ public abstract class DialogControlBase : OverlayFeedbackElement
AvaloniaProperty.RegisterDirect(
nameof(IsFullScreen), o => o.IsFullScreen, (o, v) => o.IsFullScreen = v);
+ public static readonly StyledProperty CanResizeProperty = AvaloniaProperty.Register(
+ nameof(CanResize));
+
protected internal Button? _closeButton;
private bool _isFullScreen;
private Panel? _titleArea;
+ private bool _moveDragging;
+ private Point _moveDragStartPoint;
+
static DialogControlBase()
{
@@ -36,6 +42,12 @@ public abstract class DialogControlBase : OverlayFeedbackElement
IsFullScreenProperty.AffectsPseudoClass(PC_FullScreen);
}
+ public bool CanResize
+ {
+ get => GetValue(CanResizeProperty);
+ set => SetValue(CanResizeProperty, value);
+ }
+
internal HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
internal VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
internal HorizontalPosition ActualHorizontalAnchor { get; set; }
@@ -79,17 +91,44 @@ public abstract class DialogControlBase : OverlayFeedbackElement
private void OnTitlePointerPressed(InputElement sender, PointerPressedEventArgs e)
{
- e.Source = this;
+ //e.Source = this;
+ if (ContainerPanel is OverlayDialogHost h)
+ {
+ if (h.IsTopLevel && this.IsFullScreen)
+ {
+ var top = TopLevel.GetTopLevel(this);
+ if (top is Window w)
+ {
+ w.BeginMoveDrag(e);
+ return;
+ }
+ }
+ }
+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
+ if (IsFullScreen) return;
+ _moveDragging = true;
+ _moveDragStartPoint = e.GetPosition(this);
}
private void OnTitlePointerMove(InputElement sender, PointerEventArgs e)
{
- e.Source = this;
+ //e.Source = this;
+ if (!_moveDragging) return;
+ if (ContainerPanel is null) return;
+ var p = e.GetPosition(this);
+ var left = Canvas.GetLeft(this) + p.X - _moveDragStartPoint.X;
+ var top = Canvas.GetTop(this) + p.Y - _moveDragStartPoint.Y;
+ left = MathHelpers.SafeClamp(left, 0, ContainerPanel.Bounds.Width - Bounds.Width);
+ top = MathHelpers.SafeClamp(top, 0, ContainerPanel.Bounds.Height - Bounds.Height);
+ Canvas.SetLeft(this, left);
+ Canvas.SetTop(this, top);
}
private void OnTitlePointerRelease(InputElement sender, PointerReleasedEventArgs e)
{
- e.Source = this;
+ // e.Source = this;
+ _moveDragging = false;
+ AnchorAndUpdatePositionInfo();
}
private void OnCloseButtonClick(object? sender, RoutedEventArgs args)
@@ -195,4 +234,50 @@ public abstract class DialogControlBase : OverlayFeedbackElement
}
#endregion
+
+ protected internal override void AnchorAndUpdatePositionInfo()
+ {
+ if (ContainerPanel is null) return;
+ ActualHorizontalAnchor = HorizontalPosition.Center;
+ ActualVerticalAnchor = VerticalPosition.Center;
+ double left = Canvas.GetLeft(this);
+ double top = Canvas.GetTop(this);
+ double right = ContainerPanel.Bounds.Width - left - Bounds.Width;
+ double bottom = ContainerPanel.Bounds.Height - top - Bounds.Height;
+ if (ContainerPanel is OverlayDialogHost h)
+ {
+ var snapThickness = h.SnapThickness;
+ if(top < snapThickness.Top)
+ {
+ Canvas.SetTop(this, 0);
+ ActualVerticalAnchor = VerticalPosition.Top;
+ VerticalOffsetRatio = 0;
+ }
+ if(bottom < snapThickness.Bottom)
+ {
+ Canvas.SetTop(this, ContainerPanel.Bounds.Height - Bounds.Height);
+ ActualVerticalAnchor = VerticalPosition.Bottom;
+ VerticalOffsetRatio = 1;
+ }
+ if(left < snapThickness.Left)
+ {
+ Canvas.SetLeft(this, 0);
+ ActualHorizontalAnchor = HorizontalPosition.Left;
+ HorizontalOffsetRatio = 0;
+ }
+ if(right < snapThickness.Right)
+ {
+ Canvas.SetLeft(this, ContainerPanel.Bounds.Width - this.Bounds.Width);
+ ActualHorizontalAnchor = HorizontalPosition.Right;
+ HorizontalOffsetRatio = 1;
+ }
+ }
+ left = Canvas.GetLeft(this);
+ top = Canvas.GetTop(this);
+ right = ContainerPanel.Bounds.Width - left - Bounds.Width;
+ bottom = ContainerPanel.Bounds.Height - top - Bounds.Height;
+
+ HorizontalOffsetRatio = (left + right) == 0 ? 0 : left / (left + right);
+ VerticalOffsetRatio = (top + bottom) == 0 ? 0 : top / (top + bottom);
+ }
}
\ No newline at end of file
diff --git a/src/Ursa/Controls/Dialog/DialogWindow.cs b/src/Ursa/Controls/Dialog/DialogWindow.cs
index 29f5398..f56ae09 100644
--- a/src/Ursa/Controls/Dialog/DialogWindow.cs
+++ b/src/Ursa/Controls/Dialog/DialogWindow.cs
@@ -17,8 +17,17 @@ public class DialogWindow : Window
public const string PART_TitleArea = "PART_TitleArea";
protected internal Button? _closeButton;
+
private Panel? _titleArea;
- public bool CanDragMove { get; set; } = true;
+
+ public static readonly StyledProperty IsManagedResizerVisibleProperty = AvaloniaProperty.Register(
+ nameof(IsManagedResizerVisible));
+
+ public bool IsManagedResizerVisible
+ {
+ get => GetValue(IsManagedResizerVisibleProperty);
+ set => SetValue(IsManagedResizerVisibleProperty, value);
+ }
static DialogWindow()
{
@@ -26,9 +35,11 @@ public class DialogWindow : Window
window.OnDataContextChange(e));
}
+ public bool CanDragMove { get; set; } = true;
+ internal bool? IsCloseButtonVisible { get; set; }
+
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
- internal bool? IsCloseButtonVisible { get; set; }
private void OnDataContextChange(AvaloniaPropertyChangedEventArgs