A newer version of this page is available. Switch to the current version.

Splash Image

  • 8 minutes to read

This topic covers information on displaying custom images as splash screens using the Splash Screen Manager component. Image transparency is supported, so splash images may be of an irregular form and may contain shadows.

There are two ways to display an image as a splash screen.

Method 1 - Create a Splash Image Using a Splash Screen

The first method is described in the Splash Screen document. Create a SplashScreen object via the Splash Screen Manager component and set the SplashScreen.ShowMode property to Image. Then, assign a custom splash image to the SplashScreen.SplashImage property. Below you can see the default splash image displayed if no custom image is specified.

SplashScreen-DefaultImage

Using this method, you can choose between displaying a Splash Screen with an image automatically on the main form's startup or manually during the application run. See Splash Screen to learn more.

Method 2 - Direct Image Display

Another way to show an image as a splash screen is to manually call the static SplashScreenManager.ShowImage method. An image to be displayed is passed as the method's parameter. To hide the image, call SplashScreenManager.HideImage.


Image im = Image.FromFile("mySplashScreen.png");
SplashScreenManager.ShowImage(im);
//...
SplashScreenManager.HideImage();

Note that the SplashScreenManager.ShowImage method has a number of overloads that allow fade-in and fade-out effects to be enabled and draw custom graphics over the image.

Unlike the first approach, this one doesn't allow custom controls to be added above the splash image. However, you can draw custom graphics over the image by using the ShowImage method overload that takes an ICustomImagePainter object as a parameter. You need to create a class supporting the ICustomImagePainter interface and implement a paint procedure via the ICustomImagePainter.Draw method. The ICustomImagePainter.Draw method will be invoked each time the splash image is redisplayed. If required, you can dynamically update the splash image by calling the SplashScreenManager.Invalidate method, thus forcing your ICustomImagePainter.Draw method to be re-called.

Example

In this example, an image is displayed as a splash screen via the SplashScreenManager.ShowImage method.Custom information is painted over this image via a custom class (SplashImagePainter), whose instance is passed as a parameter to the ShowImage method. The SplashImagePainter draws text labels with custom progress information.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;

namespace SplashScreenManagerSample01 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            LongInitialization();
        }
        protected void LongInitialization() {
            BaseInitialization();
            LoadFonts();
            LoadTextures();
        }

        void BaseInitialization() {
            // Set progress stage to be displayed by SplashImagePainter
            SplashImagePainter.Painter.ViewInfo.Stage = "Initialization";
            for(int i = 1; i <= 100; i++) {
                System.Threading.Thread.Sleep(20);

                // Change progress to be displayed by SplashImagePainter
                SplashImagePainter.Painter.ViewInfo.Counter = i;
                //Force SplashImagePainter to repaint information
                SplashScreenManager.Default.Invalidate();
            }
        }
        void LoadFonts() {
            // Set progress stage to be displayed by SplashImagePainter
            SplashImagePainter.Painter.ViewInfo.Stage = "Loading Fonts";
            for(int i = 1; i <= 100; i++) {
                System.Threading.Thread.Sleep(20);

                // Change progress to be displayed by SplashImagePainter
                SplashImagePainter.Painter.ViewInfo.Counter = i;
                //Force SplashImagePainter to repaint information
                SplashScreenManager.Default.Invalidate();
            }
        }
        void LoadTextures() {
            // Set progress stage to be displayed by SplashImagePainter
            SplashImagePainter.Painter.ViewInfo.Stage = "Loading Textures";
            for(int i = 1; i <= 100; i++) {
                System.Threading.Thread.Sleep(20);

                // Change progress to be displayed by SplashImagePainter
                SplashImagePainter.Painter.ViewInfo.Counter = i;
                //Force SplashImagePainter to repaint information
                SplashScreenManager.Default.Invalidate();
            }
        }
        //

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            // Close splash image
            SplashScreenManager.HideImage();
        }
    }
}
See Also