5 Star 4 Fork 2

芝麻科技 / SplashScreen

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

SplashScreen

输入图片说明

A lightweight and easy-to-use splash screen control that starts life before the Application Form

Introduction

Awhile back, when I first browsed around for splash screen examples, I couldn't find anything that met my requirements for a splash screen. I wanted something simple, flexible, reliable, intrinsically safe -- no threads or child controls etc. -- and that would start up immediately, stay on top, go away when required and also reappear if wanted. I have noticed there are some good examples based entirely within .NET using Forms, whereas the approach I have taken uses the System.Runtime.InteropServices to create a topmost top-level window from a Control-based class. I prefer this approach, as I have found it to be reliable and very flexible with regards to customisation. Because of the required simplicity, the control handles its own painting, which provides the freedom to use the GDI to create an application-personalised splash screen.

Background

I had been developing an application that required a splash screen. The motivation to provide a splash screen is given by any delay between launching the application and the user interface subsequently becoming available.

There's something reassuring about an application that starts up straightaway, without a splash screen, ready to use. However, if a program has any reason to initialize before starting, which implies a potential for delay or failure, then it would be best to present something right away via a splash screen with a commentary. This can have its benefits, as well:

A branding opportunity

With a visually pleasing background graphic for your banner, you can immediately create a better first impression with your users. It's an opportunity to brand your software and, just as importantly, brand a version. Users of Office, for instance, know immediately what version they are starting up, 2003 or 2007, for example.

A moment of greater user attention

It's a good opportunity to take advantage of the increased attention you have from your user. After all, they've just thought about your software and launched it. So whilst loading you could, for example, remind them to visit your website for up-to-date news about your products.

A chance to relay start-up and configuration information

If your program relies on establishing connections -- or dynamically loads plug-ins or the like -- then a splash screen can make the user aware of what you are connecting to or loading. This information could prove useful to both you and your users.

Using the Code

To use the class SplashScreen, add the file SplashScreen.cs to your application. Locate the entry point Main in your program, typically in Program.cs for a generated project.

SplashScreen is implemented as a Singleton pattern class. This is a class that allows a maximum of one instance of itself. This is achieved by using a private constructor with a static member reference to the created instance and public static access to that instance. SplashScreen also provides public static methods to manage using the control.

After the calls to the application visual styles and text rendering settings, initialize SplashScreen with your image resource (if required) and call the static method BeginDisplay() to present the splash screen. From now on, use the static methods SetTitleString and SetCommentaryString at your start-up checkpoints to keep the user informed of progress. Remember that you initialize SplashScreen in Main, but you will continue to use it and end its display in your Forms application. The principal places of interest in your application's main form are the OnLoad and OnShown overrides. Of most importance is that you call the static method EndDisplay() in the OnShown override.

Comments ( 0 )

Sign in for post a comment

About

A lightweight and easy-to-use splash screen control that starts life before the Application Form spread retract
C#
Cancel

Releases

No release

SplashScreen

Contributors

All

Activities

load more
can not load any more
C#
1
https://gitee.com/sesametech-group/SplashScreen.git
git@gitee.com:sesametech-group/SplashScreen.git
sesametech-group
SplashScreen
SplashScreen
master

Search