Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        public static void SetExerciseTimer(System.Windows.Forms.Label label)
        {
            //Swaps a winforms label with an exercisetimer class.
            ExerciseTimer et = new ExerciseTimer();

            Globals.SwapControl(label, et);
            et.Font      = label.Font;
            et.ForeColor = label.ForeColor;
        }
Beispiel #3
0
        public void Pause()
        {
            ElapsedSinceRunMillis += Environment.TickCount - ResumeTimeMillis;

            PlayState = PlayState.Paused;
            ExerciseTimer.Stop();

            UpdateDurationRemaining();
        }
Beispiel #4
0
        private void ResetState()
        {
            PlayState = PlayState.Stopped;
            ExerciseTimer.Stop();

            Cards.Clear();
            CardIndex               = 0;
            CurrentCard             = null;
            ResumeTimeMillis        = 0;
            EndTimeMillis           = 0;
            TotalExerciseTimeMillis = 0;
            CurrentExerciseIndex    = 0;
            ElapsedSinceRunMillis   = 0;
        }
Beispiel #5
0
        public void Resume()
        {
            if (PlayState == PlayState.Paused)
            {
                PlayState = PlayState.Playing;
                ExerciseTimer.Start();

                ResumeTimeMillis = Environment.TickCount;
                EndTimeMillis    = ResumeTimeMillis + DurationRemaining;

                OnExerciseStart?.Invoke();
            }
            else
            {
                Globals.LogError("Error - play state was not paused before Resume() called.");
            }
        }