* UIMessageDialog,UIMessageBox:增加TopMost参数

This commit is contained in:
Sunny 2021-05-08 22:23:45 +08:00
parent bdd5f5f8b3
commit fe50105cba
10 changed files with 46 additions and 37 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -168,7 +168,7 @@ namespace Sunny.UI
{
UISwitch edit = new UISwitch();
edit.SwitchShape = UISwitch.UISwitchShape.Square;
edit.Left = option.LabelWidth;
edit.Left = option.LabelWidth - 1;
edit.Width = 75;
edit.Height = 29;
edit.Top = top;

View File

@ -23,6 +23,7 @@
* 2020-09-17: V2.2.7 WindowState相关代码
* 2020-09-17: V2.2.7 ShowDragStretch属性
* 2021-02-04: V3.0.1
* 2021-05-06: V3.0.3
******************************************************************************/
using System;
@ -1555,7 +1556,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowSuccessDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask, TopMost);
}
/// <summary>
@ -1565,7 +1566,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowInfoDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask, TopMost);
}
/// <summary>
@ -1575,7 +1576,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowWarningDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask, TopMost);
}
/// <summary>
@ -1585,7 +1586,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowErrorDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask, TopMost);
}
/// <summary>
@ -1596,7 +1597,7 @@ namespace Sunny.UI
/// <returns>结果</returns>
public bool ShowAskDialog(string msg, bool showMask = true)
{
return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask);
return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask, TopMost);
}
/// <summary>
@ -1608,7 +1609,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowSuccessDialog(string title, string msg, UIStyle style = UIStyle.Green, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, TopMost);
}
/// <summary>
@ -1620,7 +1621,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowInfoDialog(string title, string msg, UIStyle style = UIStyle.Gray, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, TopMost);
}
/// <summary>
@ -1632,7 +1633,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowWarningDialog(string title, string msg, UIStyle style = UIStyle.Orange, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, TopMost);
}
/// <summary>
@ -1644,7 +1645,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowErrorDialog(string title, string msg, UIStyle style = UIStyle.Red, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, TopMost);
}
/// <summary>
@ -1657,7 +1658,7 @@ namespace Sunny.UI
/// <returns>结果</returns>
public bool ShowAskDialog(string title, string msg, UIStyle style = UIStyle.Blue, bool showMask = true)
{
return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask);
return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask, TopMost);
}
/// <summary>

View File

@ -165,8 +165,9 @@ namespace Sunny.UI
/// <param name="showCancelButton">显示取消按钮</param>
/// <param name="style">主题</param>
/// <param name="showMask">显示遮罩层</param>
/// <param name="topMost">置顶</param>
/// <returns>结果</returns>
public static bool ShowMessageDialog(string message, string title, bool showCancelButton, UIStyle style, bool showMask = true)
public static bool ShowMessageDialog(string message, string title, bool showCancelButton, UIStyle style, bool showMask = true, bool topMost = false)
{
Point pt = SystemEx.GetCursorPos();
Rectangle screen = Screen.GetBounds(pt);
@ -190,7 +191,7 @@ namespace Sunny.UI
frm.StartPosition = FormStartPosition.CenterScreen;
frm.ShowMessage(message, title, showCancelButton, style);
frm.ShowInTaskbar = false;
frm.TopMost = showMask;
frm.TopMost = showMask || topMost;
frm.ShowDialog();
bool isOk = frm.IsOK;
frm.Dispose();
@ -202,39 +203,39 @@ namespace Sunny.UI
public static class UIMessageBox
{
public static void Show(string text, bool showMask = true)
public static void Show(string text, bool showMask = true, bool topMost = false)
{
Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask);
Show(text, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, topMost);
}
public static void ShowInfo(string text, bool showMask = true)
public static void ShowInfo(string text, bool showMask = true, bool topMost = false)
{
Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask);
Show(text, UILocalize.InfoTitle, UIStyle.Gray, UIMessageBoxButtons.OK, showMask, topMost);
}
public static void ShowSuccess(string text, bool showMask = true)
public static void ShowSuccess(string text, bool showMask = true, bool topMost = false)
{
Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask);
Show(text, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, topMost);
}
public static void ShowWarning(string text, bool showMask = true)
public static void ShowWarning(string text, bool showMask = true, bool topMost = false)
{
Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask);
Show(text, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, topMost);
}
public static void ShowError(string text, bool showMask = true)
public static void ShowError(string text, bool showMask = true, bool topMost = false)
{
Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask);
Show(text, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, topMost);
}
public static bool ShowAsk(string text, bool showMask = true)
public static bool ShowAsk(string text, bool showMask = true, bool topMost = false)
{
return Show(text, UILocalize.AskTitle, UIStyle.Blue, UIMessageBoxButtons.OKCancel, showMask);
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)
public static bool Show(string text, string caption, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = true, bool topMost = false)
{
return UIMessageDialog.ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask);
return UIMessageDialog.ShowMessageDialog(text, caption, buttons == UIMessageBoxButtons.OKCancel, style, showMask, topMost);
}
}
@ -612,5 +613,7 @@ namespace Sunny.UI
UIPage AddPage(UIPage page);
void SelectPage(int pageIndex);
bool GetTopMost();
}
}

View File

@ -129,6 +129,11 @@ namespace Sunny.UI
MainTabControl.SelectPage(pageIndex);
}
public bool GetTopMost()
{
return TopMost;
}
#endregion IFrame实现
}
}

View File

@ -368,7 +368,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowSuccessDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.SuccessTitle, false, UIStyle.Green, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -378,7 +378,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowInfoDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.InfoTitle, false, UIStyle.Gray, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -388,7 +388,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowWarningDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.WarningTitle, false, UIStyle.Orange, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -398,7 +398,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowErrorDialog(string msg, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask);
UIMessageDialog.ShowMessageDialog(msg, UILocalize.ErrorTitle, false, UIStyle.Red, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -409,7 +409,7 @@ namespace Sunny.UI
/// <returns>结果</returns>
public bool ShowAskDialog(string msg, bool showMask = true)
{
return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask);
return UIMessageDialog.ShowMessageDialog(msg, UILocalize.AskTitle, true, UIStyle.Blue, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -421,7 +421,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowSuccessDialog(string title, string msg, UIStyle style = UIStyle.Green, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -433,7 +433,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowInfoDialog(string title, string msg, UIStyle style = UIStyle.Gray, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -445,7 +445,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowWarningDialog(string title, string msg, UIStyle style = UIStyle.Orange, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -457,7 +457,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param>
public void ShowErrorDialog(string title, string msg, UIStyle style = UIStyle.Red, bool showMask = true)
{
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask);
UIMessageDialog.ShowMessageDialog(msg, title, false, style, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>
@ -470,7 +470,7 @@ namespace Sunny.UI
/// <returns>结果</returns>
public bool ShowAskDialog(string title, string msg, UIStyle style = UIStyle.Blue, bool showMask = true)
{
return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask);
return UIMessageDialog.ShowMessageDialog(msg, title, true, style, showMask, Frame?.GetTopMost() ?? false);
}
/// <summary>