Tuesday, September 24, 2013

Splash Screen (Ver. 1)

How to make a simple splash screen using C#. The purpose of the splash screen is to introduce the name of the program, the brand, the developer and the company but sometimes, it is used to make the program not too heavy during running or to wait other functions to load (also known as a loading screen) during the opening of the program.


Down here is the video



Codes down here



I used 3 timers, 1st timer for increment, 2nd timer for buffer, 3rd timer for decrement.

int count = 0, buffer = 0;
        public Form1()
        {
            InitializeComponent();
            Opacity = 0;
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if(Opacity == 1)
            {
                timer2.Start();
                timer1.Stop();
            }
            else
            {
                count++;
                Opacity = count * 0.01;
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if(buffer == 3)
            {
                timer3.Start();
                timer2.Stop();
            }
            else
            {
                buffer++;
            }
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            if(Opacity == 0)
            {
                Form2 newform = new Form2();
                newform.Show();
                Hide();
                timer3.Stop();
            }
            else
            {
                count--;
                Opacity = count * 0.01;
            }
        }

No comments:

Post a Comment