15

How can I create an animated splash screen like the one in Office 2010 using C#?

Saleh Omar
  • 739
  • 2
  • 8
  • 29

6 Answers6

14

Is this question about winforms or wpf?

If it's about wpf:

An animated splash screen is not more than a wpf window showing while your "Main Window" is loading. You can design this splash window with Expression Blend as explained by wischi.

You can also have a look at this code project.

For creating some kind of a loading animation: A Simple WPF Loading Animation

Just create a window with an animation defined in xaml and show it while your application is loading -> animated splash screen.

In Winforms:

You may have to override the paint method of a form to create an animation. But it's still showing another window which contains an animation while another window is loading.

The-First-Tiger
  • 1,574
  • 11
  • 18
  • How do you deal with a busy UI thread? In my case the animation is not running smoothly. Not everything can be offloaded to background threads. – sa.he Jan 05 '17 at 10:30
  • To answer my own question. Start the Splash window in another Thread like here http://stackoverflow.com/questions/1111369/how-do-i-create-and-show-wpf-windows-on-separate-threads#1111485 – sa.he Jan 05 '17 at 11:15
3

I recommend using WPF for modern application design and your splashscreen problem.
Expression Blend is a nice tool for creating animations and xaml designs. But you can also design animations by writing plain xaml as well

Expression Blend Tutorials
Animation Using Expression Blend: How to create an animation
Animation Using Expression Blend: How to start animations on events

MSDN Info
Animation Overview

Using Winforms it will be much more complicated. The entire GUI is rendered by the CPU (no GPU support) but you can create a custom usercontrol and overwrite the Paint event and use GDI for drawing, but this will be much more complicated then using wpf.

wischi
  • 666
  • 10
  • 34
  • You did not say anything about how this is related to splash screen and how to use the animation with the splash screen! – Saleh Omar Feb 04 '13 at 18:44
  • 1
    A splash screen is just a window without border during loading to entertain the user who's waiting. That's it. If you would probably be so kind and specify your question it would be easier for us to help. ;-) – wischi Feb 05 '13 at 09:38
  • I am asking about the how. You talked about the animation which is great. But how would I apply this animation to the splash screen? It might be easy! But a small example would be nice. – Saleh Omar Feb 05 '13 at 12:06
  • 1
    "You did not say anything about how this is related to splash screen and how to use the animation with the splash screen!" Yes he did. This is exactly what you need to know. You say you've created splash screens, you say you've used WPF. 1 + 1 = 2. – Wim Ombelets Feb 08 '13 at 17:29
2

if you want to make a dynamic animated splash screen like Office 2010 , i recommend you to use WPF and never think about WinForms to make dynamic animation with code !

but if you are determined of using WinForms you have to be tricky , and use one of this tricks :

• put a Flash ActiveX Object , and make your animation with Flash then link them together

• if you are good with WPF and Silverlight you can make your animation with Silverlight and view it in a WebBrowser Control , You may also use Flash or HTML5

Eslam Hamouda
  • 1,141
  • 9
  • 13
1

A detailed guide for a splashscreen is here: eExample splashscreen

Another example

Although the basics is:

1) Create a splashscreen, show it, close/dispose it

    private void SplashForm()
    {
    SplashForm newSplashForm = new SplashForm();
    newSplashForm.ShowDialog();
    newSplashForm.Dispose();
    }

2) Run the splashscreen on a seperate thread/backgroundworker

        Thread t1 = new Thread(new ThreadStart(SplashForm));
        t1.Start();
        Thread.Sleep(5000); // 5 seconds
        t1.Abort();
        Thread.Sleep(1000);
Random IT Guy
  • 625
  • 1
  • 8
  • 16
  • 1
    I know how to create a splash screen bro. In fact I have created a lot. My question is how create an animated one like the office 2010's. Thanks anyway. – Saleh Omar Feb 01 '13 at 12:36
  • @SalehOmar What about a picturebox with a gif inside? If you can create your own gif, it should work. – Random IT Guy Feb 01 '13 at 12:44
  • I have thought about this but it does not seem that way. If you run office you will get the feeling that it is dynamic. – Saleh Omar Feb 01 '13 at 12:47
  • @SalehOmar Btw are you using WPF or Winform or? – Random IT Guy Feb 01 '13 at 13:04
  • Windows Forms, but I use WPF too. – Saleh Omar Feb 01 '13 at 13:20
  • I can't realy find anything besides using a gif + transparent label to update text, or a gif with fading text. If you can try to create a gif with layers and changing opacity, otherwise no idea. – Random IT Guy Feb 01 '13 at 13:30
  • 1
    The office animation isn't dynamic, it's just a very well animated image. – Karl-Johan Sjögren Feb 03 '13 at 14:24
  • 4
    @SalehOmar If you already know how to create a splash screen, then perhaps a more appropriate question is *"How can I produce animation in C# WinForms?"*. – Snixtor Feb 05 '13 at 05:22
  • Sorry may be I am not good at formulating questions. I basically wanted to know how the animation was produced in office. I wanted to implemented it in Winforms. I knew it will be easier to be implemented in WPF. What I was asking for is a formal way to carry out such task rather than using a hack. But if it is done this way then fine. – Saleh Omar Feb 08 '13 at 19:48
1

In Winforms, the simplest way is using a PictureBox with an animated Gif on a splashscreen.

This way allows you to spend more time on your animation than your code.

Marco Guignard
  • 613
  • 3
  • 9
0

In WPF it is very easy just right click on project > add new item > splash screen. This

is simple example explaining it.

user4340666
  • 1,453
  • 15
  • 36