Shuxia Ning
2024-07-17 fd681339c81201ed6fb3303647ecab89e3e6c0c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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);
                }));
        }
 
 
 
 
    }
 
}