2008/C#2008. 10. 14. 16:51

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;

namespace Login
{
    public partial class LoginForm : Form
    {
        private int index = 12;
        private int index2 = 12;

        bool isSleep = false;

        Thread t1;

        System.Windows.Forms.Timer timer1;
        System.Windows.Forms.Timer timer2;


        public LoginForm()
        {
            InitializeComponent();       
           
        }

        private void LoginForm_Load(object sender, EventArgs e)
        {
            axWebBrowser1.Navigate(Application.StartupPath + @"\0_main.swf");

            timer1 = new System.Windows.Forms.Timer();
            timer2 = new System.Windows.Forms.Timer();

            timer1.Tick += new EventHandler(timer1_Tick);
            timer2.Tick += new EventHandler(timer2_Tick);

            timer1.Interval = 10;
            timer2.Interval = 10;

            timer1.Enabled =true;
            timer2.Enabled =true;   
        }

        void timer2_Tick(object sender, EventArgs e)
        {
            index2++;

            if (index2 == 60) index2 = 12;

            button2.Location = new Point(index2, 183);


        }

        void timer1_Tick(object sender, EventArgs e)
        {
            // isSleep(bool)변수가 false일때만 실행

            if (!isSleep)
            {

                index++;

 

                // index가 30이면 isSleep을 true로 바꾸고

                // 쓰레드를 실행합니다.

                if (index == 30)
                {

                    isSleep = true;

                    t1 = new Thread(new ThreadStart(TimerStart));

                    t1.Start();

                }

 

                // index가 60이면 12로(앞으로) 되돌리고 애니메이션~!

                if (index == 60) index = 12;

                button2.Location = new Point(index, 12);

            }


        }

        private void TimerStart()
        {

            // 간단하게 0.5초를 쉬고 isSleep변수값을 바꿉니다.

            Thread.Sleep(500);

            isSleep = false;

      }
      
    }
}

Posted by penguindori