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