Esempio n. 1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            var parameters = (WorkoutDetailsParams)e.Parameter;

            m_trainingProgram = parameters.trainingProgram;
            m_workout         = parameters.workout;

            var tasks = new List <Task <DefaultExercise> >();


            var exerciseIds = m_workout.ExercisesIds.Split(';').ToList();

            ObservableCollection <string> listItems = new ObservableCollection <string>();


            foreach (var id in exerciseIds)
            {
                tasks.Add(App.DefaultExercisesTable.LookupAsync(id));
            }

            var results = (await Task.WhenAll(tasks)).ToList();

            foreach (var result in results)
            {
                var ex = await App.DefaultExercisesTable.LookupAsync(result.Id);

                m_exercises.Add(ex);

                listItems.Add(ex.Name);
            }

            exercisesList.ItemsSource = listItems;
        }
Esempio n. 2
0
 public SetParams(DefaultWorkout currentWorkout, int currentExerciseIndex, DefaultExercise exercise, int numbrtOfSetsRemained)
 {
     CurrentWorkout            = currentWorkout;
     this.currentExerciseIndex = currentExerciseIndex;
     Exercise = exercise;
     this.numbrtOfSetsRemained = numbrtOfSetsRemained;
 }
Esempio n. 3
0
 public MainDashboardParams(User user, DefaultWorkout currentWorkout, bool isCurrentWorkoutFinished)
     : this(user)
 {
     CurrentWorkout           = currentWorkout;
     IsCurrentWorkoutFinished = isCurrentWorkoutFinished;
 }
        private async void workoutList_ItemClickAsync(object sender, ItemClickEventArgs e)
        {
            string item      = (string)e.ClickedItem;
            string workoutId = trainingProgram.SundayWorkoutId;

            switch (item)
            {
            case "Sunday workout":
                workoutId = trainingProgram.SundayWorkoutId;
                break;

            case "Monday workout":
                workoutId = trainingProgram.MondayWorkoutId;
                break;

            case "Tuesday workout":
                workoutId = trainingProgram.TuesdayWorkoutId;
                break;

            case "Wednesday workout":
                workoutId = trainingProgram.WednesdayWorkoutId;
                break;

            case "Thursday workout":
                workoutId = trainingProgram.ThursdayWorkoutId;
                break;

            case "Friday workout":
                workoutId = trainingProgram.FridayWorkoutId;
                break;

            case "Saturday workout":
                workoutId = trainingProgram.SaturdayWorkoutId;
                break;
            }

            var parameters = new WorkoutDetailsParams(workoutId, trainingProgram);

            var tasks = new List <Task <DefaultExercise> >();

            m_workout = parameters.workout;

            if (parameters.workout == null)
            {
                m_workoutId = parameters.workoutId;
                m_workout   = await App.DefaultWorkoutsTable.LookupAsync(m_workoutId);
            }

            trainingProgram = parameters.trainingProgram;

            var exerciseIds = m_workout.ExercisesIds.Split(';').ToList();

            ObservableCollection <string> listItems = new ObservableCollection <string>();


            foreach (var id in exerciseIds)
            {
                tasks.Add(App.DefaultExercisesTable.LookupAsync(id));
            }

            var results = (await Task.WhenAll(tasks)).ToList();

            foreach (var result in results)
            {
                var ex = await App.DefaultExercisesTable.LookupAsync(result.Id);

                m_exercises.Add(ex);

                listItems.Add(ex.Name);
            }

            exercisesList.ItemsSource = listItems;
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var workoutId = UserWorkoutStaticsParams.WorkoutId;

            m_workout = await App.DefaultWorkoutsTable.LookupAsync(workoutId);

            if (UserWorkoutStaticsParams.Myself)
            {
                Title.Text          = "Previous Workouts Statistics";
                m_workoutStatistics = App.UserWorkoutStatistics.FindAll(stat => stat.UserId.Equals(MainDashboard.CurrentUser.Id) && stat.WorkoutId.Equals(workoutId));
                m_workoutStatistics.Sort(delegate(UserWorkoutStatistics x, UserWorkoutStatistics y)
                {
                    return((int)(x.PerformanceNumberCount - y.PerformanceNumberCount));
                });
            }
            else
            {
                Title.Text          = "Other Trainers Statistics";
                m_workoutStatistics = App.UserWorkoutStatistics.FindAll(stat => !stat.UserId.Equals(MainDashboard.CurrentUser.Id) && stat.WorkoutId.Equals(workoutId));
                m_workoutStatistics.Sort(delegate(UserWorkoutStatistics x, UserWorkoutStatistics y)
                {
                    return((int)(x.PerformanceNumberCount - y.PerformanceNumberCount));
                });
                int max = m_workoutStatistics.ElementAt(m_workoutStatistics.Count - 1).PerformanceNumberCount;
                List <UserWorkoutStatistics> averageStatistics = new List <UserWorkoutStatistics>();

                for (int i = 1; i <= max; i++)
                {
                    List <UserWorkoutStatistics> statisticsForIndex = m_workoutStatistics.FindAll(stat => stat.PerformanceNumberCount == i);
                    if (statisticsForIndex.Count() != 0)
                    {
                        UserWorkoutStatistics averageStatisticsForIndex = new UserWorkoutStatistics();
                        averageStatisticsForIndex.PerformanceTimeAvarage  = Utils.CalculatePrevWorkoutsPerformanceTimeAverage(statisticsForIndex);
                        averageStatisticsForIndex.GeneralColumn1          = Utils.CalculatePrevWorkoutsExNumAverage(statisticsForIndex);
                        averageStatisticsForIndex.HeartReatAvarage        = Utils.CalculatePrevWorkoutsAverageHeartRateAverage(statisticsForIndex);
                        averageStatisticsForIndex.MaximalHeartRateAvarage = Utils.CalculatePrevWorkoutsPeakHeartRateAverage(statisticsForIndex);
                        averageStatisticsForIndex.CaloriesBurnedAvarage   = Utils.CalculatePrevWorkoutsCaloriesAverage(statisticsForIndex);
                        averageStatistics.Add(averageStatisticsForIndex);
                    }
                }

                m_workoutStatistics = averageStatistics;
            }

            if (m_workoutStatistics.Count == 0)
            {
                var dialog = new MessageDialog("No statistics found");
                dialog.Commands.Add(new UICommand("Return"));
                await dialog.ShowAsync();

                Frame rootFrame = Window.Current.Content as Frame;
                rootFrame.GoBack();
            }
            else
            {
                TimeSpan span = TimeSpan.FromMinutes(Utils.CalculatePrevWorkoutsPerformanceTimeAverage(m_workoutStatistics));

                Time.Text            += span.ToString(@"hh\:mm");
                NumOfEx.Text         += Utils.CalculatePrevWorkoutsExNumAverage(m_workoutStatistics).ToString() + "/" + (m_workout.ExercisesIds.Split(';').Count());
                heartRate.Text       += Utils.CalculatePrevWorkoutsAverageHeartRateAverage(m_workoutStatistics);
                peak_heart_rate.Text += Utils.CalculatePrevWorkoutsPeakHeartRateAverage(m_workoutStatistics);
                calories.Text        += Utils.CalculatePrevWorkoutsCaloriesAverage(m_workoutStatistics);

                List <Records> timeRecords = new List <Records>();
                for (int i = 0; i < m_workoutStatistics.Count; i++)
                {
                    timeRecords.Add(new Records()
                    {
                        Name = "" + (i + 1), Amount = (int)m_workoutStatistics.ElementAt(i).PerformanceTimeAvarage
                    });
                }

                List <Records> exercisesAmountRecords = new List <Records>();
                for (int i = 0; i < m_workoutStatistics.Count; i++)
                {
                    exercisesAmountRecords.Add(new Records()
                    {
                        Name = "" + (i + 1), Amount = (int)(m_workoutStatistics.ElementAt(i).GeneralColumn1 / (m_workout.ExercisesIds.Split(';').Count()) * 100)
                    });
                }

                List <Records> heartRatesRecords = new List <Records>();
                for (int i = 0; i < m_workoutStatistics.Count; i++)
                {
                    heartRatesRecords.Add(new Records()
                    {
                        Name = "" + (i + 1), Amount = (int)m_workoutStatistics.ElementAt(i).HeartReatAvarage
                    });
                }

                List <Records> peakHeartRatesRecords = new List <Records>();
                for (int i = 0; i < m_workoutStatistics.Count; i++)
                {
                    peakHeartRatesRecords.Add(new Records()
                    {
                        Name = "" + (i + 1), Amount = (int)m_workoutStatistics.ElementAt(i).MaximalHeartRateAvarage
                    });
                }

                (LineChart.Series[0] as LineSeries).ItemsSource = timeRecords;
                (LineChart.Series[1] as LineSeries).ItemsSource = exercisesAmountRecords;
                (LineChart.Series[2] as LineSeries).ItemsSource = heartRatesRecords;
                (LineChart.Series[3] as LineSeries).ItemsSource = peakHeartRatesRecords;
            }
        }
Esempio n. 6
0
 public WorkoutDetailsParams(DefaultWorkout workout, UserTrainingProgram trainingProgram)
 {
     this.workout         = workout;
     this.trainingProgram = trainingProgram;
 }