当前位置: 编程技术>.net/c#/asp.net
DevExpress之SplashScreen用法实例
来源: 互联网 发布时间:2014-11-02
本文导语: 本文实例展示了DevExpress中SplashScreen的用法,对于C#初学者来说有一定的参考借鉴价值,具体用法如下: 关键代码部分如下: using DevExpress.XtraSplashScreen; using System; namespace DevExpressUtilHelpV3 { /// /// 基于.NET 3.0的 SplashScreen...
本文实例展示了DevExpress中SplashScreen的用法,对于C#初学者来说有一定的参考借鉴价值,具体用法如下:
关键代码部分如下:
using DevExpress.XtraSplashScreen; using System; namespace DevExpressUtilHelpV3 { /// /// 基于.NET 3.0的 SplashScreen工具类 /// public static class SplashScreenToolV3 { private const bool FadeIn = false; private const bool FadeOut = true; private const bool ThrowExceptionIfIsAlreadyShown = false; private const bool ThrowExceptionIfIsAlreadyClosed = false; /// /// ShowSplashScreen /// /// WaitForm public static void ShowSplashScreen(Type type) { CloseSplashScreen(); SplashScreenManager.ShowForm(null, type, FadeIn, FadeOut, ThrowExceptionIfIsAlreadyShown); } /// /// CloseSplashScreen /// public static void CloseSplashScreen() { if (SplashScreenManager.Default != null) { //Thread _task = new Thread(() => //{ SplashScreenManager.CloseForm(ThrowExceptionIfIsAlreadyClosed); //}); //_task.Start(); } } /// /// SetCaption /// /// 需要设置的Title public static void SetCaption(string caption) { if (SplashScreenManager.Default != null && !string.IsNullOrEmpty(caption)) { SplashScreenManager.Default.SetWaitFormCaption(caption); } } /// /// SetDescription /// /// 需要设置的文字提示信息 public static void SetDescription(string description) { if (SplashScreenManager.Default != null && !string.IsNullOrEmpty(description)) { SplashScreenManager.Default.SetWaitFormDescription(description); } } } }
测试代码如下:
try { SplashScreenToolV3.ShowSplashScreen(typeof(WaitForm1)); Thread.Sleep(5000); throw new Exception("ccccccccc"); ////Thread.Sleep(5000); //SplashScreenToolV3.SetCaption("正在开始下载...."); ////SplashScreenController.ShowSplashScreen(); //Thread _task1 = new Thread(() => //{ // for (int i = 0; i < 100; i++) // { // SplashScreenToolV3.SetDescription(i.ToString() + "%"); // Thread.Sleep(1000); // } //}); //Thread _task2 = new Thread(() => //{ // for (int i = 0; i < 100; i++) // { // SplashScreenToolV3.SetCaption("测试.." + i); // Thread.Sleep(500); // } //}); //_task1.Start(); //_task2.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { // SplashScreenController.HideSplashScreen(); }
测试效果如下图所示:
希望本文所述方法对打击的C#程序设计能有所帮助!