public Form1() { InitializeComponent(); whichTimer = WhichTimer.Timer1; readSeconds(WhichTimer.Timer1); readSeconds(WhichTimer.Timer2); showSeconds(WhichTimer.Timer1); showSeconds(WhichTimer.Timer2); rdlg = new ResponseDialog(); random = new Random(); }
private void whichTimerButton_Click(object sender, EventArgs e) { if (whichTimer == WhichTimer.Timer1) { whichTimer = WhichTimer.Timer2; whichTimerButton.Text = "-->"; } else { whichTimer = WhichTimer.Timer1; whichTimerButton.Text = "<--"; } }
private void timer_Tick(object sender, EventArgs e) { if (whichTimer == WhichTimer.Timer1) { seconds1 -= 1; if (seconds1 <= 0) { readSeconds(WhichTimer.Timer1); whichTimer = WhichTimer.Timer2; whichTimerButton.Text = "-->"; this.WindowState = FormWindowState.Normal; //MessageBox.Show("Timer1"); DoTimeoutDialog("Timer 1"); } showSeconds(WhichTimer.Timer1); } else { seconds2 -= 1; if (seconds2 <= 0) { readSeconds(WhichTimer.Timer2); whichTimer = WhichTimer.Timer1; whichTimerButton.Text = "<--"; this.WindowState = FormWindowState.Normal; //MessageBox.Show("Timer2"); DoTimeoutDialog("Timer 2"); } showSeconds(WhichTimer.Timer2); } }
private void showSeconds(WhichTimer w) { if (w == WhichTimer.Timer1) { string t = string.Format("{0:00}:{1:00}", seconds1 / 60, seconds1 % 60); timer1Label.Text = t; this.Text = "TwoTimer - " + t; } else { string t = string.Format("{0:00}:{1:00}", seconds2 / 60, seconds2 % 60); timer2Label.Text = t; this.Text = "TwoTimer - " + t; } }
private void readSeconds(WhichTimer w) { if (w == WhichTimer.Timer1) { seconds1 = getSeconds(w); } else { seconds2 = getSeconds(w); } }
private int getSeconds(WhichTimer w) { string source = timer1Text.Text; if (w == WhichTimer.Timer2) { source = timer2Text.Text; } try { return Int32.Parse(source) * 60; } catch (Exception ex) { return 0; } }