/// <summary> /// Thumb drag completed event handler /// </summary> private void MoveThumbDragCompleted(object sender, DragCompletedEventArgs e) { if (this.DataContext is BaseQuestionViewModel) { // move question BaseQuestionViewModel questionViewModel = (BaseQuestionViewModel)this.DataContext; double deltaTop = this.startTop - questionViewModel.Top; double deltaLeft = this.startLeft - questionViewModel.Left; if (Math.Abs(deltaTop) > 0.01 || Math.Abs(deltaLeft) > 0.01) { if (questionViewModel.ParentTemplate != null) { // moving choicebox question, check all other selected questions List <BaseQuestionViewModel> selectedItems = questionViewModel.ParentTemplate.SelectedElements.ToList(); ActionTracker.TrackChangeQuestionsPosition(selectedItems, deltaTop, deltaLeft, 1, 1); if (questionViewModel.ParentTemplate.GotSnapLines) { questionViewModel.ParentTemplate.CleanSnapLines(); } } else if (questionViewModel is ChoiceBoxViewModel) { if (((ChoiceBoxViewModel)questionViewModel).ParentGrid != null) { // moving choicebox child of grid question ActionTracker.TrackChangeQuestionsPosition(new List <BaseQuestionViewModel>() { questionViewModel }, deltaTop, deltaLeft, 1, 1); } } } if (questionViewModel.ParentTemplate != null) { if (questionViewModel.ParentTemplate.GotSnapLines) { questionViewModel.ParentTemplate.CleanSnapLines(); } } } else if (this.DataContext is BubbleViewModel) { // move bubble BubbleViewModel bubbleViewModel = (BubbleViewModel)this.DataContext; double deltaTop = this.bubbleStartTop - bubbleViewModel.Top; double deltaLeft = this.bubbleStartLeft - bubbleViewModel.Left; if (Math.Abs(deltaTop) > 0.01 || Math.Abs(deltaLeft) > 0.01) { ActionTracker.TrackChangeBubble(new List <BubbleViewModel> { bubbleViewModel }, deltaTop, deltaLeft, 1, 1); } } }
/// <summary> /// Thumb drag completed event handler /// </summary> private void ResizeThumbDragCompleted(object sender, DragCompletedEventArgs e) { if (this.DataContext is BaseQuestionViewModel) { // resize question BaseQuestionViewModel questionViewModel = (BaseQuestionViewModel)this.DataContext; double deltaTop = this.startTop - questionViewModel.Top; double deltaLeft = this.startLeft - questionViewModel.Left; double widthKoef = this.startWidth / questionViewModel.Width; double heightKoef = this.startHeight / questionViewModel.Height; if (questionViewModel.ParentTemplate != null) { List<BaseQuestionViewModel> selectedItems = questionViewModel.ParentTemplate.SelectedElements.ToList(); ActionTracker.TrackChangeQuestionsPosition(selectedItems, deltaTop, deltaLeft, widthKoef, heightKoef); } else if (questionViewModel is ChoiceBoxViewModel) { var choiceBoxViewModel = (ChoiceBoxViewModel) questionViewModel; List<BaseQuestionViewModel> selectedItems = choiceBoxViewModel.ParentGrid.ChoiceBoxes .Cast<BaseQuestionViewModel>() .ToList(); ActionTracker.TrackChangeQuestionsPosition(selectedItems, deltaTop, deltaLeft, widthKoef, heightKoef); } } else if (this.DataContext is BubbleViewModel) { // resize bubble BubbleViewModel bubbleViewModel = (BubbleViewModel)this.DataContext; List<BubbleViewModel> bubbles = bubbleViewModel.ParentQuestion.Bubbles.ToList(); double deltaTop = this.bubbleStartTop - bubbles[0].Top; double deltaLeft = this.bubbleStartLeft - bubbles[0].Left; double widthKoef = this.bubbleStartWidth / bubbles[0].Width; double heightKoef = this.bubbleStartHeight / bubbles[0].Height; ActionTracker.TrackChangeBubble(bubbles, deltaTop, deltaLeft, widthKoef, heightKoef); } }