Esempio n. 1
0
 private void btnPause_Click(object sender, EventArgs e)
 {
     ActiveControl = null;
     if (Action == isAction.isStart)
     {
         Action = isAction.isPause;
         me.Reset();
     }
 }
Esempio n. 2
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     ActiveControl = null;
     if (Action == isAction.isStart || Action == isAction.isPause)
     {
         Action = isAction.isStop;
         me.Reset();
         microwave.Time = new TimeSpan(0, 0, 0);
         lblTimer.Text  = microwave.TimePowerUpdate();
     }
 }
Esempio n. 3
0
        public void StartTimer(object state)
        {
            ManualResetEvent MRE   = (ManualResetEvent)state;
            Color            color = Color.Black;

            while (true)
            {
                MRE.WaitOne();
                if (microwave.Time.TotalSeconds == 0)
                {
                    Console.Beep(4000, 250);
                    Console.Beep(4000, 250);
                    Thread.Sleep(1000);
                    Console.Beep(4000, 250);
                    Console.Beep(4000, 250);
                    Action = isAction.isStop;
                    break;
                }

                microwave.Time = microwave.Time.Add(new TimeSpan(0, 0, -1));
                //lblTimer.Text = microwave.TimePowerUpdate();
                string str = microwave.TimePowerUpdate();

                if (color == Color.Red)
                {
                    color = Color.Black;
                }
                else
                {
                    color = Color.Red;
                }

                lblTimer.Invoke(new Del((s) => lblTimer.ForeColor = color), "newText");
                lblTimer.Invoke(new Del((s) => lblTimer.Text      = str), "newText");
                Thread.Sleep(500);

                if (color == Color.Red)
                {
                    color = Color.Black;
                }
                else
                {
                    color = Color.Red;
                }

                lblTimer.Invoke(new Del((s) => lblTimer.ForeColor = color), "newText");
                Thread.Sleep(500);
            }
        }
Esempio n. 4
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     ActiveControl = null;
     if (microwave.Time.TotalSeconds == 0)
     {
         return;
     }
     if (Action == isAction.isStop)
     {
         Action = isAction.isStart;
         thread = new Thread(StartTimer);
         me     = new ManualResetEvent(true);
         thread.Start(me);
     }
     if (Action == isAction.isPause)
     {
         Action = isAction.isStart;
         me.Set();
     }
 }
Esempio n. 5
0
        public Form()
        {
            InitializeComponent();
            Action        = isAction.isStop;
            microwave     = new Microwave(this);
            lblTimer.Text = microwave.TimePowerUpdate();
            isOpened      = false;

            byte[] fontData = Properties.Resources.LCDM2N;
            IntPtr fontPtr  = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);

            System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
            uint dummy = 0;

            fonts.AddMemoryFont(fontPtr, Properties.Resources.LCDM2N.Length);
            AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.LCDM2N.Length, IntPtr.Zero, ref dummy);
            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);

            myFont = new Font(fonts.Families[0], 12.0F);

            lblTimer.Font = myFont;
        }