private void btnSetCustomTime_Click(object sender, EventArgs e) { if (!isCollapsed) { btnTimer.PerformClick(); } try { int h, m, s, all; string timeRemain; //DIEUKIEN h = 0; m = 0; s = 0; if (txtHour.Text != "") { h = Convert.ToInt32(txtHour.Text); } if (txtMinute.Text != "") { m = Convert.ToInt32(txtMinute.Text); } if (txtSecond.Text != "") { s = Convert.ToInt32(txtSecond.Text); } if ((txtHour.Text == "") && (txtMinute.Text == "") && (txtSecond.Text == "")) { MsgBox.Show("You must enter timespan first", "ERROR", MsgBox.Buttons.OK, MsgBox.Icon.Error, MsgBox.AnimateStyle.FadeIn); } else { all = h * 60 * 60 + m * 60 + s; this.lblCountdown.Visible = true; s_Timer = new stopTimer(all); this.lblCountdown.Text = "CD: " + all; timeRemain = "Application will shut down in " + all.ToString() + " second(s)"; s_Timer.Tick += TimeOut; s_Timer.Tick += OneMinRemaining; if (all == 0) { Application.Exit(); } else { btnTimer.Hide(); btnStopTimer.Show(); notifyIcon.ShowBalloonTip(3000, "BLADE SleepTimer", timeRemain, ToolTipIcon.Warning); } } } catch (Exception ex) { MsgBox.Show("You must fill all fields", "ERROR", MsgBox.Buttons.OK, MsgBox.Icon.Error, MsgBox.AnimateStyle.FadeIn); } }
private void btn1h_Click_1(object sender, EventArgs e) { int all = 3600; this.lblCountdown.Visible = true; string timeRemain; this.lblCountdown.Text = "CD: " + all; s_Timer = new stopTimer(all); s_Timer.Tick += OneMinRemaining; s_Timer.Tick += TimeOut; if (!isCollapsed) { btnTimer.PerformClick(); } btnTimer.Hide(); btnStopTimer.Show(); timeRemain = "Application will shut down in an hour"; notifyIcon.ShowBalloonTip(3000, "BLADE SleepTimer", timeRemain, ToolTipIcon.Warning); }