Esempio n. 1
0
        public void timer1_Tick(object o, EventArgs sender)
        {
            if (min == 0 && hours == 0 && sec == 0)
            {
                timerhour.Content    = "00";
                timerminutes.Content = "00";
            }
            else
            {
                if (sec < 1)
                {
                    sec = 59;
                    if (min < 1)
                    {
                        min = 59;

                        if (hours != 0)
                        {
                            hours -= 1;
                        }
                    }
                    else
                    {
                        if (min == 6 && hours == 0)
                        {
                            this.Background = new SolidColorBrush(Colors.Orange);

                            Window dialog = new MyDialog();
                            dialog.Show();
                        }
                        min -= 1;
                    }
                }
                else
                {
                    if (hours == 0 && min == 0)
                    {
                        Restart();
                    }
                    sec -= 1;
                }

                if (hours > 9)
                {
                    timerhour.Content = hours.ToString();
                }
                else
                {
                    timerhour.Content = "0" + hours.ToString();
                }
                if (min > 9)
                {
                    timerminutes.Content = min.ToString();
                }
                else
                {
                    timerminutes.Content = "0" + min.ToString();
                }
            }
        }
        public void timer1_Tick(object o, EventArgs sender)
        {
            if (min == 0 && hours == 0 && sec == 0)
            {

                timerhour.Content = "00";
                timerminutes.Content = "00";
            }
            else
            {

                if (sec < 1)
                {
                    sec = 59;
                    if (min < 1)
                    {
                        min = 59;

                        if (hours != 0)
                        {
                            hours -= 1;
                        }
                    }
                    else
                    {
                        if (min == 6 && hours==0)
                        {
                            this.Background = new SolidColorBrush(Colors.Orange);

                            Window dialog = new MyDialog();
                            dialog.Show();
                        }
                        min -= 1;
                    }
                }
                else
                {
                     if (hours == 0 && min == 0)
                    {

                        Restart();
                    }
                    sec -= 1;
                }

                if (hours > 9)
                    timerhour.Content =  hours.ToString();
                else
                    timerhour.Content = "0" + hours.ToString();
                if (min > 9)
                    timerminutes.Content = min.ToString();
                else
                    timerminutes.Content = "0" + min.ToString();
            }
        }