private void btnSubmit_Click(object sender, EventArgs e) { TimerCountDown.Stop(); if (txtBxAnswer.Text.ToLower() == aQuestion.Answer.ToLower()) { this.ReturnBool = true; this.ReturnPoint = aQuestion.Point; this.DialogResult = DialogResult.OK; string message = "Correct"; string title = "Congratulation"; MessageBox.Show(message, title); this.Close(); } else { this.ReturnBool = false; this.ReturnPoint = aQuestion.Point * -1; this.DialogResult = DialogResult.OK; string message = $"Oops!!! The correct answer is {aQuestion.Answer}"; string title = "Oops"; MessageBox.Show(message, title); this.Close(); } }
private void btnStart_Click(object sender, EventArgs e) { TimerCountDown.Stop(); try { timeTick.setTimeInt(textBoxHour.Text, textBoxMin.Text, textBoxSec.Text); numRepeat = int.Parse(textBoxRepeat.Text); timeTick.totalTime = 0; countDownCurrent = timeTick.hour * 3600 + timeTick.min * 60 + timeTick.sec; if (timeTick.hour * 3600 + timeTick.min * 60 + timeTick.sec > 0 && timeTick.min <= 60 && timeTick.sec <= 60) { memory.addHistoryList(textBoxHour.Text, textBoxMin.Text, textBoxSec.Text, textBoxRepeat.Text); memory.updateListView(listViewHistory, "history"); TimerCountDown.Interval = 1000; TimerCountDown.Start(); toggleAvaliabilityTextbox(false); } else { MessageBox.Show("Please enter a valid value", "Error", MessageBoxButtons.OK); initialise("countdown"); } } catch { MessageBox.Show("Please enter positive integers to all textBoxes", "Error", MessageBoxButtons.OK); initialise("countdown"); } }
private void ButtonStopBackup_Click(object sender, EventArgs e) { if (ButtonStopBackup.Text == "停止備份") { ButtonStopBackup.Text = "繼續備份"; TimerFreq.Stop(); TimerCountDown.Stop(); } else { ButtonStopBackup.Text = "停止備份"; TimerFreq.Start(); TimerCountDown.Start(); } }
/// <summary> /// Timercountdown , not sure if you want the question to be closed or the player still have chance to answer after that /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimerCountDown_Tick(object sender, EventArgs e) { if (quick > 0) { // by updating the Time Left label. quick--; lblTimer.Text = quick / 60 + ":" + ((quick % 60) >= 10 ? (quick % 60).ToString() : "0" + (quick % 60)); } else { // If the user ran out of time, stop the timer, show // a MessageBox, and fill in the answers. TimerCountDown.Stop(); string message = $"Time's up!!!\nThe correct answer is \"{aQuestion.Answer}\""; string title = "Oops! Time's up."; MessageBox.Show(message, title); this.Close();// Im not sure if you want to close the form } }
private void checkTiming_Tick(object sender, EventArgs e) { timeTick.updateTime(countDownCurrent); Console.WriteLine(countDownCurrent); updateTextBoxes(); if (countDownCurrent > 0) { countDownCurrent--; } if (countDownCurrent == 0) { if (numRepeat == 1) { TimerCountDown.Stop(); toggleAvaliabilityTextbox(true); MessageBox.Show(memory.listHistory.Last() + " has elapsed", "Timing has Ended", MessageBoxButtons.OK); timeTick.totalTime = 0; } if (numRepeat > 1) { numRepeat--; countDownCurrent = timeTick.totalTime; setTextBoxes(memory.getSplittedTime(memory.listHistory.Count() - 1, "history")); timeTick.setTimeList(memory.getSplittedTime(memory.listHistory.Count() - 1, "history")); TimerCountDown.Stop(); if (MessageBox.Show(memory.listHistory.Last() + " has elapsed. " + "Repeating " + numRepeat.ToString() + " more times", "Timing has Ended", MessageBoxButtons.OK) == DialogResult.OK) { TimerCountDown.Interval = 1000; TimerCountDown.Start(); } } } }
private void initialise(string mode) { switch (mode) { case "countdown": textBoxHour.Text = "00"; textBoxMin.Text = "00"; textBoxSec.Text = "00"; countDownCurrent = 0; timeTick.hour = 0; timeTick.min = 0; timeTick.sec = 0; TimerCountDown.Stop(); toggleAvaliabilityTextbox(true); break; case "stopwatch": SWTextBoxHr.Text = "00"; SWTextBoxMin.Text = "00"; SWTextBoxSec.Text = "00"; break; } }
private void FrmAandQ_FormClosing(object sender, FormClosingEventArgs e) { TimerCountDown.Stop(); }
private void btnStop_Click(object sender, EventArgs e) { TimerCountDown.Stop(); updateTextBoxes(); }