diff --git a/demo/Ursa.Demo/Pages/DialogDemo.axaml b/demo/Ursa.Demo/Pages/DialogDemo.axaml
index 1e6e67f..7981a93 100644
--- a/demo/Ursa.Demo/Pages/DialogDemo.axaml
+++ b/demo/Ursa.Demo/Pages/DialogDemo.axaml
@@ -39,22 +39,27 @@
IsChecked="{Binding CanLightDismiss}"
OffContent="No"
OnContent="Yes" />
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -73,8 +78,8 @@
OffContent="Local"
OnContent="Global" />
@@ -83,6 +88,11 @@
IsChecked="{Binding CanLightDismiss}"
OffContent="No"
OnContent="Yes" />
+
diff --git a/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs
index cf5d6b3..2b3d146 100644
--- a/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs
@@ -11,85 +11,28 @@ using Ursa.Demo.Pages;
namespace Ursa.Demo.ViewModels;
-public class DialogDemoViewModel: ObservableObject
+public partial class DialogDemoViewModel: ObservableObject
{
public ICommand ShowDialogCommand { get; set; }
public ICommand ShowCustomDialogCommand { get; set; }
- private DialogMode _selectedMode;
- public DialogMode SelectedMode
- {
- get => _selectedMode;
- set => SetProperty(ref _selectedMode, value);
- }
-
- public ObservableCollection Modes { get; set; }
-
- private DialogButton _selectedButton;
- public DialogButton SelectedButton
- {
- get => _selectedButton;
- set => SetProperty(ref _selectedButton, value);
- }
-
- public ObservableCollection Buttons { get; set; }
-
- private bool _isWindow;
- public bool IsWindow
- {
- get => _isWindow;
- set => SetProperty(ref _isWindow, value);
- }
-
- private bool _isGlobal;
- public bool IsGlobal
- {
- get => _isGlobal;
- set => SetProperty(ref _isGlobal, value);
- }
-
- private bool _isModal;
- public bool IsModal
- {
- get => _isModal;
- set => SetProperty(ref _isModal, value);
- }
-
- private bool _canLightDismiss;
- public bool CanLightDismiss
- {
- get => _canLightDismiss;
- set => SetProperty(ref _canLightDismiss, value);
- }
-
- private DialogResult? _defaultResult;
- public DialogResult? DefaultResult
- {
- get => _defaultResult;
- set => SetProperty(ref _defaultResult, value);
- }
-
- private bool _result;
- public bool Result
- {
- get => _result;
- set => SetProperty(ref _result, value);
- }
-
- private DateTime? _date;
- public DateTime? Date
- {
- get => _date;
- set => SetProperty(ref _date, value);
- }
-
+ [ObservableProperty] private DialogMode _selectedMode;
+ [ObservableProperty] private DialogButton _selectedButton;
+ [ObservableProperty] private bool _isWindow;
+ [ObservableProperty] private bool _isGlobal;
+ [ObservableProperty] private bool _isModal;
+ [ObservableProperty] private bool _canLightDismiss;
+ [ObservableProperty] private DialogResult? _defaultResult;
+ [ObservableProperty] private bool _result;
+ [ObservableProperty] private DateTime? _date;
+ [ObservableProperty] private bool _fullScreen;
public DialogDemoViewModel()
{
ShowDialogCommand = new AsyncRelayCommand(ShowDialog);
ShowCustomDialogCommand = new AsyncRelayCommand(ShowCustomDialog);
- Modes = new ObservableCollection(Enum.GetValues());
- Buttons = new ObservableCollection(Enum.GetValues());
+ IsModal = true;
+ IsGlobal = true;
}
private async Task ShowDialog()
@@ -123,6 +66,7 @@ public class DialogDemoViewModel: ObservableObject
HorizontalOffset = 50,
VerticalAnchor = VerticalPosition.Top,
VerticalOffset = 50,
+ FullScreen = FullScreen,
}
);
Date = vm.Date;
@@ -138,6 +82,7 @@ public class DialogDemoViewModel: ObservableObject
Mode = SelectedMode,
Buttons = SelectedButton,
CanLightDismiss = CanLightDismiss,
+ FullScreen = FullScreen,
});
}
}
@@ -149,7 +94,6 @@ public class DialogDemoViewModel: ObservableObject
var vm = new DialogWithActionViewModel();
if (IsWindow)
{
-
if (IsModal)
{
Result = await Dialog.ShowCustomModal(
@@ -161,7 +105,6 @@ public class DialogDemoViewModel: ObservableObject
Dialog.ShowCustom(
vm);
}
-
}
else
{
@@ -171,6 +114,7 @@ public class DialogDemoViewModel: ObservableObject
vm, IsGlobal ? null : "LocalHost", options: new OverlayDialogOptions()
{
CanLightDismiss = CanLightDismiss,
+ FullScreen = FullScreen,
});
Date = vm.Date;
}
@@ -178,7 +122,7 @@ public class DialogDemoViewModel: ObservableObject
{
OverlayDialog.ShowCustom(new DialogWithActionViewModel(),
IsGlobal ? null : "LocalHost",
- options: new OverlayDialogOptions{ CanLightDismiss = CanLightDismiss });
+ options: new OverlayDialogOptions{ CanLightDismiss = CanLightDismiss, FullScreen = FullScreen});
}
}
diff --git a/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs
index e51586b..c438020 100644
--- a/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs
@@ -31,6 +31,9 @@ public partial class DrawerDemoViewModel: ObservableObject
{
ShowDialogCommand = new AsyncRelayCommand(ShowDefaultDialog);
ShowCustomDialogCommand = new AsyncRelayCommand(ShowCustomDrawer);
+ SelectedPosition = Position.Right;
+ IsGlobal = true;
+ IsModal = true;
}
private async Task ShowDefaultDialog()
diff --git a/src/Ursa.Themes.Semi/Controls/Dialog.axaml b/src/Ursa.Themes.Semi/Controls/Dialog.axaml
index 5980151..6060c01 100644
--- a/src/Ursa.Themes.Semi/Controls/Dialog.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Dialog.axaml
@@ -18,7 +18,7 @@
+ Theme="{DynamicResource OverlayCloseButton}" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Controls/Drawer.axaml b/src/Ursa.Themes.Semi/Controls/Drawer.axaml
index e397fcd..28df5ea 100644
--- a/src/Ursa.Themes.Semi/Controls/Drawer.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Drawer.axaml
@@ -35,7 +35,7 @@
Grid.Column="1"
Margin="0,24,24,0"
DockPanel.Dock="Right"
- Theme="{DynamicResource CloseButton}" />
+ Theme="{DynamicResource OverlayCloseButton}" />
@@ -107,7 +107,7 @@
Grid.Column="1"
Margin="0,24,24,0"
DockPanel.Dock="Right"
- Theme="{DynamicResource CloseButton}" />
+ Theme="{DynamicResource OverlayCloseButton}" />
+
+ Theme="{DynamicResource OverlayCloseButton}" />
IsFullScreenProperty = AvaloniaProperty.RegisterDirect(
+ nameof(IsFullScreen), o => o.IsFullScreen, (o, v) => o.IsFullScreen = v);
+
+ public bool IsFullScreen
+ {
+ get => _isFullScreen;
+ set => SetAndRaise(IsFullScreenProperty, ref _isFullScreen, value);
+ }
protected internal Button? _closeButton;
private Panel? _titleArea;
@@ -134,6 +145,7 @@ public abstract class DialogControlBase : OverlayFeedbackElement
{
CanDragMoveProperty.Changed.AddClassHandler(OnCanDragMoveChanged);
CanCloseProperty.Changed.AddClassHandler(OnCanCloseChanged);
+ IsFullScreenProperty.AffectsPseudoClass(PC_FullScreen);
}
@@ -143,7 +155,7 @@ public abstract class DialogControlBase : OverlayFeedbackElement
{
base.OnApplyTemplate(e);
_titleArea = e.NameScope.Find(PART_TitleArea);
- if (CanDragMove)
+ if (GetCanDragMove(this))
{
_titleArea?.RemoveHandler(PointerMovedEvent, OnTitlePointerMove);
_titleArea?.RemoveHandler(PointerPressedEvent, OnTitlePointerPressed);
diff --git a/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs b/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs
index f58ea2a..7ac073e 100644
--- a/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs
+++ b/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs
@@ -17,6 +17,7 @@ public enum VerticalPosition
public class OverlayDialogOptions
{
internal static OverlayDialogOptions Default { get; } = new OverlayDialogOptions();
+ public bool FullScreen { get; set; }
public HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
public VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
///
diff --git a/src/Ursa/Controls/Dialog/OverlayDialog.cs b/src/Ursa/Controls/Dialog/OverlayDialog.cs
index 7d69047..7d57525 100644
--- a/src/Ursa/Controls/Dialog/OverlayDialog.cs
+++ b/src/Ursa/Controls/Dialog/OverlayDialog.cs
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Layout;
using Ursa.Common;
namespace Ursa.Controls;
@@ -181,6 +182,12 @@ public static class OverlayDialog
private static void ConfigureCustomDialogControl(CustomDialogControl control, OverlayDialogOptions? options)
{
options ??= OverlayDialogOptions.Default;
+ control.IsFullScreen = options.FullScreen;
+ if (options.FullScreen)
+ {
+ control.HorizontalAlignment = HorizontalAlignment.Stretch;
+ control.VerticalAlignment = VerticalAlignment.Stretch;
+ }
control.HorizontalAnchor = options.HorizontalAnchor;
control.VerticalAnchor = options.VerticalAnchor;
control.ActualHorizontalAnchor = options.HorizontalAnchor;
@@ -191,12 +198,18 @@ public static class OverlayDialog
options.VerticalAnchor == VerticalPosition.Center ? null : options.VerticalOffset;
control.IsCloseButtonVisible = options.ShowCloseButton;
control.CanLightDismiss = options.CanLightDismiss;
- control.CanDragMove = options.CanDragMove;
+ DialogControlBase.SetCanDragMove(control, options.CanDragMove);
}
private static void ConfigureDefaultDialogControl(DefaultDialogControl control, OverlayDialogOptions? options)
{
if (options is null) options = new OverlayDialogOptions();
+ control.IsFullScreen = options.FullScreen;
+ if (options.FullScreen)
+ {
+ control.HorizontalAlignment = HorizontalAlignment.Stretch;
+ control.VerticalAlignment = VerticalAlignment.Stretch;
+ }
control.HorizontalAnchor = options.HorizontalAnchor;
control.VerticalAnchor = options.VerticalAnchor;
control.ActualHorizontalAnchor = options.HorizontalAnchor;
@@ -209,7 +222,7 @@ public static class OverlayDialog
control.Buttons = options.Buttons;
control.Title = options.Title;
control.CanLightDismiss = options.CanLightDismiss;
- control.CanDragMove = options.CanDragMove;
+ DialogControlBase.SetCanDragMove(control, options.CanDragMove);
}
internal static T? Recall(string? hostId) where T: Control
diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs
index baa9139..f219815 100644
--- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs
+++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs
@@ -14,6 +14,14 @@ public partial class OverlayDialogHost
private static void ResetDialogPosition(DialogControlBase control, Size newSize)
{
+ if (control.IsFullScreen)
+ {
+ control.Width = newSize.Width;
+ control.Height = newSize.Height;
+ SetLeft(control, 0);
+ SetTop(control, 0);
+ return;
+ }
var width = newSize.Width - control.Bounds.Width;
var height = newSize.Height - control.Bounds.Height;
var newLeft = width * control.HorizontalOffsetRatio??0;
@@ -84,6 +92,11 @@ public partial class OverlayDialogHost
}
this.Children.Add(control);
_layers.Add(new DialogPair(mask, control, false));
+ if (control.IsFullScreen)
+ {
+ control.Width = Bounds.Width;
+ control.Height = Bounds.Height;
+ }
control.Measure(this.Bounds.Size);
control.Arrange(new Rect(control.DesiredSize));
SetToPosition(control);
@@ -113,7 +126,10 @@ public partial class OverlayDialogHost
{
_modalCount--;
HasModal = _modalCount > 0;
- await _maskDisappearAnimation.RunAsync(layer.Mask);
+ if (!IsAnimationDisabled)
+ {
+ await _maskDisappearAnimation.RunAsync(layer.Mask);
+ }
}
}
@@ -133,12 +149,20 @@ public partial class OverlayDialogHost
ResetZIndices();
this.Children.Add(mask);
this.Children.Add(control);
+ if (control.IsFullScreen)
+ {
+ control.Width = Bounds.Width;
+ control.Height = Bounds.Height;
+ }
control.Measure(this.Bounds.Size);
control.Arrange(new Rect(control.DesiredSize));
SetToPosition(control);
control.AddHandler(OverlayFeedbackElement.ClosedEvent, OnDialogControlClosing);
control.AddHandler(DialogControlBase.LayerChangedEvent, OnDialogLayerChanged);
- _maskAppearAnimation.RunAsync(mask);
+ if (!IsAnimationDisabled)
+ {
+ _maskAppearAnimation.RunAsync(mask);
+ }
_modalCount++;
HasModal = _modalCount > 0;
control.IsClosed = false;
diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
index d83c58a..d7a1bfa 100644
--- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
+++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
@@ -28,13 +28,20 @@ public partial class OverlayDialogHost
SetDrawerPosition(control);
control.AddHandler(OverlayFeedbackElement.ClosedEvent, OnDrawerControlClosing);
var animation = CreateAnimation(control.Bounds.Size, control.Position, true);
- if (mask is null)
+ if (IsAnimationDisabled)
{
- await animation.RunAsync(control);
+ ResetDrawerPosition(control, this.Bounds.Size);
}
else
{
- await Task.WhenAll(animation.RunAsync(control), _maskAppearAnimation.RunAsync(mask));
+ if (mask is null)
+ {
+ await animation.RunAsync(control);
+ }
+ else
+ {
+ await Task.WhenAll(animation.RunAsync(control), _maskAppearAnimation.RunAsync(mask));
+ }
}
}
@@ -48,9 +55,18 @@ public partial class OverlayDialogHost
control.Measure(this.Bounds.Size);
control.Arrange(new Rect(control.DesiredSize));
SetDrawerPosition(control);
+ _modalCount++;
+ HasModal = _modalCount > 0;
control.AddHandler(OverlayFeedbackElement.ClosedEvent, OnDrawerControlClosing);
var animation = CreateAnimation(control.Bounds.Size, control.Position);
- await Task.WhenAll(animation.RunAsync(control), _maskAppearAnimation.RunAsync(mask));
+ if (IsAnimationDisabled)
+ {
+ ResetDrawerPosition(control, this.Bounds.Size);
+ }
+ else
+ {
+ await Task.WhenAll(animation.RunAsync(control), _maskAppearAnimation.RunAsync(mask));
+ }
}
private void SetDrawerPosition(DrawerControlBase control)
@@ -145,15 +161,23 @@ public partial class OverlayDialogHost
control.RemoveHandler(DialogControlBase.LayerChangedEvent, OnDialogLayerChanged);
if (layer.Mask is not null)
{
+ _modalCount--;
+ HasModal = _modalCount > 0;
layer.Mask.RemoveHandler(PointerPressedEvent, ClickMaskToCloseDialog);
- var disappearAnimation = CreateAnimation(control.Bounds.Size, control.Position, false);
- await Task.WhenAll(disappearAnimation.RunAsync(control), _maskDisappearAnimation.RunAsync(layer.Mask));
+ if (!IsAnimationDisabled)
+ {
+ var disappearAnimation = CreateAnimation(control.Bounds.Size, control.Position, false);
+ await Task.WhenAll(disappearAnimation.RunAsync(control), _maskDisappearAnimation.RunAsync(layer.Mask));
+ }
Children.Remove(layer.Mask);
}
else
{
- var disappearAnimation = CreateAnimation(control.Bounds.Size, control.Position, false);
- await disappearAnimation.RunAsync(control);
+ if (!IsAnimationDisabled)
+ {
+ var disappearAnimation = CreateAnimation(control.Bounds.Size, control.Position, false);
+ await disappearAnimation.RunAsync(control);
+ }
}
Children.Remove(control);
ResetZIndices();
diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs
index f2bdfa9..e993696 100644
--- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs
+++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs
@@ -15,7 +15,7 @@ public partial class OverlayDialogHost: Canvas
private static readonly Animation _maskAppearAnimation;
private static readonly Animation _maskDisappearAnimation;
- private readonly List _layers = new List();
+ private readonly List _layers = new List(10);
private class DialogPair
{
@@ -43,6 +43,8 @@ public partial class OverlayDialogHost: Canvas
get => _hasModal;
private set => SetAndRaise(HasModalProperty, ref _hasModal, value);
}
+
+ public bool IsAnimationDisabled { get; set; }
static OverlayDialogHost()
{