private void mnuUserExercise_Click(object sender, RoutedEventArgs e) { var item = (StrengthTrainingItemViewModel)(sender as FrameworkElement).DataContext; List <StrengthTrainingItemDTO> itemsToCopy = new List <StrengthTrainingItemDTO>(); if (Settings.TreatSuperSetsAsOne && !string.IsNullOrEmpty(item.Item.SuperSetGroup)) {//if we should treat superset as one then when we copy one exercise which is a part of superset then we should copy all of them itemsToCopy.AddRange(item.Item.StrengthTrainingEntry.Entries.Where(x => x.SuperSetGroup == item.Item.SuperSetGroup).OrderBy(x => x.Position)); } else { itemsToCopy.Add(item.Item); } foreach (var itemDto in itemsToCopy) { var newItem = itemDto.Copy(true); TrainingBuilder builder = new TrainingBuilder(); builder.PrepareCopiedStrengthTraining(newItem, Settings.CopyStrengthTrainingMode); builder.SetPreviewSets(itemDto, newItem); Entry.AddEntry(newItem); } //_viewModel.AddExercise(item.Item.Exercise); lblNoExercises.Visibility = Entry.Entries.Count == 0? System.Windows.Visibility.Visible: System.Windows.Visibility.Collapsed; StrengthWorkoutViewModel.ResetPositions(Entry); show(true); pivot.SelectedIndex = 0; }
protected override void PrepareCopiedEntry(EntryObjectDTO origEntry, EntryObjectDTO entry) { StrengthTrainingEntryDTO strength = entry as StrengthTrainingEntryDTO; if (strength != null) { var oldStrength = (StrengthTrainingEntryDTO)origEntry; copyStrengthTrainingProperties(strength, oldStrength); TrainingBuilder builder = new TrainingBuilder(); builder.PrepareCopiedStrengthTraining(strength, Settings.CopyStrengthTrainingMode); builder.SetPreviewSets(oldStrength, strength); } }
private void fillStrengthTrainingEntryWithPlan(TrainingPlanDay planDay) { if (ApplicationState.Current.CurrentBrowsingTrainingDays.IsMine) { if (!EntryObjectPageBase.EnsureRemoveEntryTypeFromToday(typeof(StrengthTrainingEntryDTO))) {//cancel overwrite return; } var strengthTraining = new StrengthTrainingEntryDTO(); strengthTraining.StartTime = DateTime.Now; ApplicationState.Current.TrainingDay.TrainingDay.Objects.Add(strengthTraining); strengthTraining.TrainingDay = ApplicationState.Current.TrainingDay.TrainingDay; ApplicationState.Current.CurrentEntryId = new LocalObjectKey(strengthTraining); TrainingBuilder builder = new TrainingBuilder(); builder.FillTrainingFromPlan(planDay, strengthTraining); //apply setting related with copy sets data builder.PrepareCopiedStrengthTraining(strengthTraining, Settings.CopyStrengthTrainingMode); this.GetParent <PhoneApplicationPage>().Navigate("/Pages/StrengthWorkoutPage.xaml"); } }
protected override void copyAllImplementation(EntryObjectDTO oldEntry) { if (oldEntry != null) { //var copyDay = oldDay.TrainingDay.StrengthWorkout.Copy(true); //PrepareCopiedEntry(oldDay.TrainingDay.StrengthWorkout,copyDay); var itemsToCopy = lstOldItems.SelectedItems.Cast <StrengthTrainingItemViewModel>().Select(x => x.Item).ToList(); var strength = Entry; var oldStrength = (StrengthTrainingEntryDTO)oldEntry; copyStrengthTrainingProperties(strength, oldStrength); TrainingBuilder builder = new TrainingBuilder(); foreach (var itemDto in itemsToCopy) { var newItem = itemDto.Copy(true); builder.PrepareCopiedStrengthTraining(newItem, Settings.CopyStrengthTrainingMode); if (Settings.CopyStrengthTrainingMode != CopyStrengthTrainingMode.OnlyExercises) { builder.SetPreviewSets(itemDto, newItem); } strength.AddEntry(newItem); } builder.CleanSingleSupersets(Entry); StrengthWorkoutViewModel.ResetPositions(Entry); show(true); lblNoExercises.Visibility = Entry.Entries.Count == 0? System.Windows.Visibility.Visible: System.Windows.Visibility.Collapsed; } }