namespace Yw.WinFrmUI { /// /// 提示框辅助类 /// public class TipFormHelper { //获取提示窗体 private static TipForm GetTipForm() { if (_tipForm == null || _tipForm.IsDisposed) { lock (_locker) { if (_tipForm == null || _tipForm.IsDisposed) { _tipForm = new TipForm(); } } } return _tipForm; } private static TipForm _tipForm = null; private static object _locker = new();//锁对象 /// /// 显示提示窗体 /// /// 提示状态 /// 提示信息 /// 持续时间(毫秒) public static void Show(eTipStatus status, string caption, int interval = 2000) { var frm = GetTipForm(); frm.Set(status, caption, interval); frm.Show(); } /// /// 显示信息提示窗体 /// /// 提示信息 /// 持续时间(毫秒) public static void ShowInfo(string caption, int interval = 2000) { Show(eTipStatus.Info, caption, interval); } /// /// 显示成功提示窗体 /// /// 提示信息 /// 持续时间(毫秒) public static void ShowSucceed(string caption, int interval = 2000) { Show(eTipStatus.Succeed, caption, interval); } /// /// 显示警告提示窗体 /// /// 提示信息 /// 持续时间(毫秒) public static void ShowWarn(string caption, int interval = 2000) { Show(eTipStatus.Warn, caption, interval); } /// /// 显示错误提示窗体 /// /// 提示信息 /// 持续时间(毫秒) public static void ShowError(string caption, int interval = 2000) { Show(eTipStatus.Error, caption, interval); } } }