private void FormMain_Load(object sender, EventArgs e) { PicAni.Hide(); Timer timer = new Timer(); timer.Enabled = true; timer.Interval = 100; timer.Start(); timer.Tick += delegate { LabelTime.Text = DateTime.Now.ToLongTimeString() + " - " + DateTime.Now.ToLongDateString(); }; }
private void BtnClaer_Click(object sender, EventArgs e) { var result = MessageBox.Show("آیا میخواهید یادآور پاک شود ؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { PicAni.Hide(); BtnStart.Enabled = true; StepTime = 0; ValueTime.Value = 0; TimerMain.Stop(); ViewTime.Text = "Clock"; groupBox1.Text = "Alarm"; BtnStop.Text = "Stop"; BtnStop.BackColor = Color.FromArgb(192, 0, 0); } }
private void TimerMain_Tick(object sender, EventArgs e) { try { if (EnabelTMP) { StepTime++; } else { StepTime--; } ValueTime.Value = (int)(StepTime / 60) + 1; TimeSpan timesp = TimeSpan.FromSeconds(StepTime); ViewTime.Text = timesp.ToString(@"hh\:mm\:ss"); if (StepTime == 0 && EnabelTMP == false && FHide == true) { //new FormMain().Show(); Show(); FHide = false; } if (StepTime == 0 && EnabelTMP == false) { TimerMain.Stop(); PicAni.Hide(); System.Media.SystemSounds.Asterisk.Play(); Console.Beep(3000, 1000); MessageBox.Show("End Alarm !", "Remiander"); ViewTime.Text = "Clock"; ValueTime.Value = 0; BtnStop.Text = "Stop"; BtnStart.Enabled = true; BtnStop.BackColor = Color.FromArgb(192, 0, 0); } } catch (Exception ex) { TimerMain.Stop(); MessageBox.Show(ex.Message, "Error Timer"); } }
private void BtnStop_Click(object sender, EventArgs e) { if (StepTime > 0) { TimerMain.Enabled = !TimerMain.Enabled; if (TimerMain.Enabled) { PicAni.Show(); BtnStop.Text = "Stop"; BtnStop.BackColor = Color.FromArgb(192, 0, 0); } else { PicAni.Hide(); BtnStop.BackColor = Color.Orange; BtnStop.Text = "Continue"; } } }