The Splash Screen sample demonstrates how to achieve splash screen effect in Windows Forms application.
1. The Splash Screen fades in and then fades out.
2. The main form shows out.
private void ExtraFormSettings() { this.FormBorderStyle = FormBorderStyle.None; this.Opacity = 0.5; this.BackgroundImage = CSWinFormSplashScreen.Properties.Resources.SplashImage; }
private void ExtraFormSettings() { this.FormBorderStyle = FormBorderStyle.None; this.Opacity = 0.5; this.BackgroundImage = CSWinFormSplashScreen.Properties.Resources.SplashImage; }
void t_Tick(object sender, EventArgs e) { // Fade in by increasing the opacity of the splash to 1.0 if (fadeIn) { if (this.Opacity < 1.0) { this.Opacity += 0.02; } // After fadeIn complete, begin fadeOut else { fadeIn = false; fadeOut = true; } } else if (fadeOut) // Fade out by increasing the opacity of the splash to 1.0 { if (this.Opacity > 0) { this.Opacity -= 0.02; } else { fadeOut = false; } } // After fadeIn and fadeOut complete, stop the timer and close this splash. if (!(fadeIn || fadeOut)) { t.Stop(); this.Close(); } }
void t_Tick(object sender, EventArgs e) { // Fade in by increasing the opacity of the splash to 1.0 if (fadeIn) { if (this.Opacity < 1.0) { this.Opacity += 0.02; } // After fadeIn complete, begin fadeOut else { fadeIn = false; fadeOut = true; } } else if (fadeOut) // Fade out by increasing the opacity of the splash to 1.0 { if (this.Opacity > 0) { this.Opacity -= 0.02; } else { fadeOut = false; } } // After fadeIn and fadeOut complete, stop the timer and close this splash. if (!(fadeIn || fadeOut)) { t.Stop(); this.Close(); } }
class SplashScreenUsingVBFramework : WindowsFormsApplicationBase { protected override void OnCreateSplashScreen() { base.OnCreateSplashScreen(); // You can replace the Splash2 screen to yours. this.SplashScreen = new CSWinFormSplashScreen.SplashScreen2(); } protected override void OnCreateMainForm() { base.OnCreateMainForm(); //Here you can specify the MainForm you want to start. this.MainForm = new MainForm(); } }
class SplashScreenUsingVBFramework : WindowsFormsApplicationBase { protected override void OnCreateSplashScreen() { base.OnCreateSplashScreen(); // You can replace the Splash2 screen to yours. this.SplashScreen = new CSWinFormSplashScreen.SplashScreen2(); } protected override void OnCreateMainForm() { base.OnCreateMainForm(); //Here you can specify the MainForm you want to start. this.MainForm = new MainForm(); } }
new SplashScreenUsingVBFramework().Run(args);
new SplashScreenUsingVBFramework().Run(args);