DevExpress 의 SplashScreen 사용법 실례

3533 단어 DevExpress
본 고 는 DevExpress 에서 Splash Screen 의 용법 을 보 여 주 었 는데 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\#프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다!

좋은 웹페이지 즐겨찾기