C # Making a flare animation form

Source: Internet
Author: User

  1. First create a project in VS, project type Select vc#, create a Windows Forms application such as:

  2. After you click OK, set the form content in the form, and add three timers to the form from the toolbox, such as:

  3. In the form blank, right-click, click View Code, and under the initialization function, add the following code:

    The code is as follows:

    int screenwidth = SystemInformation.PrimaryMonitorMaximizedWindowSize.Width; Width of the screen

    int screenheight=systeminformation.primarymonitormaximizedwindowsize.heigh;//The height of the screen

  4. Double-click Timer1 to add the following code to the event function, such as:

    The code is as follows:

    Point mypos = new Point (this. Desktoplocation.x, this.       DESKTOPLOCATION.Y); The current position of the form

    if (mypos.x + Width < screenwidth)

    {

    This. Desktoplocation = new Point (mypos.x + 1, mypos.y);

    }

    Else

    {

    This. Desktoplocation = new Point (0, 0);

    }

  5. Double-click "Horizontal flapping" to add the following code to the event function, such as:

  6. The code is as follows:

    This.timer1.Enabled = true;

    this.timer2.Enabled = false;

    this.timer3.Enabled = false;

  7. Similarly double-click "Vertical Flare" to add code:

    this.timer1.Enabled = false;

    This.timer2.Enabled = true;

    this.timer3.Enabled = false;

  8. Double-click Timer2, add the following code to the event response function, such as: Code as follows:

     point MyPos = New Point (this. Desktoplocation.x, this. DESKTOPLOCATION.Y);      //The current position of the form

                if (Mypos.y + Height < screenheight)

                {

                    this. Desktoplocation = new Point (mypos.x, Mypos.y + 1);

               }

                Else

                {

                  this. Desktoplocation = new Point (0, 0);

               }

  9. Similarly double-click Timer3 and add the following code:

     point mypos = new Point ( This. Desktoplocation.x, this. DESKTOPLOCATION.Y);      //The current position of the form

                if (mypos.x + Width < ScreenWidth | | Mypos.y + Height < screenheight)

                {

            &N Bsp       this. Desktoplocation = new Point (mypos.x + 1, mypos.y + 1);

               }

                Else

                {

                  this. Desktoplocation = new Point (0, 0);

               }

     

  10. Then double-click the Flare form to add the following code:

    this.timer1.Enabled = false;

    this.timer2.Enabled = false;

    This.timer3.Enabled = true;

  11. Similarly double-click to stop flapping, add the following code:

    this.timer1.Enabled = false;

    this.timer2.Enabled = false;

    this.timer3.Enabled = false;

  12. Finally, double-click on the blank in the form to create the Form1_Load event and add the following code, such as:

    The code is as follows: This.timer1.Enabled = true;

  13. Start debugging and run the results such as:

C # Making a flare animation form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.