DeviceManager/TsSFCDevice.Control/XtraMessageBoxHelper.cs

64 lines
2.7 KiB
C#
Raw Permalink Normal View History

2024-07-01 16:52:48 +00:00
using DevExpress.XtraEditors;
using System.Windows.Forms;
namespace TsSFCDevice.Control
{
/// <summary>
/// Xtra消息弹框处理
/// </summary>
public static class XtraMessageBoxHelper
{
public static DialogResult Ask(string text, string caption = "询问", bool allowHtmlText = true, System.Action act = null)
{
act?.Invoke();
if (!text.Contains("<size/>"))
{
text = $"<size=16>{text}<size/>";
}
return XtraMessageBox.Show(text, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, allowHtmlText: allowHtmlText ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False);
}
public static DialogResult AskYesNo(string text, string caption = "询问", bool allowHtmlText = true, System.Action act = null)
{
act?.Invoke();
if (!text.Contains("<size/>"))
{
text = $"<size=16>{text}<size/>";
}
return XtraMessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, allowHtmlText: allowHtmlText ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False);
}
public static DialogResult Info(string text, string caption = "信息", bool allowHtmlText = true, System.Action act = null)
{
act?.Invoke();
if (!text.Contains("<size/>"))
{
text = $"<size=16>{text}<size/>";
}
return XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information, allowHtmlText: allowHtmlText ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False);
}
public static DialogResult Error(string text, string caption = "错误", bool allowHtmlText = true, System.Action act = null)
{
act?.Invoke();
if (!text.Contains("<size/>"))
{
text = $"<size=16>{text}<size/>";
}
return XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error, allowHtmlText: allowHtmlText ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False);
}
public static DialogResult Warn(string text, string caption = "警告", bool allowHtmlText = true, System.Action act = null)
{
act?.Invoke();
if (!text.Contains("<size/>"))
{
text = $"<size=16>{text}<size/>";
}
return XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning, allowHtmlText: allowHtmlText ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False);
}
}
}