Ejemplo n.º 1
0
        private void UpdateReceiver(object sender, Timer.UpdateEventArgs e)
        {
            Console.WriteLine("Just Update the timer.");
            Action DoAction = delegate()
            {
                this.displayer.Clear();

                switch (this.timer.timerOption)
                {
                case TimerOption.Timing:        //  If it's a timing timer, just show the time.
                    this.displayer.AppendText(e.Diff.ToString("hh':'mm':'ss'.'fff"));
                    break;

                default:        //  Else, show the time left and the progress.
                    if (e.Expire)
                    {
                        this.refreshProgressBar(0);        //   When it's expired, the progress bar should be run to the end.
                    }
                    else
                    {
                        double percent = (e.Diff.TotalMilliseconds / e.Orig.TotalMilliseconds);
                        this.refreshProgressBar(percent);       //  Show progress bar according to the percentage.
                    }
                    this.displayer.AppendText(e.Diff.ToString("hh':'mm':'ss'.'fff"));
                    break;
                }
            };

            if (this.InvokeRequired)//  Cross-thread operation
            {
                ControlExtensions.UIThreadInvoke(this, delegate
                {
                    DoAction();
                });
            }
            else
            {
                DoAction();
            }
        }
Ejemplo n.º 2
0
        //  Receive the event when start a timer in the TimerChooseForm UI logic.
        private void ChosenReceiver(object sender, TimerChooseForm.ChosenEventArgs e)
        {
            Console.WriteLine("Just Selected and started the timer.");
            Action DoAction = delegate()
            {
                TimerForm f = new TimerForm(e.duration, e.option, e.cycle_limit);
                f.Show();
                this.TCF.Close();
            };

            if (this.InvokeRequired)
            {
                ControlExtensions.UIThreadInvoke(this, delegate
                {
                    DoAction();
                });
            }
            else
            {
                DoAction();
            }
        }
Ejemplo n.º 3
0
        //  Run when the choose unit is closed.
        private void ClosedEventReceiver(object sender, FormClosedEventArgs e)
        {
            Action DoAction = delegate()
            {
                if (this.TCF != null)
                {
                    this.TCF = null;
                }
            };

            if (this.InvokeRequired)
            {
                ControlExtensions.UIThreadInvoke(this, delegate
                {
                    DoAction();
                });
            }
            else
            {
                DoAction();
            }
        }
Ejemplo n.º 4
0
        //  Run when got the end event.
        private void EndReceiver(object sender, EventArgs e)
        {
            Console.WriteLine("Just end the timer.");
            Action DoAction = delegate()
            {
                this.textBox1.Clear();
                this.textBox1.AppendText("Now the Timer is ended!");
            };


            if (this.InvokeRequired)//  Cross-thread operation
            {
                ControlExtensions.UIThreadInvoke(this, delegate
                {
                    DoAction();
                });
            }
            else
            {
                DoAction();
            }
        }