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:
@@ -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)
|
||||
|
||||
@@ -24,6 +24,9 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
AvaloniaProperty.RegisterDirect<DialogControlBase, bool>(
|
||||
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;
|
||||
|
||||
private bool _isFullScreen;
|
||||
@@ -36,6 +39,12 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
IsFullScreenProperty.AffectsPseudoClass<DialogControlBase>(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; }
|
||||
|
||||
@@ -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<bool> IsManagedResizerVisibleProperty = AvaloniaProperty.Register<DialogWindow, bool>(
|
||||
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<object?> args)
|
||||
{
|
||||
|
||||
@@ -30,4 +30,6 @@ public class DialogOptions
|
||||
public bool ShowInTaskBar { get; set; } = true;
|
||||
|
||||
public bool CanDragMove { get; set; } = true;
|
||||
|
||||
public bool CanResize { get; set; }
|
||||
}
|
||||
@@ -62,4 +62,6 @@ public class OverlayDialogOptions
|
||||
/// id.
|
||||
/// </summary>
|
||||
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;
|
||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||
control.CanLightDismiss = options.CanLightDismiss;
|
||||
control.CanResize = options.CanResize;
|
||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||
}
|
||||
|
||||
@@ -229,6 +230,7 @@ public static class OverlayDialog
|
||||
control.Title = options.Title;
|
||||
control.CanLightDismiss = options.CanLightDismiss;
|
||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||
control.CanResize = options.CanResize;
|
||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user