码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress之SplashScreen用法实例

时间:2017-11-13 23:29:37      阅读:714      评论:0      收藏:0      [点我收藏+]

标签:win   public   fadeout   3.0   提示   窗体显示   excel表格   stat   deb   

本文实例展示了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#程序设计能有所帮助!

除声明外,跑步客文章均为原创,转载请以链接形式标明本文地址
  DevExpress之SplashScreen用法实例

本文地址:  http://www.paobuke.com/develop/c-develop/pbk23635.html






相关内容

DevExpress之SplashScreen用法实例

标签:win   public   fadeout   3.0   提示   窗体显示   excel表格   stat   deb   

原文地址:http://www.cnblogs.com/paobuke/p/7828178.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!