feat: fix MessageBox default position, use internal option default instance.
This commit is contained in:
@@ -217,10 +217,7 @@ public static class Dialog
|
|||||||
/// <param name="options"></param>
|
/// <param name="options"></param>
|
||||||
private static void ConfigureDefaultDialogWindow(DefaultDialogWindow window, DialogOptions? options)
|
private static void ConfigureDefaultDialogWindow(DefaultDialogWindow window, DialogOptions? options)
|
||||||
{
|
{
|
||||||
if (options is null)
|
options ??= DialogOptions.Default;
|
||||||
{
|
|
||||||
options = new DialogOptions();
|
|
||||||
}
|
|
||||||
window.WindowStartupLocation = options.StartupLocation;
|
window.WindowStartupLocation = options.StartupLocation;
|
||||||
window.Title = options.Title;
|
window.Title = options.Title;
|
||||||
window.Buttons = options.Button;
|
window.Buttons = options.Button;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class DialogControl: ContentControl
|
|||||||
protected internal Button? _closeButton;
|
protected internal Button? _closeButton;
|
||||||
private Panel? _titleArea;
|
private Panel? _titleArea;
|
||||||
|
|
||||||
internal HorizontalPosition HorizontalAnchor { get; set; }
|
internal HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||||
internal VerticalPosition VerticalAnchor { get; set; }
|
internal VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||||
internal HorizontalPosition ActualHorizontalAnchor { get; set; }
|
internal HorizontalPosition ActualHorizontalAnchor { get; set; }
|
||||||
internal VerticalPosition ActualVerticalAnchor { get; set; }
|
internal VerticalPosition ActualVerticalAnchor { get; set; }
|
||||||
internal double? HorizontalOffset { get; set; }
|
internal double? HorizontalOffset { get; set; }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Ursa.Controls;
|
|||||||
|
|
||||||
public class DialogOptions
|
public class DialogOptions
|
||||||
{
|
{
|
||||||
public static DialogOptions Default { get; } = new DialogOptions();
|
internal static DialogOptions Default { get; } = new DialogOptions();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Startup Location of DialogWindow. Default is <see cref="WindowStartupLocation.CenterOwner"/>
|
/// The Startup Location of DialogWindow. Default is <see cref="WindowStartupLocation.CenterOwner"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public enum VerticalPosition
|
|||||||
|
|
||||||
public class OverlayDialogOptions
|
public class OverlayDialogOptions
|
||||||
{
|
{
|
||||||
|
internal static OverlayDialogOptions Default { get; } = new OverlayDialogOptions();
|
||||||
public bool CanClickOnMaskToClose { get; set; } = false;
|
public bool CanClickOnMaskToClose { get; set; } = false;
|
||||||
public HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
public HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||||
public VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
public VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public static class OverlayDialog
|
|||||||
|
|
||||||
private static void ConfigureDialogControl(DialogControl control, OverlayDialogOptions? options)
|
private static void ConfigureDialogControl(DialogControl control, OverlayDialogOptions? options)
|
||||||
{
|
{
|
||||||
if (options is null) options = new OverlayDialogOptions();
|
options ??= OverlayDialogOptions.Default;
|
||||||
control.HorizontalAnchor = options.HorizontalAnchor;
|
control.HorizontalAnchor = options.HorizontalAnchor;
|
||||||
control.VerticalAnchor = options.VerticalAnchor;
|
control.VerticalAnchor = options.VerticalAnchor;
|
||||||
control.ActualHorizontalAnchor = options.HorizontalAnchor;
|
control.ActualHorizontalAnchor = options.HorizontalAnchor;
|
||||||
|
|||||||
@@ -132,4 +132,17 @@ public class MessageBoxControl: DialogControl
|
|||||||
{
|
{
|
||||||
if (button is not null) button.IsVisible = visible;
|
if (button is not null) button.IsVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal override void CloseDialog()
|
||||||
|
{
|
||||||
|
MessageBoxResult result = Buttons switch
|
||||||
|
{
|
||||||
|
MessageBoxButton.OK => MessageBoxResult.OK,
|
||||||
|
MessageBoxButton.OKCancel => MessageBoxResult.Cancel,
|
||||||
|
MessageBoxButton.YesNo => MessageBoxResult.No,
|
||||||
|
MessageBoxButton.YesNoCancel => MessageBoxResult.Cancel,
|
||||||
|
_ => MessageBoxResult.None
|
||||||
|
};
|
||||||
|
OnDialogControlClosing(this, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user