12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using DevExpress.XtraEditors;
- using DevExpress.XtraEditors.Internal;
- using DevExpress.XtraSplashScreen;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Ips.Library.DxpLib
- {
- public static class MsgHelper
- {
- public static Form MainWin { get; set; }
- public static void ShowMsg(string text, string caption = "提示消息")
- {
- XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- public static void ShowWarn(string text, string caption = "警告消息")
- {
- XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- public static void ShowError(string text, Exception ex = null, string caption = "错误消息")
- {
- XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- public static bool ShowConfirm(string text, string caption = "确认消息")
- {
- var msgIco = XtraMessageHelper.MessageBoxIconToIcon(MessageBoxIcon.Question);
- XtraMessageBoxArgs arg = new XtraMessageBoxArgs(null, text, caption, new DialogResult[] { DialogResult.Yes, DialogResult.No }, msgIco, 0);
- arg.Showing += (o, e) => { e.Form.CloseBox = false; };
- var dlgRes = XtraMessageBox.Show(arg);
- return dlgRes == DialogResult.Yes;
- }
- private static IOverlaySplashScreenHandle CurrentOverlay;
- public static void ShowOverlay(Control ctrl = null)
- {
- if (ctrl == null) ctrl = MainWin;
- CurrentOverlay = SplashScreenManager.ShowOverlayForm(ctrl);
- }
- public static void CloseOverlay()
- {
- if (CurrentOverlay != null)
- {
- CurrentOverlay.Close();
- CurrentOverlay = null;
- }
- }
- }
- }
|