feat: implement default control and window mode.
This commit is contained in:
@@ -44,13 +44,13 @@ public class DefaultDialogControl: DialogControl
|
||||
set => SetValue(ButtonsProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<DialogIcon> IconProperty = AvaloniaProperty.Register<DefaultDialogControl, DialogIcon>(
|
||||
nameof(Icon));
|
||||
public static readonly StyledProperty<DialogMode> ModeProperty = AvaloniaProperty.Register<DefaultDialogControl, DialogMode>(
|
||||
nameof(Mode));
|
||||
|
||||
public DialogIcon Icon
|
||||
public DialogMode Mode
|
||||
{
|
||||
get => GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
get => GetValue(ModeProperty);
|
||||
set => SetValue(ModeProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
|
||||
@@ -34,13 +34,13 @@ public class DefaultDialogWindow: DialogWindow
|
||||
set => SetValue(ButtonsProperty, value);
|
||||
}
|
||||
|
||||
public new static readonly StyledProperty<DialogIcon> IconProperty = AvaloniaProperty.Register<DefaultDialogWindow, DialogIcon>(
|
||||
nameof(Icon));
|
||||
public static readonly StyledProperty<DialogMode> ModeProperty = AvaloniaProperty.Register<DefaultDialogWindow, DialogMode>(
|
||||
nameof(Mode));
|
||||
|
||||
public new DialogIcon Icon
|
||||
public DialogMode Mode
|
||||
{
|
||||
get => GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
get => GetValue(ModeProperty);
|
||||
set => SetValue(ModeProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
|
||||
@@ -58,7 +58,7 @@ public static class Dialog
|
||||
Window? owner,
|
||||
TViewModel vm,
|
||||
string? title = null,
|
||||
DialogIcon icon = DialogIcon.None,
|
||||
DialogMode mode = DialogMode.None,
|
||||
DialogButton buttons = DialogButton.OKCancel)
|
||||
where TView : Control, new()
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public static class Dialog
|
||||
DataContext = vm,
|
||||
Buttons = buttons,
|
||||
Title = title,
|
||||
Icon = icon,
|
||||
Mode = mode,
|
||||
};
|
||||
if (owner is null)
|
||||
{
|
||||
@@ -85,12 +85,12 @@ public static class Dialog
|
||||
public static async Task<DialogResult> ShowModalAsync<TView, TViewModel>(
|
||||
TViewModel vm,
|
||||
string? title = null,
|
||||
DialogIcon icon = DialogIcon.None,
|
||||
DialogMode mode = DialogMode.None,
|
||||
DialogButton buttons = DialogButton.OKCancel)
|
||||
where TView: Control, new()
|
||||
{
|
||||
var mainWindow = GetMainWindow();
|
||||
return await ShowModalAsync<TView, TViewModel>(mainWindow, vm, title, icon, buttons);
|
||||
return await ShowModalAsync<TView, TViewModel>(mainWindow, vm, title, mode, buttons);
|
||||
}
|
||||
|
||||
private static Window? GetMainWindow()
|
||||
@@ -106,7 +106,7 @@ public static class OverlayDialog
|
||||
TViewModel vm,
|
||||
string? hostId = null,
|
||||
string? title = null,
|
||||
DialogIcon icon = DialogIcon.None,
|
||||
DialogMode mode = DialogMode.None,
|
||||
DialogButton buttons = DialogButton.OKCancel)
|
||||
where TView : Control, new()
|
||||
{
|
||||
@@ -116,7 +116,7 @@ public static class OverlayDialog
|
||||
DataContext = vm,
|
||||
Buttons = buttons,
|
||||
Title = title,
|
||||
Icon = icon,
|
||||
Mode = mode,
|
||||
};
|
||||
var host = OverlayDialogManager.GetHost(hostId);
|
||||
host?.AddModalDialog(t);
|
||||
@@ -142,7 +142,7 @@ public static class OverlayDialog
|
||||
TViewModel vm,
|
||||
string? hostId = null,
|
||||
string? title = null,
|
||||
DialogIcon icon = DialogIcon.None,
|
||||
DialogMode mode = DialogMode.None,
|
||||
DialogButton buttons = DialogButton.OKCancel)
|
||||
where TView: Control, new()
|
||||
{
|
||||
@@ -152,7 +152,7 @@ public static class OverlayDialog
|
||||
DataContext = vm,
|
||||
Buttons = buttons,
|
||||
Title = title,
|
||||
Icon = icon,
|
||||
Mode = mode,
|
||||
};
|
||||
var host = OverlayDialogManager.GetHost(hostId);
|
||||
host?.AddDialog(t);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public enum DialogIcon
|
||||
public enum DialogMode
|
||||
{
|
||||
Info,
|
||||
Warning,
|
||||
@@ -63,7 +63,7 @@ public class OverlayDialogHost : Canvas
|
||||
protected override void OnPointerMoved(PointerEventArgs e)
|
||||
{
|
||||
base.OnPointerMoved(e);
|
||||
if (e.Source is DefaultDialogControl item)
|
||||
if (e.Source is DialogControl item)
|
||||
{
|
||||
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public class OverlayDialogHost : Canvas
|
||||
// Handle dialog layer change event
|
||||
private void OnDialogLayerChanged(object sender, DialogLayerChangeEventArgs e)
|
||||
{
|
||||
if (sender is not DefaultDialogControl control)
|
||||
if (sender is not DialogControl control)
|
||||
return;
|
||||
if (!_dialogs.Contains(control))
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user