Introduction
Many produce programs that are similar to the user interface of renowned Microsoft Office. Many ribbon, skin and other controls are made from a variety of platforms (WPF, Windows Forms, Active X) Microsoft Office model. I am writing about this because I have not seen a lot of these.
How to create Office 2013 style splash screen for Windows Forms? I present the step by step procedure below.
Step 1: Create the Project
Create a new Windows Forms application in Visual Studio. Download Metro ProgressBar, and the blue splash background. Create new Windows Forms to your project (Click „Project”->”Add Windows Form...”).
Step 2: Configure Splash Screen Form
Select the new Windows Forms window, set the "FormBorderStyle" property to "None". Select blue splash image to "BackgroundImage". You can use red (than the PowerPoint), green (than the Excel and the Publisher) or own colour background. Minimum and maximum size: width: 439, Height: 248.
Step 3: Create the Controls
It should look like:
Step 4: Write the Code
The Program.cs is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Office2013StyleSplashScreen
{
static class Program
{
[STAThread] static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Splash());
}
}
}
The splash form source code is as follows:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Threading;
namespace Office2013StyleSplashScreen
{
public partial class Splash : Form
{
public Splash()
{
InitializeComponent();
tasks.Text = "Starting...";
Thread.Sleep(1000);
splashtime.Start();
}
public bool Isminimized = false;
private void close_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void minimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
Isminimized = true;
}
private void close_MouseHover(object sender, EventArgs e)
{
close.ForeColor = Color.Silver;
}
private void close_MouseLeave(object sender, EventArgs e)
{
close.ForeColor = Color.White;
}
private void minimize_MouseHover(object sender, EventArgs e)
{
minimize.ForeColor = Color.Silver;
}
private void minimize_MouseLeave(object sender, EventArgs e)
{
minimize.ForeColor = Color.White;
}
public void frmNewFormThread()
{
var frmNewForm = new Form1();
if(Isminimized == true)
{
frmNewForm.WindowState = FormWindowState.Minimized;
}
else
{
frmNewForm.WindowState = FormWindowState.Maximized;
}
Application.Run(frmNewForm);
}
private void splashtime_Tick(object sender, EventArgs e)
{
splashtime.Stop();
var newThread = new System.Threading.Thread(frmNewFormThread);
newThread.SetApartmentState(System.Threading.ApartmentState.STA);
newThread.Start();
this.Close();
}
}
}
I use this.Close();
method to close splash screen, therefore create new Task to start application general window. Set the thread apartmentstate to STA(newThread.SetApartmentState(System.Threading.ApartmentState.STA);
).
You can see the related documentation by clicking on the link below:
The Final Result
The Microsoft Office Word splash screen(left) and My splash screen(right), almost same!
History
Not all programs have splash screen. But if you need or want it to look good, I've done this. I hope that this will be useful for your program!