protected override async void OnAppearing() { base.OnAppearing(); BindingContext = ViewModel; // set Text PlateWeightLabel.Text = string.Format(AppResources.PlateWeightLabel, L10n.GetWeightUnit()); var dayNames = AppResources.Culture.DateTimeFormat.DayNames; MonLabel.Text = dayNames[1]; TueLabel.Text = dayNames[2]; WedLabel.Text = dayNames[3]; ThuLabel.Text = dayNames[4]; FriLabel.Text = dayNames[5]; SatLabel.Text = dayNames[6]; SunLabel.Text = dayNames[0]; // setup delete toolbar item var deleteItem = ToolbarItems.FirstOrDefault(x => x.Icon == "ic_action_discard"); if (ViewModel.ExerciseId > 0 && deleteItem == null) { deleteItem = new ToolbarItem { Order = ToolbarItemOrder.Primary, Icon = "ic_action_discard" }; deleteItem.SetBinding <ExerciseDetailsViewModel> (MenuItem.CommandProperty, x => x.DeleteCommand); ToolbarItems.Insert(0, deleteItem); } }
private string GetTotalWeight(Exercise exercise) { var total = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).Sum(x => x.Weight); return($"{WeightMetricToImperialConverter.GetWeight(total)} {L10n.GetWeightUnit()}"); }
private string GetWeightIncreases(Exercise exercise) { var weights = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId) .GroupBy(x => x.Weight).Select(x => x.First().Weight).ToList(); weights.Sort(); if (weights.Count == 0) { return("0"); } var convertedWeights = new List <string> (); foreach (var weight in weights) { convertedWeights.Add($"{WeightMetricToImperialConverter.GetWeight(weight)} {L10n.GetWeightUnit()}"); } return($"{weights.Count} ({string.Join(", ", convertedWeights)})"); }
private string GetLastTargetWorkout(Exercise exercise) { var workout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).LastOrDefault(); if (workout == null) { return(string.Empty); } if ((workout.TargetReps > 0) && (workout.TargetWeight > 0)) { return ($"{workout.TargetReps} Reps {WeightMetricToImperialConverter.GetWeight(workout.TargetWeight)} {L10n.GetWeightUnit()}"); } return(string.Empty); }
private string GetCurrentWeight(Exercise exercise) { var lastWorkout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).LastOrDefault(); if (lastWorkout == null) { return(string.Empty); } return($"{WeightMetricToImperialConverter.GetWeight(lastWorkout.Weight)} {L10n.GetWeightUnit()}"); }
private string GetStarted(Exercise exercise) { var workout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).FirstOrDefault(); if (workout == null) { return(string.Empty); } return ($"{workout.Created:d}, {workout.Reps} Reps {WeightMetricToImperialConverter.GetWeight(workout.Weight)} {L10n.GetWeightUnit()}"); }
private void BuildRepsPerWorkout() { var data = from w in Workouts group w by w.ExerciseId into workoutsPerExercise from nestedGroup in ( from a in workoutsPerExercise group a by a.Weight ) group nestedGroup by workoutsPerExercise.Key; var list = new List <PlotView>(); foreach (var exerciseGroup in data) { var exercise = Exercises.FirstOrDefault(x => x.ExerciseId == exerciseGroup.Key); var plotModel = new PlotModel { Title = exercise.Name, Background = OxyColors.LightYellow, PlotAreaBackground = OxyColors.LightGray, }; var count = 0; foreach (var weightGroup in exerciseGroup) { var series = new LineSeries { Title = $"{WeightMetricToImperialConverter.GetWeightAsDouble(weightGroup.Key)} {L10n.GetWeightUnit()}" }; plotModel.Series.Add(series); var weightData = new List <DataPoint>(); foreach (var workout in weightGroup) { weightData.Add(new DataPoint(DateTimeAxis.ToDouble(workout.Created), workout.Reps)); count++; } series.ItemsSource = weightData; } var dateAxis = GetDateTimeAxis(count); plotModel.Axes.Add(dateAxis); var valueAxis = new LinearAxis { Position = AxisPosition.Left, MinimumPadding = 0, Title = "Resps" }; plotModel.Axes.Add(valueAxis); var plotView = new PlotView { HeightRequest = 300, Model = plotModel, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill }; list.Add(plotView); } _messagingService.Send(this, Messages.ChartBuilt, list); }