DevExpress之SplashScreen用法實例。本站提示廣大學習愛好者:(DevExpress之SplashScreen用法實例)文章只能為提供參考,不一定能成為您想要的結果。以下是DevExpress之SplashScreen用法實例正文
本文實例展現了DevExpress中SplashScreen的用法,關於C#初學者來講有必定的參考自創價值,詳細用法以下:
症結代碼部門以下:
using DevExpress.XtraSplashScreen; using System; namespace DevExpressUtilHelpV3 { /// <summary> /// 基於.NET 3.0的 SplashScreen對象類 /// </summary> public static class SplashScreenToolV3 { private const bool FadeIn = false; private const bool FadeOut = true; private const bool ThrowExceptionIfIsAlreadyShown = false; private const bool ThrowExceptionIfIsAlreadyClosed = false; /// <summary> /// ShowSplashScreen /// </summary> /// <param name="type">WaitForm</param> public static void ShowSplashScreen(Type type) { CloseSplashScreen(); SplashScreenManager.ShowForm(null, type, FadeIn, FadeOut, ThrowExceptionIfIsAlreadyShown); } /// <summary> /// CloseSplashScreen /// </summary> public static void CloseSplashScreen() { if (SplashScreenManager.Default != null) { //Thread _task = new Thread(() => //{ SplashScreenManager.CloseForm(ThrowExceptionIfIsAlreadyClosed); //}); //_task.Start(); } } /// <summary> /// SetCaption /// </summary> /// <param name="caption">須要設置的Title</param> public static void SetCaption(string caption) { if (SplashScreenManager.Default != null && !string.IsNullOrEmpty(caption)) { SplashScreenManager.Default.SetWaitFormCaption(caption); } } /// <summary> /// SetDescription /// </summary> /// <param name="description">須要設置的文字提醒信息</param> 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#法式設計能有所贊助!