Exemplo n.º 1
0
        private void Timer_Click(object sender, EventArgs e)
        {
            if (expectedTime > DateTime.Now)
            {
                int    totalMinutes = (int)expectedTime.Subtract(DateTime.Now).TotalMinutes;
                int    hours        = totalMinutes / 60;
                int    mins         = totalMinutes % 60;
                string hoursValue   = (hours < 10) ? $"0{hours}" : hours.ToString();
                string minsValue    = (mins < 10) ? $"0{mins}" : mins.ToString();
                label.Content = $"{selectedMode} in {hoursValue}:{minsValue}";
            }
            else
            {
                switch (selectedMode)
                {
                case TimerMode.ShutDown:
                    powerManager.ShutDown();
                    break;

                case TimerMode.Sleep:
                    powerManager.Sleep();
                    break;
                }
                Timer.Stop();
            }
        }