private void RunExercise() { if (CurrentExercise == null) { //We completed the session. //MessageBox.Show("Session Complete. Press ESC or F11 to exit picture viewer.", "Session Complete", MessageBoxButtons.OK); string inf = "Session Complete. Press ESC or F11 to exit picture viewer."; Globals.MainForm.PictureViewerForm.ShowLocalMessage(inf); Stop(); OnSessionEnd?.Invoke(); } else { //invoke a first tick to start the current exercise. NextCard(); //This is now called (once) by the start exercise routine // OnExerciseStart?.Invoke(); //Start the timer for subsequent Exercises. ExerciseTimer.Stop(); TotalExerciseTimeMillis = (int)CurrentExercise.Duration.TotalMilliseconds; ExerciseTimer.Interval = TotalExerciseTimeMillis; ResumeTimeMillis = Environment.TickCount; EndTimeMillis = ResumeTimeMillis + ExerciseTimer.Interval; UpdateDurationRemaining(); PlayState = PlayState.Playing; ExerciseTimer.Start(); //Call the lambda out to the controlling view that sets the picture. OnExerciseStart?.Invoke(); } }
public void Pause() { ElapsedSinceRunMillis += Environment.TickCount - ResumeTimeMillis; PlayState = PlayState.Paused; ExerciseTimer.Stop(); UpdateDurationRemaining(); }
private void ResetState() { PlayState = PlayState.Stopped; ExerciseTimer.Stop(); Cards.Clear(); CardIndex = 0; CurrentCard = null; ResumeTimeMillis = 0; EndTimeMillis = 0; TotalExerciseTimeMillis = 0; CurrentExerciseIndex = 0; ElapsedSinceRunMillis = 0; }