예제 #1
0
 //Clicking ResetBtn will set reset to true so that when textBox change, it will not start timer again
 //This will reset the timer, clear the textBox, set readOnly for textBox to false, and switch visiblity of wordPerMin to false
 private void ResetBtn_Click(object sender, EventArgs e)
 {
     reset = true;
     TimerController.ResetTimer(time);
     TextBoxController.ClearTextBox(textBox);
     TextBoxController.SetReadOnly(textBox, false);
     accuracyController.SetVisibility(accuracy, false);
     WordPerMinController.SetVisibility(wordPerMinLabel, false);
     WordPerMinController.SetVisibility(wordPerMin, false);
 }
예제 #2
0
 //Detect when ever user type something in textBox.
 //When resetBtn is clicked, only run reset sequence
 //Trigger timer when it is not running
 //Stops the timer and disable textBox when length of textBox is same as length of sampleText
 //Disables textBox when user is done typing
 private void TextBox_TextChanged(object sender, EventArgs e)
 {
     WordCountController.UpdateWordCount(textBox, wordCount);
     if (reset)
     {
         TimerController.UpdateTimer(timer);
         reset = false;
         return;
     }
     else
     {
         if (!MyTimer.watch.IsRunning)
         {
             TimerController.StartTimer(time);
         }
         if (textBox.Text.Length == sampleText.Text.Length)
         {
             TimerController.StopTimer(time);
             TextBoxController.SetReadOnly(textBox, true);
             WordPerMinController.UpdateWordPerMin(textBox, wordPerMin, wordPerMinLabel);
             accuracyController.UpdateErrorPercentage(accuracy, textBox, sampleText);
         }
     }
 }