zoukankan      html  css  js  c++  java
  • 收集的关于Splash Screen的两篇好文章

    .NET Splash Screen Component (C#, VB.NET)

    This small article is a review of a .NET component that will help you in creating a pretty good splash screen in C# or VB.Net. After having made my own splash screens for several projects and having tried different approaches for the task, I’ve found this very useful component while surfing on the net. Far from being expensive and with a very well designed interface, this component is the right choice for those who don’t want to bother with all the coding themselves.

    Once you import the supplied DLL you also need to import the Splash_Screen_Component namespace and you’re ready to go. One great feature about this component is that it runs on its own thread.

    Here’s an example of how simple it is to use this component

        1Splash.Start();
        2Splash.SetBackgroundImage(Image.FromFile("./SplashBG.png"));
        3
        4Splash.State = "Loading Images";
        5Splash.StateDescription = "Animated GIFs";
        6loadGifs();
        7
        8Splash.StateDescription = "Animated JPGs";
        9loadJpgs();
       10
       11// How to display a progress bar
       12loadUIButtons();
       13
       14Splash.Vanish();
       15
       16private void loadUIButtons() {
       17          int value;
       18
       19          Splash.DisplayProgressBar = true;
       20          Splash.State = "Loading Buttons";
       21
       22           // load 70 buttons
       23           for (int i=0; i<70; i++) {
       24                value = (i/70.00) * 100;
       25                Splash.ProgressBarValue = value;
       26                Splash.StateDescription = "Current Button: " + i;
       27           }
       28
       29          Splash.DisplayProgressBar = false;
       30}

    Ok, that’s it…!

    Website: http://www.splash-screen.com/

    I’ll keep posting reviews about more useful components, feel free to comment and/or suggest other related components.

    转自:http://www.agusblog.com/wordpress/net-splash-screen-component-c-sharp-vb-net-framework-231.htm

    Creating a splash screen

    Introduction:

       Today you will learn create a simple splash screen for your application. In order to follow this tutorial, you will need to have Visual Studio .NET and .NET Framework installed on your computer.

    Getting to work:

       Let's start by creating a new C# Windows Application ( File -> New -> Project -> Visual C# Projects -> Windows Application ). Name the project SplashScreen.

       Let's leave the current form the way it is and add to our project another form. To do this, go to Project menu and click Add Windows Form. Name the class Splash.cs and click OK.

       Visual Studio .NET has created another form for you. Let's work a little on our new form. Let's set it's FormBorderStyle to None its StartPosition to CenterScreen. In the attached archive, I've created a simple image witch we will set as the BackgoundImage for our current form. Resize the form until it displays the full image. Now set the TransparencyKey property of our form to the background color of our image. As you can see, the color is Black. Also, it would be nice that this form would not be displayed in the taskbar. So set the ShowInTaskbar property to false.

       Now go back to Form1 class, created by default by Visual Studio .NET. We must add some code in this class to show the Splash form before initializing Form1.

       Let's go to Form1() method. That method is the constructor of the class and it executes before any other method. Let's add here the following code, right bellow the call to InitializeComponent method:

    Thread th = new Thread(new ThreadStart(DoSplash));
    th.Start();
    Thread.Sleep(3000);
    th.Abort();
    Thread.Sleep(1000);

       Let's see what is done here. Fist, we declare a thread and tell him that when he starts, to execute the DoSplash method. The next line starts the thread. Now the started thread executes in parallel with the main application thread. To prevent the main form from appearing before the thread exits, we put the main thread to sleep for 3 seconds( 3000 milliseconds ).To be sure that the second thread will exit, we’ll leave him an extra 1 second to cleanup. . Let’s take a look at the DoSplash method that our second thread executes:

    Splash sp = new Splash();
    sp.ShowDialog();


       Let's see what is happening here. We declared an instance of our Splash class and displayed it. When we'll call the abort method of the thread, all the variable declared or instantiated in that thread will be disposed.

       Run the application now and see what happens. On my computer, the image is displayed correctly only if I set the color depth of my computer to 16 bits. This is a bug from Microsoft. After a few searches on google, you will find there is a fix for that. So let's fix it.

       Go to the Splash class constructor, and add the following code, after the InitializeComponent method:

    Bitmap b = new Bitmap(this.BackgroundImage);
    b.MakeTransparent(b.GetPixel(1,1));
    this.BackgroundImage = b;
     

       What our code does is get the image we set as BackgroundImage and creates a Bitmap object as a copy of the same image. Next, we call MakeTransparent method of the Bitmap class that gets a color as an argument and makes it transparent. The argument that we pass is the color of the pixel at coordinates 1,1(these coordinates are not the only ones that you can use. You can use as well 0,0 and any other.).

       Here is the splash on my machine.

       That's about it. Until next time, I wish you luck and happy programming.

       Raul POPESCU

    Attachments:

      Project Files: creating_splash_csharp.zip

    转载:http://www.codersource.net/csharp_splash_screen.aspx

  • 相关阅读:
    POJ 2923 Relocation ★(状态压缩+01背包)
    POJ 1062 昂贵的聘礼 (带限制的最短路)
    HDU 4355 Party All the Time (三分求凸函数极值)
    POJ 1860 Currency Exchange (BellmanFord)
    POJ 2923 Relocation ★(状态压缩+01背包)
    【HNOI2011】数学作业(BZOJ 2326)
    POJ 1062 昂贵的聘礼 (带限制的最短路)
    作为当代大学生,面对着信息增长加快,老化周期变短,你应该如何做?
    作为当代大学生,面对着信息增长加快,老化周期变短,你应该如何做?
    信息分析与预测考前模拟试题
  • 原文地址:https://www.cnblogs.com/wuhenke/p/1660326.html
Copyright © 2011-2022 走看看