using DevExpress.XtraSplashScreen; namespace IStation.Win { public static class WaitHelper { private const string _caption = "努力加载中..."; /// ///显示等待窗体 /// public static void ShowWaitForm() { HideWaitForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(null, typeof(WaitFormStyle1), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(_caption); } /// /// 显示等待窗体 /// /// 父窗体 public static void ShowWaitForm(Form form, bool isLocked = false) { HideWaitForm(); if (isLocked) DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(form, typeof(WaitFormStyle1), true, true, false, ParentFormState.Locked); else DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(form, typeof(WaitFormStyle1), true, true, false, ParentFormState.Unlocked); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(_caption); } /// /// 显示等待窗体 /// /// 提示信息 public static void ShowWaitForm(string caption) { HideWaitForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(null, typeof(WaitFormStyle1), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(caption); } /// /// 显示等待窗体 /// /// 父窗体 /// 提示信息 public static void ShowWaitForm(Form form, string caption) { HideWaitForm(); DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(form, typeof(WaitFormStyle1), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(caption); } /// /// 用户控件调用显示等待窗体 /// /// /// 是否锁定 public static void ShowWaitForm(UserControl userCtrl, bool isLocked = false) { HideWaitForm(); if (isLocked) DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(userCtrl, typeof(WaitFormStyle1), true, true, ParentFormState.Locked); else DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(userCtrl, typeof(WaitFormStyle1), true, true); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(_caption); } /// ///用户控件调用显示等待窗体 /// /// 用户控件 /// 提示信息 /// 是否锁定 public static void ShowWaitForm(UserControl userCtrl, string caption, bool isLocked = false) { HideWaitForm(); if (isLocked) DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(userCtrl, typeof(WaitFormStyle1), true, true, ParentFormState.Locked); else DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(userCtrl, typeof(WaitFormStyle1), true, true); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(caption); } /// /// 用户控件调用显示等待窗体 /// /// 用户控件 /// 显示位置 /// 是否锁定 /// 提示信息 public static void ShowWaitForm(UserControl userCtrl, Point pt, bool isLocked = false, string caption = null) { HideWaitForm(); if (isLocked) DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(userCtrl, typeof(WaitFormStyle1), true, true, SplashFormStartPosition.Manual, pt, ParentFormState.Locked); else DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(userCtrl, typeof(WaitFormStyle1), true, true, SplashFormStartPosition.Manual, pt, ParentFormState.Unlocked); if (caption == null) DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(_caption); else DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption(caption); } /// /// 设置等待提示 /// /// public static void SetWaitCaption(string Caption) { var form = DevExpress.XtraSplashScreen.SplashScreenManager.Default; if (form == null) return; form.SetWaitFormCaption(Caption); } /// /// 关闭等待窗体 /// public static void HideWaitForm() { DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); } /// /// 锁定控件的前提下必须调用此方法 /// /// public static void HideWaitForm(Control ctrl) { ctrl.Invoke(new MethodInvoker(() => { DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); })); } } }