Splash Screen Example
I only want a simple Splash Screen Example.
Get the Code, Insert my picture, add 2 lines of code to load and finish.
But all I can google is so complex, that is too much. I only want a form with a picture that goes more and more transparent until it hides automaticly and my window is shown.
I tried the "prettygoodsplash开发者_高级运维screen" from Codeproject, but don't work for me.
Lang is c#.net 2.0
Creating the splash screen can be as simple or complex as you make/want it to be.
private void Form1_Load(object sender, System.EventArgs e)
{
// Display the splash screen
var splashScreen = new SplashForm();
splashScreen.Show()
// On the splash screen now go and show loading messages
splashScreen.lblStatus.Text = "Loading Clients...";
splashScreen.lblStatus.Refresh();
// Do the specific loading here for the status set above
var clientList = _repository.LoadClients();
// Continue doing this above until you're done
// Close the splash screen
splashScreen.Close()
}
Obviously the Splash Screen itself is something that you'd have to decide how you want it to look...
In order for your splash screen to be areal splash screen, it shouldn't have other code than displaying about what it's doing (loading clients, for instance) or show the progress of application startup through a ProgressBar control.
Here are the steps:
- Instantiate a BackgroundWorker for which you will launch the loading within the BackgroundWorker.DoWork() method;
- Within your main Form_Load() event, call BackgroundWorker.RunWorkerAsync() method;
- Still in your Form_Load() event, after your call to RunWorkerAsync(), instantiate and display your splash screen to your user SplashForm.ShowDialog()
- Report progress from within your LoadClient() method, for instance, with the BackgroundWorker.ProgressChanged() event (you may also report what it is your BackgroundWorker is doing ("loading clients...");
- In your RunWorkerCompleted() event, you may Splash.Close() your splash screen form.
I shall add some further details later on. Have to go now.
精彩评论