* UIFormHelper: 默认提示弹窗TopMost为true

This commit is contained in:
Sunny 2023-07-27 15:39:24 +08:00
parent e70907cbc1
commit ae55932c9e

View File

@ -22,6 +22,7 @@
* 2021-06-27: V3.0.4 FeedbackPage可将对象反馈给Frame * 2021-06-27: V3.0.4 FeedbackPage可将对象反馈给Frame
* 2021-12-13: V3.0.9 Form的ShowDialogWithMask() * 2021-12-13: V3.0.9 Form的ShowDialogWithMask()
* 2022-07-17: V3.2.1 ShowNotifier打开多个 * 2022-07-17: V3.2.1 ShowNotifier打开多个
* 2023-07-27: V3.4.1 TopMost为true
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -197,7 +198,7 @@ namespace Sunny.UI
public static bool ShowMessageDialog(this Form form, string message, string title, bool isShowCancel, UIStyle style) public static bool ShowMessageDialog(this Form form, string message, string title, bool isShowCancel, UIStyle style)
{ {
UIMessageForm frm = new UIMessageForm(); UIMessageForm frm = new UIMessageForm();
frm.TopMost = form != null && form.TopMost; frm.TopMost = true;
frm.ShowMessage(message, title, isShowCancel, style); frm.ShowMessage(message, title, isShowCancel, style);
frm.ShowDialog(); frm.ShowDialog();
bool isOk = frm.IsOK; bool isOk = frm.IsOK;
@ -215,7 +216,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
/// <param name="topMost">置顶</param> /// <param name="topMost">置顶</param>
/// <returns>结果</returns> /// <returns>结果</returns>
public static bool ShowMessageDialog(string message, string title, bool showCancelButton, UIStyle style, bool showMask = true, bool topMost = false) public static bool ShowMessageDialog(string message, string title, bool showCancelButton, UIStyle style, bool showMask = true, bool topMost = true)
{ {
Point pt = SystemEx.GetCursorPos(); Point pt = SystemEx.GetCursorPos();
Rectangle screen = Screen.GetBounds(pt); Rectangle screen = Screen.GetBounds(pt);
@ -238,37 +239,37 @@ namespace Sunny.UI
public static class UIMessageBox public static class UIMessageBox
{ {
public static void Show(string text, bool showMask = true, bool topMost = false) public static void Show(string text, bool showMask = true, bool topMost = true)
{ {
Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, topMost); Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, topMost);
} }
public static void ShowInfo(string text, bool showMask = true, bool topMost = false) public static void ShowInfo(string text, bool showMask = true, bool topMost = true)
{ {
Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask, topMost); Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask, topMost);
} }
public static void ShowSuccess(string text, bool showMask = true, bool topMost = false) public static void ShowSuccess(string text, bool showMask = true, bool topMost = true)
{ {
Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, topMost); Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, topMost);
} }
public static void ShowWarning(string text, bool showMask = true, bool topMost = false) public static void ShowWarning(string text, bool showMask = true, bool topMost = true)
{ {
Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, topMost); Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, topMost);
} }
public static void ShowError(string text, bool showMask = true, bool topMost = false) public static void ShowError(string text, bool showMask = true, bool topMost = true)
{ {
Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, topMost); Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, topMost);
} }
public static bool ShowAsk(string text, bool showMask = true, bool topMost = false) public static bool ShowAsk(string text, bool showMask = true, bool topMost = true)
{ {
return Show(text, UILocalize.AskTitle, UIStyle.Blue, UIMessageBoxButtons.OKCancel, showMask, topMost); return Show(text, UILocalize.AskTitle, UIStyle.Blue, UIMessageBoxButtons.OKCancel, showMask, topMost);
} }
public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = true, bool topMost = false) public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = true, bool topMost = true)
{ {
return UIMessageDialog.ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask, topMost); return UIMessageDialog.ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask, topMost);
} }
@ -289,8 +290,7 @@ namespace Sunny.UI
public static class UIInputDialog public static class UIInputDialog
{ {
public static bool InputStringDialog(ref string value, bool checkEmpty = true, public static bool InputStringDialog(ref string value, bool checkEmpty = true, string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool topMost = true, bool showMask = false)
string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -312,26 +312,22 @@ namespace Sunny.UI
return false; return false;
} }
public static bool InputStringDialog(this UIForm form, ref string value, bool checkEmpty = true, public static bool InputStringDialog(this UIForm form, ref string value, bool checkEmpty = true, string desc = "请输入字符串:", bool showMask = false)
string desc = "请输入字符串:", bool showMask = false)
{ {
return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputStringDialog(this UIPage form, ref string value, bool checkEmpty = true, public static bool InputStringDialog(this UIPage form, ref string value, bool checkEmpty = true, string desc = "请输入字符串:", bool showMask = false)
string desc = "请输入字符串:", bool showMask = false)
{ {
return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputStringDialog(this Form form, ref string value, bool checkEmpty = true, public static bool InputStringDialog(this Form form, ref string value, bool checkEmpty = true, string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool showMask = false)
string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool showMask = false)
{ {
return InputStringDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost, showMask); return InputStringDialog(ref value, checkEmpty, desc, style, true, showMask);
} }
public static bool InputPasswordDialog(ref string value, bool checkEmpty = true, public static bool InputPasswordDialog(ref string value, bool checkEmpty = true, string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool topMost = true, bool showMask = false)
string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -353,26 +349,22 @@ namespace Sunny.UI
return false; return false;
} }
public static bool InputPasswordDialog(this UIForm form, ref string value, bool checkEmpty = true, public static bool InputPasswordDialog(this UIForm form, ref string value, bool checkEmpty = true, string desc = "请输入密码:", bool showMask = false)
string desc = "请输入密码:", bool showMask = false)
{ {
return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputPasswordDialog(this UIPage form, ref string value, bool checkEmpty = true, public static bool InputPasswordDialog(this UIPage form, ref string value, bool checkEmpty = true, string desc = "请输入密码:", bool showMask = false)
string desc = "请输入密码:", bool showMask = false)
{ {
return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputPasswordDialog(this Form form, ref string value, bool checkEmpty = true, public static bool InputPasswordDialog(this Form form, ref string value, bool checkEmpty = true, string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool showMask = false)
string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool showMask = false)
{ {
return InputPasswordDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost, showMask); return InputPasswordDialog(ref value, checkEmpty, desc, style, true, showMask);
} }
public static bool InputIntegerDialog(ref int value, bool checkEmpty = true, public static bool InputIntegerDialog(ref int value, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = true, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -395,8 +387,7 @@ namespace Sunny.UI
return false; return false;
} }
public static bool InputIntegerDialog(ref int value, int minimum, int maximum, bool checkEmpty = true, public static bool InputIntegerDialog(ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = true, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -422,44 +413,37 @@ namespace Sunny.UI
return false; return false;
} }
public static bool InputIntegerDialog(this UIForm form, ref int value, bool checkEmpty = true, public static bool InputIntegerDialog(this UIForm form, ref int value, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputIntegerDialog(this UIPage form, ref int value, bool checkEmpty = true, public static bool InputIntegerDialog(this UIPage form, ref int value, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputIntegerDialog(this Form form, ref int value, bool checkEmpty = true, public static bool InputIntegerDialog(this Form form, ref int value, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{ {
return InputIntegerDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost, showMask); return InputIntegerDialog(ref value, checkEmpty, desc, style, true, showMask);
} }
public static bool InputIntegerDialog(this UIForm form, ref int value, int minimum, int maximum, bool checkEmpty = true, public static bool InputIntegerDialog(this UIForm form, ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputIntegerDialog(this UIPage form, ref int value, int minimum, int maximum, bool checkEmpty = true, public static bool InputIntegerDialog(this UIPage form, ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputIntegerDialog(this Form form, ref int value, int minimum, int maximum, bool checkEmpty = true, public static bool InputIntegerDialog(this Form form, ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{ {
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, style, form != null && form.TopMost, showMask); return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, style, true, showMask);
} }
public static bool InputDoubleDialog(ref double value, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = true, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -483,8 +467,7 @@ namespace Sunny.UI
return false; return false;
} }
public static bool InputDoubleDialog(ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = true, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -510,46 +493,40 @@ namespace Sunny.UI
return false; return false;
} }
public static bool InputDoubleDialog(this UIForm form, ref double value, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(this UIForm form, ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputDoubleDialog(this UIPage form, ref double value, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(this UIPage form, ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputDoubleDialog(this Form form, ref double value, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(this Form form, ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{ {
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, style, form != null && form.TopMost, showMask); return InputDoubleDialog(ref value, decimals, checkEmpty, desc, style, true, showMask);
} }
public static bool InputDoubleDialog(this UIForm form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(this UIForm form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputDoubleDialog(this UIPage form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(this UIPage form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", bool showMask = false)
string desc = "请输入数字:", bool showMask = false)
{ {
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask); return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, true, showMask);
} }
public static bool InputDoubleDialog(this Form form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, public static bool InputDoubleDialog(this Form form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{ {
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, style, form != null && form.TopMost, showMask); return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, style, true, showMask);
} }
} }
public static class UISelectDialog public static class UISelectDialog
{ {
public static bool ShowSelectDialog(this Form form, ref int selectIndex, IList items, string title, string description, UIStyle style = UIStyle.Blue, bool topMost = false) public static bool ShowSelectDialog(this Form form, ref int selectIndex, IList items, string title, string description, UIStyle style = UIStyle.Blue, bool topMost = true)
{ {
UISelectForm frm = new UISelectForm(); UISelectForm frm = new UISelectForm();
frm.TopMost = topMost; frm.TopMost = topMost;
@ -572,7 +549,7 @@ namespace Sunny.UI
public static bool ShowSelectDialog(this Form form, ref int selectIndex, IList items, UIStyle style = UIStyle.Blue) public static bool ShowSelectDialog(this Form form, ref int selectIndex, IList items, UIStyle style = UIStyle.Blue)
{ {
return form.ShowSelectDialog(ref selectIndex, items, UILocalize.SelectTitle, "", style, form != null && form.TopMost); return form.ShowSelectDialog(ref selectIndex, items, UILocalize.SelectTitle, "", style, true);
} }
public static bool ShowSelectDialog(this UIForm form, ref int selectIndex, IList items) public static bool ShowSelectDialog(this UIForm form, ref int selectIndex, IList items)
@ -587,12 +564,12 @@ namespace Sunny.UI
public static bool ShowSelectDialog(this UIForm form, ref int selectIndex, IList items, string title, string description) public static bool ShowSelectDialog(this UIForm form, ref int selectIndex, IList items, string title, string description)
{ {
return form.ShowSelectDialog(ref selectIndex, items, title, description, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost); return form.ShowSelectDialog(ref selectIndex, items, title, description, form != null ? form.Style : UIStyle.Blue, true);
} }
public static bool ShowSelectDialog(this UIPage form, ref int selectIndex, IList items, string title, string description) public static bool ShowSelectDialog(this UIPage form, ref int selectIndex, IList items, string title, string description)
{ {
return form.ShowSelectDialog(ref selectIndex, items, title, description, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost); return form.ShowSelectDialog(ref selectIndex, items, title, description, form != null ? form.Style : UIStyle.Blue, true);
} }
} }