public void BuildTimer(Workout workout) { // Summary // // Takes a workout and builds a stack of timer stations with each station repersenting // an exercise or rest. if (workout.Stations.Count == 0) { throw new ArgumentNullException(nameof(workout)); } _timeStack.Clear(); int numStations = workout.Stations.Count; int stationReps = workout.StationReps; int exercisesPerStation = workout.Stations[0].Exercises.Count; // Add 10s countdown for start of workout _timeStack.Add(new TimerStation { ExerciseName = "Get Ready", Description = "Up Next: " + workout.Stations[0].Exercises[0].ExerciseName, ExerciseNumber = "--", RoundNumber = "--", StationNumber = "--", Time = TimeSpan.FromSeconds(10) }); // Looping through Stations for (int i = 0; i < numStations; i++) { // Looping through Reps per Station for (int j = 0; j < stationReps; j++) { // Looing through Exercises for (int k = 0; k < exercisesPerStation; k++) { // Add Exercise _timeStack.Add(new TimerStation { ExerciseName = workout.Stations[i].Exercises[k].ExerciseName, Description = workout.Stations[i].Exercises[k].Description, ExerciseNumber = (k + 1).ToString() + @" / " + exercisesPerStation.ToString(), RoundNumber = (j + 1).ToString() + @" / " + stationReps.ToString(), StationNumber = (i + 1).ToString() + @" / " + numStations.ToString(), Time = TimeSpan.FromSeconds(workout.RepSeconds) }); //System.Diagnostics.Debug.WriteLine(_timeStack[^1].ExerciseName); // Add Rep Rest unless about to add a Station Rest // Need to add 1 to avoid off-by-1 error since indices start at 0 & have to stop 1 early if (((k + 1) == exercisesPerStation) && ((j + 1) == stationReps)) { break; } _timeStack.Add(new TimerStation { ExerciseName = "Rest", Description = "Up Next: " + workout.Stations[i].Exercises[(k + 1) % exercisesPerStation].ExerciseName, ExerciseNumber = (k + 1).ToString() + @" / " + exercisesPerStation.ToString(), RoundNumber = (j + 1).ToString() + @" / " + stationReps.ToString(), StationNumber = (i + 1).ToString() + @" / " + numStations.ToString(), Time = TimeSpan.FromSeconds(workout.RestSeconds) }); //System.Diagnostics.Debug.WriteLine(_timeStack[^1].ExerciseName + " - " + _timeStack[^1].Description); } } // Add Station Rest unless workout is over // Need to add 1 to avoid off-by-1 error since indices start at 0 & have to stop 1 early if ((i + 1) == numStations) { break; } _timeStack.Add(new TimerStation { ExerciseName = "Rest", Description = "Up Next: " + workout.Stations[i + 1].Exercises[0].ExerciseName, ExerciseNumber = "--", RoundNumber = "--", StationNumber = "--", Time = TimeSpan.FromSeconds(workout.SetSeconds) }); //System.Diagnostics.Debug.WriteLine(_timeStack[^1].ExerciseName + " - " + _timeStack[^1].Description); } // Set TimeToGo to total workout length. Clear first TimeElapsed = TimeSpan.Zero; TimeToGo = Workout.GenerateLength(workout); }
public Record(Workout workout) { Date = DateTime.Today; Workout = workout; }