Merge pull request #465 from irihitech/issue-422
New Dialog/Drawer/MessageBox option: StyleClass
This commit is contained in:
@@ -214,6 +214,11 @@ public static class Dialog
|
||||
else
|
||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||
{
|
||||
var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
window.Classes.AddRange(styles);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,5 +245,10 @@ public static class Dialog
|
||||
else
|
||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||
{
|
||||
var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
window.Classes.AddRange(styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,5 @@ public class DialogOptions
|
||||
public bool CanDragMove { get; set; } = true;
|
||||
|
||||
public bool CanResize { get; set; }
|
||||
public string? StyleClass { get; set; }
|
||||
}
|
||||
@@ -64,4 +64,6 @@ public class OverlayDialogOptions
|
||||
public int? TopLevelHashCode { get; set; }
|
||||
|
||||
public bool CanResize { get; set; }
|
||||
|
||||
public string? StyleClass { get; set; }
|
||||
}
|
||||
@@ -205,6 +205,11 @@ public static class OverlayDialog
|
||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||
control.CanLightDismiss = options.CanLightDismiss;
|
||||
control.CanResize = options.CanResize;
|
||||
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||
{
|
||||
var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
control.Classes.AddRange(styles);
|
||||
}
|
||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||
}
|
||||
|
||||
@@ -231,6 +236,11 @@ public static class OverlayDialog
|
||||
control.CanLightDismiss = options.CanLightDismiss;
|
||||
control.IsCloseButtonVisible = options.IsCloseButtonVisible;
|
||||
control.CanResize = options.CanResize;
|
||||
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||
{
|
||||
var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
control.Classes.AddRange(styles);
|
||||
}
|
||||
DialogControlBase.SetCanDragMove(control, options.CanDragMove);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +217,12 @@ public static class Drawer
|
||||
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
|
||||
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||
{
|
||||
var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
drawer.Classes.AddRange(styles);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigureDefaultDrawer(DefaultDrawerControl drawer, DrawerOptions? options)
|
||||
@@ -239,5 +245,10 @@ public static class Drawer
|
||||
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
|
||||
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(options.StyleClass))
|
||||
{
|
||||
var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
drawer.Classes.AddRange(styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,6 @@ public class DrawerOptions
|
||||
public int? TopLevelHashCode { get; set; }
|
||||
|
||||
public bool CanResize { get; set; }
|
||||
|
||||
public string? StyleClass { get; set; }
|
||||
}
|
||||
@@ -11,7 +11,8 @@ public static class MessageBox
|
||||
string message,
|
||||
string? title = null,
|
||||
MessageBoxIcon icon = MessageBoxIcon.None,
|
||||
MessageBoxButton button = MessageBoxButton.OK)
|
||||
MessageBoxButton button = MessageBoxButton.OK,
|
||||
string? styleClass = null)
|
||||
{
|
||||
var messageWindow = new MessageBoxWindow(button)
|
||||
{
|
||||
@@ -19,6 +20,11 @@ public static class MessageBox
|
||||
Title = title,
|
||||
MessageIcon = icon
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(styleClass))
|
||||
{
|
||||
var styles = styleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
messageWindow.Classes.AddRange(styles);
|
||||
}
|
||||
var lifetime = Application.Current?.ApplicationLifetime;
|
||||
if (lifetime is not IClassicDesktopStyleApplicationLifetime classLifetime) return MessageBoxResult.None;
|
||||
var main = classLifetime.MainWindow;
|
||||
@@ -37,7 +43,8 @@ public static class MessageBox
|
||||
string message,
|
||||
string title,
|
||||
MessageBoxIcon icon = MessageBoxIcon.None,
|
||||
MessageBoxButton button = MessageBoxButton.OK)
|
||||
MessageBoxButton button = MessageBoxButton.OK,
|
||||
string? styleClass = null)
|
||||
{
|
||||
var messageWindow = new MessageBoxWindow(button)
|
||||
{
|
||||
@@ -45,6 +52,11 @@ public static class MessageBox
|
||||
Title = title,
|
||||
MessageIcon = icon
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(styleClass))
|
||||
{
|
||||
var styles = styleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
messageWindow.Classes.AddRange(styles!);
|
||||
}
|
||||
var result = await messageWindow.ShowDialog<MessageBoxResult>(owner);
|
||||
return result;
|
||||
}
|
||||
@@ -55,7 +67,8 @@ public static class MessageBox
|
||||
string? hostId = null,
|
||||
MessageBoxIcon icon = MessageBoxIcon.None,
|
||||
MessageBoxButton button = MessageBoxButton.OK,
|
||||
int? toplevelHashCode = null)
|
||||
int? toplevelHashCode = null,
|
||||
string? styleClass = null)
|
||||
{
|
||||
var host = OverlayDialogManager.GetHost(hostId, toplevelHashCode);
|
||||
if (host is null) return MessageBoxResult.None;
|
||||
@@ -67,6 +80,11 @@ public static class MessageBox
|
||||
MessageIcon = icon,
|
||||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(styleClass))
|
||||
{
|
||||
var styles = styleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
messageControl.Classes.AddRange(styles!);
|
||||
}
|
||||
host.AddModalDialog(messageControl);
|
||||
var result = await messageControl.ShowAsync<MessageBoxResult>();
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -10,6 +11,7 @@ internal static class OverlayDialogManager
|
||||
|
||||
public static void RegisterHost(OverlayDialogHost host, string? id, int? hash)
|
||||
{
|
||||
Debug.WriteLine("Count: "+Hosts.Count);
|
||||
Hosts.TryAdd(new HostKey(id, hash), host);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user