From ca1ab0cfd3244bc2337626ea5209f2db3d4c3514 Mon Sep 17 00:00:00 2001 From: Sunny Date: Sun, 28 Apr 2024 10:12:33 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIFormHelper:=20=E4=BF=A1=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=AA=97=E4=BD=93=E8=B7=9F=E9=9A=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E6=89=80=E5=9C=A8=E7=9A=84=E5=B1=8F=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Forms/UIFormHelper.cs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs index b2ab8656..06d3d09b 100644 --- a/SunnyUI/Forms/UIFormHelper.cs +++ b/SunnyUI/Forms/UIFormHelper.cs @@ -27,6 +27,7 @@ * 2024-04-22: V3.6.5 重构,所有弹窗调整为窗体的扩展方法,使用时加上this. * 2024-04-22: V3.6.5 输入弹窗前增加Show前缀 * 2024-04-27: V3.6.5 提示框增加延时关闭 + * 2024-04-28: V3.6.5 信息提示窗体跟随程序所在的屏幕 ******************************************************************************/ using System; @@ -82,39 +83,39 @@ namespace Sunny.UI public static class UIMessageBox { - public static void Show(string text, bool showMask = true, bool topMost = true) + public static void Show(string text, bool showMask = true, int delay = 0) { - Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, topMost); + Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, true, delay); } - public static void ShowInfo(string text, bool showMask = true, bool topMost = true) + public static void ShowInfo(string text, bool showMask = true, int delay = 0) { - Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask, topMost); + Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask, true, delay); } - public static void ShowSuccess(string text, bool showMask = true, bool topMost = true) + public static void ShowSuccess(string text, bool showMask = true, int delay = 0) { - Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, topMost); + Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, true, delay); } - public static void ShowWarning(string text, bool showMask = true, bool topMost = true) + public static void ShowWarning(string text, bool showMask = true, int delay = 0) { - Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, topMost); + Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, true, delay); } - public static void ShowError(string text, bool showMask = true, bool topMost = true) + public static void ShowError(string text, bool showMask = true, int delay = 0) { - Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, topMost); + Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, true, delay); } - public static bool ShowAsk(string text, bool showMask = true, bool topMost = true) + public static bool ShowAsk(string text, bool showMask = true, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok) { - return Show(text, UILocalize.AskTitle, UIStyle.Blue, UIMessageBoxButtons.OKCancel, showMask, topMost); + return ShowMessageDialog(text, UILocalize.AskTitle, true, UIStyle.Blue, showMask, true, defaultButton); } - public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = true, bool topMost = true) + public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = true, bool topMost = true, int delay = 0) { - return ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask, topMost); + return ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask, topMost, UIMessageDialogButtons.Ok, delay); } /// @@ -135,7 +136,10 @@ namespace Sunny.UI Rectangle screen = Screen.GetBounds(pt); using UIMessageForm frm = new UIMessageForm(); frm.DefaultButton = showCancelButton ? defaultButton : UIMessageDialogButtons.Ok; - frm.StartPosition = FormStartPosition.CenterScreen; + //frm.StartPosition = FormStartPosition.CenterScreen; + frm.StartPosition = FormStartPosition.Manual; + frm.Left = screen.Left + screen.Width / 2 - frm.Width / 2; + frm.Top = screen.Top + screen.Height / 2 - frm.Height / 2; frm.ShowMessage(message, title, showCancelButton, style); frm.ShowInTaskbar = false; frm.TopMost = topMost;