protected override async void OnNavigatedTo(NavigationEventArgs e) { var exerciseId = ExerciseParams.exerciseId; // Timer App.workoutTimer.Tick += dispatcherTimer_Tick; if (m_numberOfSets == 0 || ExerciseParams.startNewExercise) { m_currentExercise = await App.DefaultExercisesTable.LookupAsync(exerciseId); switch (MainDashboard.CurrentUser.PreferredTrainingProgramDifficulty) { case Difficulty.Begginer: m_numberOfSets = m_currentExercise.BegginerSets; m_weight = m_currentExercise.BegginerWeight; break; case Difficulty.Intermediate: m_numberOfSets = m_currentExercise.IntermediateSets; m_weight = m_currentExercise.IntermediateWeight; break; case Difficulty.Expert: m_numberOfSets = m_currentExercise.ExpertSets; m_weight = m_currentExercise.ExpertWeight; break; default: m_numberOfSets = m_currentExercise.BegginerSets; m_weight = m_currentExercise.BegginerWeight; break; } m_numberOfSetsRemainedToPerform = m_numberOfSets; ExerciseParams.startNewExercise = false; } if (m_currentExercise == null) { m_currentExercise = await App.DefaultExercisesTable.LookupAsync(exerciseId); } if (ExerciseParams.isSetFinished) { m_numberOfSetsRemainedToPerform--; ExerciseParams.isSetFinished = false; } if (m_numberOfSetsRemainedToPerform <= 0) { StartSet.IsEnabled = false; StartSet.Visibility = Visibility.Collapsed; RemainSets.Text = "Done"; RemainSets.FontSize = 30; WorkoutParams.isFinishedExercise = true; } else { StartSet.IsEnabled = true; StartSet.Visibility = Visibility.Visible; RemainSets.Text = m_numberOfSetsRemainedToPerform.ToString() + " Sets remain * " + m_weight + " Kg"; RemainSets.FontSize = 20; } ExerciseName.Text = m_currentExercise.Name; // Calories _caloriesModel.Init(); _caloriesModel.Changed += _caloriesModel_Changed; _caloriesModel.Start(); ShowGuid.IsEnabled = true; FinishExercise.IsEnabled = true; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { Finish.IsEnabled = true; WorkoutDetails.IsEnabled = true; var workoutId = WorkoutParams.workoutId; if (WorkoutParams.resetTimer == true) { App.workoutTimer = new DispatcherTimer(); App.workoutTimer.Interval = new TimeSpan(0, 0, 1); App.startTime = DateTimeOffset.Now; App.workoutTimer.Start(); CaloriesModel.startCalories = -1; CaloriesModel.calories = 0; HeartRateModel.count = 0; HeartRateModel.sum = 0; HeartRateModel.peak = 0; WorkoutParams.resetTimer = false; } App.workoutTimer.Tick += dispatcherTimer_Tick; if (WorkoutParams.startNewWorkout || currentWorkout == null) { currentWorkout = await App.DefaultWorkoutsTable.LookupAsync(workoutId); m_nextExrciseIndex = 0; WorkoutParams.startNewWorkout = false; } if (WorkoutParams.isFinishedExercise) { m_nextExrciseIndex++; ExerciseParams.startNewExercise = true; WorkoutParams.isFinishedExercise = false; } ExersiceIds = currentWorkout.ExercisesIds.Split(';').ToList(); if (m_nextExrciseIndex >= ExersiceIds.Count()) { StartExercise.IsEnabled = false; StartExercise.Visibility = Visibility.Collapsed; NextEx.Text = "Done"; NextEx.FontSize = 30; } else { StartExercise.IsEnabled = true; StartExercise.Visibility = Visibility.Visible; NextEx.FontSize = 20; var fireAndForget = calculateNextExName(m_nextExrciseIndex); } // Calories await BandModel.InitAsync(); _caloriesModel.Init(); _caloriesModel.Changed += _caloriesModel_Changed; _caloriesModel.Start(); }