DeviceManager/DeviceRepairAndOptimization/Common/XtraMessageBoxHelper.cs
2024-05-28 22:36:38 +08:00

64 lines
2.7 KiB
C#

using DevExpress.XtraEditors;
using System.Windows.Forms;
namespace DeviceRepairAndOptimization.Common
{
/// <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);
}
}
}