private void Btn_sleep_Click(object sender, EventArgs e) { timerSec = (ulong)Convert.ToDouble(Txt_sec.Text); timerMin = (ulong)Convert.ToDouble(Txt_min.Text); timerHour = (ulong)Convert.ToDouble(Txt_hour.Text); Timer_sleep.Start(); }
private void Timer_sleep_Tick(object sender, EventArgs e) { if (timerSec != 0) { timerSec--; Txt_sec.Text = timerSec.ToString(); } if (timerSec == 0 && timerMin != 0) { timerSec = 59; Txt_sec.Text = timerSec.ToString(); timerMin--; Txt_min.Text = timerMin.ToString(); } else if (timerSec == 0 && timerMin == 0 && timerHour != 0) { timerSec = 59; Txt_sec.Text = timerSec.ToString(); timerMin = 59; Txt_min.Text = timerMin.ToString(); timerHour--; Txt_hour.Text = timerHour.ToString(); } if (timerSec == 0 && timerMin == 0 && timerHour == 0) { Timer_sleep.Stop(); Application.SetSuspendState(PowerState.Hibernate, true, true); } }