feat: add styleClass as an option to Dialogs.
This commit is contained in:
@@ -163,6 +163,7 @@ public partial class DefaultOverlayDialogDemoViewModel : ObservableObject
|
|||||||
CanDragMove = CanDragMove,
|
CanDragMove = CanDragMove,
|
||||||
IsCloseButtonVisible = IsCloseButtonVisible,
|
IsCloseButtonVisible = IsCloseButtonVisible,
|
||||||
CanResize = CanResize,
|
CanResize = CanResize,
|
||||||
|
StyleClass = "Alert",
|
||||||
};
|
};
|
||||||
string? dialogHostId = IsLocal ? DialogDemoViewModel.LocalHost : null;
|
string? dialogHostId = IsLocal ? DialogDemoViewModel.LocalHost : null;
|
||||||
if (IsModal)
|
if (IsModal)
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ public static class Dialog
|
|||||||
else
|
else
|
||||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||||
|
{
|
||||||
|
window.Classes.Add(options.StyleClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -240,5 +244,9 @@ public static class Dialog
|
|||||||
else
|
else
|
||||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||||
|
{
|
||||||
|
window.Classes.Add(options.StyleClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,4 +32,5 @@ public class DialogOptions
|
|||||||
public bool CanDragMove { get; set; } = true;
|
public bool CanDragMove { get; set; } = true;
|
||||||
|
|
||||||
public bool CanResize { get; set; }
|
public bool CanResize { get; set; }
|
||||||
|
public string? StyleClass { get; set; }
|
||||||
}
|
}
|
||||||
@@ -64,4 +64,6 @@ public class OverlayDialogOptions
|
|||||||
public int? TopLevelHashCode { get; set; }
|
public int? TopLevelHashCode { get; set; }
|
||||||
|
|
||||||
public bool CanResize { get; set; }
|
public bool CanResize { get; set; }
|
||||||
|
|
||||||
|
public string? StyleClass { get; set; }
|
||||||
}
|
}
|
||||||
@@ -205,6 +205,10 @@ public static class OverlayDialog
|
|||||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||||
control.CanLightDismiss = options.CanLightDismiss;
|
control.CanLightDismiss = options.CanLightDismiss;
|
||||||
control.CanResize = options.CanResize;
|
control.CanResize = options.CanResize;
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||||
|
{
|
||||||
|
control.Classes.Add(options.StyleClass);
|
||||||
|
}
|
||||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +235,10 @@ public static class OverlayDialog
|
|||||||
control.CanLightDismiss = options.CanLightDismiss;
|
control.CanLightDismiss = options.CanLightDismiss;
|
||||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||||
control.CanResize = options.CanResize;
|
control.CanResize = options.CanResize;
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||||
|
{
|
||||||
|
control.Classes.Add(options.StyleClass);
|
||||||
|
}
|
||||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,11 @@ public static class Drawer
|
|||||||
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
|
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
|
||||||
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
|
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||||
|
{
|
||||||
|
drawer.Classes.Add(options.StyleClass!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureDefaultDrawer(DefaultDrawerControl drawer, DrawerOptions? options)
|
private static void ConfigureDefaultDrawer(DefaultDrawerControl drawer, DrawerOptions? options)
|
||||||
@@ -239,5 +244,9 @@ public static class Drawer
|
|||||||
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
|
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
|
||||||
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
|
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||||
|
{
|
||||||
|
drawer.Classes.Add(options.StyleClass!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,4 +22,6 @@ public class DrawerOptions
|
|||||||
public int? TopLevelHashCode { get; set; }
|
public int? TopLevelHashCode { get; set; }
|
||||||
|
|
||||||
public bool CanResize { get; set; }
|
public bool CanResize { get; set; }
|
||||||
|
|
||||||
|
public string? StyleClass { get; set; }
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,8 @@ public static class MessageBox
|
|||||||
string message,
|
string message,
|
||||||
string? title = null,
|
string? title = null,
|
||||||
MessageBoxIcon icon = MessageBoxIcon.None,
|
MessageBoxIcon icon = MessageBoxIcon.None,
|
||||||
MessageBoxButton button = MessageBoxButton.OK)
|
MessageBoxButton button = MessageBoxButton.OK,
|
||||||
|
string? styleClass = null)
|
||||||
{
|
{
|
||||||
var messageWindow = new MessageBoxWindow(button)
|
var messageWindow = new MessageBoxWindow(button)
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,10 @@ public static class MessageBox
|
|||||||
Title = title,
|
Title = title,
|
||||||
MessageIcon = icon
|
MessageIcon = icon
|
||||||
};
|
};
|
||||||
|
if (!string.IsNullOrWhiteSpace(styleClass))
|
||||||
|
{
|
||||||
|
messageWindow.Classes.Add(styleClass!);
|
||||||
|
}
|
||||||
var lifetime = Application.Current?.ApplicationLifetime;
|
var lifetime = Application.Current?.ApplicationLifetime;
|
||||||
if (lifetime is not IClassicDesktopStyleApplicationLifetime classLifetime) return MessageBoxResult.None;
|
if (lifetime is not IClassicDesktopStyleApplicationLifetime classLifetime) return MessageBoxResult.None;
|
||||||
var main = classLifetime.MainWindow;
|
var main = classLifetime.MainWindow;
|
||||||
@@ -37,7 +42,8 @@ public static class MessageBox
|
|||||||
string message,
|
string message,
|
||||||
string title,
|
string title,
|
||||||
MessageBoxIcon icon = MessageBoxIcon.None,
|
MessageBoxIcon icon = MessageBoxIcon.None,
|
||||||
MessageBoxButton button = MessageBoxButton.OK)
|
MessageBoxButton button = MessageBoxButton.OK,
|
||||||
|
string? styleClass = null)
|
||||||
{
|
{
|
||||||
var messageWindow = new MessageBoxWindow(button)
|
var messageWindow = new MessageBoxWindow(button)
|
||||||
{
|
{
|
||||||
@@ -45,6 +51,10 @@ public static class MessageBox
|
|||||||
Title = title,
|
Title = title,
|
||||||
MessageIcon = icon
|
MessageIcon = icon
|
||||||
};
|
};
|
||||||
|
if (!string.IsNullOrWhiteSpace(styleClass))
|
||||||
|
{
|
||||||
|
messageWindow.Classes.Add(styleClass!);
|
||||||
|
}
|
||||||
var result = await messageWindow.ShowDialog<MessageBoxResult>(owner);
|
var result = await messageWindow.ShowDialog<MessageBoxResult>(owner);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -55,7 +65,8 @@ public static class MessageBox
|
|||||||
string? hostId = null,
|
string? hostId = null,
|
||||||
MessageBoxIcon icon = MessageBoxIcon.None,
|
MessageBoxIcon icon = MessageBoxIcon.None,
|
||||||
MessageBoxButton button = MessageBoxButton.OK,
|
MessageBoxButton button = MessageBoxButton.OK,
|
||||||
int? toplevelHashCode = null)
|
int? toplevelHashCode = null,
|
||||||
|
string? styleClass = null)
|
||||||
{
|
{
|
||||||
var host = OverlayDialogManager.GetHost(hostId, toplevelHashCode);
|
var host = OverlayDialogManager.GetHost(hostId, toplevelHashCode);
|
||||||
if (host is null) return MessageBoxResult.None;
|
if (host is null) return MessageBoxResult.None;
|
||||||
@@ -67,6 +78,10 @@ public static class MessageBox
|
|||||||
MessageIcon = icon,
|
MessageIcon = icon,
|
||||||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle
|
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle
|
||||||
};
|
};
|
||||||
|
if (!string.IsNullOrWhiteSpace(styleClass))
|
||||||
|
{
|
||||||
|
messageControl.Classes.Add(styleClass!);
|
||||||
|
}
|
||||||
host.AddModalDialog(messageControl);
|
host.AddModalDialog(messageControl);
|
||||||
var result = await messageControl.ShowAsync<MessageBoxResult>();
|
var result = await messageControl.ShowAsync<MessageBoxResult>();
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user