private void AddRepAction() { try { int previousRep = 0; double previousWeight = 0; if (BindingTrainingExerciseSetReps.Count > 0) { previousRep = BindingTrainingExerciseSetReps[BindingTrainingExerciseSetReps.Count - 1].Reps; previousWeight = BindingTrainingExerciseSetReps[BindingTrainingExerciseSetReps.Count - 1].Weights; } foreach (var bindingSetRep in BindingTrainingExerciseSetReps) { if (bindingSetRep.BtnPlusVisible) { bindingSetRep.BtnPlusVisible = false; } } BindingTrainingExerciseSetReps.Add(new BindingTrainingExerciseSetRep() { Reps = previousRep, Weights = previousWeight, BtnPlusVisible = true, RepsLabel = string.Empty, // necessary for trigger Text.Length WeightsLabel = string.Empty // necessary for trigger Text.Length }); } catch (Exception except) { ILogger.Instance.Error("Unable to add rep in training exercise", except); } }
private void DeleteRepAction(BindingTrainingExerciseSetRep bindingTrainingExerciseSetRep) { if (bindingTrainingExerciseSetRep == null) { return; } try { if (BindingTrainingExerciseSetReps.Count > 0 && BindingTrainingExerciseSetReps.IndexOf(bindingTrainingExerciseSetRep) != -1) { BindingTrainingExerciseSetReps.Remove(bindingTrainingExerciseSetRep); if (BindingTrainingExerciseSetReps.Count > 0) { BindingTrainingExerciseSetReps[BindingTrainingExerciseSetReps.Count - 1].BtnPlusVisible = true; } } } catch (Exception except) { ILogger.Instance.Error("Unable to supress rep in training exercise", except); } }
private async Task SynchronizeDataAsync() { var unit = await GetExerciseUnit(); string weightUnit = "kg"; if (unit == TUnitType.Imperial) { weightUnit = Translation.Get(TRS.POUND); } ExerciseTitle = Translation.GetInDB(BodyExerciseTransformer.GetTranslationKey(_trainingExercise.BodyExerciseId)); RestTime = _trainingExercise.RestTime; EccentricContractionTempo = _trainingExercise.EccentricContractionTempo; StretchPositionTempo = _trainingExercise.StretchPositionTempo; ConcentricContractionTempo = _trainingExercise.ConcentricContractionTempo; ContractedPositionTempo = _trainingExercise.ContractedPositionTempo; string urlImages = HttpConnector.Instance.BaseUrl + "images/bodyexercises/{0}"; var imageName = string.Format("{0}.png", _trainingExercise.BodyExerciseId); var urlImage = string.Format(urlImages, imageName); var localImagePath = Path.Combine(AppTools.BodyExercisesImagesDirectory, imageName); await AppTools.Instance.CachingImageAsync(_trainingExercise, urlImage, localImagePath, null); ExerciseImageSource = localImagePath; if (BindingTrainingExerciseSetReps == null) { BindingTrainingExerciseSetReps = new ObservableCollection <BindingTrainingExerciseSetRep>(); } else { BindingTrainingExerciseSetReps.Clear(); } if (_trainingExercise != null) { BindingTrainingExerciseSetRep bindingSetRep; if (_trainingExercise.TrainingExerciseSets == null || _trainingExercise.TrainingExerciseSets.Count == 0) { bindingSetRep = new BindingTrainingExerciseSetRep(); bindingSetRep.RepsLabel = Translation.Get(TRS.REPS); bindingSetRep.WeightsLabel = Translation.Get(TRS.WEIGHT) + "(" + weightUnit + ")"; bindingSetRep.Reps = 8; bindingSetRep.Weights = 0; BindingTrainingExerciseSetReps.Add(bindingSetRep); } else { int count = 0; foreach (var trainingExerciseSet in _trainingExercise.TrainingExerciseSets) { for (int i = 0; i < trainingExerciseSet.NumberOfSets; i++) { bindingSetRep = new BindingTrainingExerciseSetRep(); if (count == 0) { bindingSetRep.RepsLabel = Translation.Get(TRS.REPS); bindingSetRep.WeightsLabel = Translation.Get(TRS.WEIGHT) + "(" + weightUnit + ")"; } else { bindingSetRep.RepsLabel = bindingSetRep.WeightsLabel = string.Empty; // necessary for trigger Text.Length } bindingSetRep.Reps = trainingExerciseSet.NumberOfReps; bindingSetRep.Weights = trainingExerciseSet.Weight; BindingTrainingExerciseSetReps.Add(bindingSetRep); count++; } } } if (BindingTrainingExerciseSetReps.Count > 0) { BindingTrainingExerciseSetReps[BindingTrainingExerciseSetReps.Count - 1].BtnPlusVisible = true; } } }