예제 #1
0
        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;
        }
예제 #2
0
 private void lsItems_ListReordered(object sender, ListReorderedEventArgs e)
 {
     Entry.Entries.RemoveAt(e.FromIndex);
     Entry.Entries.Insert(e.ToIndex, ((StrengthTrainingItemViewModel)e.Object).Item);
     StrengthWorkoutViewModel.ResetPositions(Entry);
     _viewModel.Refresh();
 }
예제 #3
0
        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;
            }
        }