예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Thumb drag started event handler
        /// </summary>
        private void ResizeThumbDragStarted(object sender, DragStartedEventArgs e)
        {
            if (this.DataContext is BaseQuestionViewModel)
            {
                // resize question
                BaseQuestionViewModel questionViewModel = (BaseQuestionViewModel)this.DataContext;

                // remember starting top and left position for measuring delta when drag is completed
                this.startWidth = questionViewModel.Width;
                this.startHeight = questionViewModel.Height;
                this.startTop = questionViewModel.Top;
                this.startLeft = questionViewModel.Left;
            }
            else if (this.DataContext is BubbleViewModel)
            {
                // resize bubble
                BubbleViewModel bubbleViewModel = (BubbleViewModel)this.DataContext;
                BubbleViewModel bubble = bubbleViewModel.ParentQuestion.Bubbles[0];

                this.bubbleStartWidth = bubble.Width;
                this.bubbleStartHeight = bubble.Height;
                this.bubbleStartTop = bubble.Top;
                this.bubbleStartLeft = bubble.Left;
            }
        }
 private void ChangeOriginalQuestions(int i, BaseQuestionViewModel ethalonQuestion)
 {
     if (this.questions[i] is ChoiceBoxViewModel)
     {
         ChoiceBoxViewModel choiceBox = (ChoiceBoxViewModel)this.questions[i];
         ChoiceBoxViewModel target    = (ChoiceBoxViewModel)ethalonQuestion;
         this.ApplyChanges(choiceBox, target);
     }
     else if (this.questions[i] is GridViewModel)
     {
         GridViewModel grid   = (GridViewModel)this.questions[i];
         GridViewModel target = (GridViewModel)ethalonQuestion;
         this.ApplyChanges(grid, target);
     }
 }
예제 #4
0
 /// <summary>
 /// Thumb drag started event handler
 /// </summary>
 private void MoveThumbDragStarted(object sender, DragStartedEventArgs e)
 {
     if (this.DataContext is BaseQuestionViewModel)
     {
         // move question
         BaseQuestionViewModel questionViewModel = (BaseQuestionViewModel)this.DataContext;
         this.startTop  = questionViewModel.Top;
         this.startLeft = questionViewModel.Left;
     }
     else if (this.DataContext is BubbleViewModel)
     {
         // move bubble
         BubbleViewModel bubbleViewModel = (BubbleViewModel)this.DataContext;
         this.bubbleStartTop  = bubbleViewModel.Top;
         this.bubbleStartLeft = bubbleViewModel.Left;
     }
 }
예제 #5
0
        /// <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);
            }
        }
        /// <summary>
        /// Tracks apply formatting action
        /// </summary>
        /// <param name="trackedElements">Changed questions</param>
        /// <param name="copiesBefore">Copies of questions before the change</param>
        /// <param name="ethalon">Target ethalon question</param>
        public static void TrackApplyFormatting(List <BaseQuestionViewModel> trackedElements, List <BaseQuestionViewModel> copiesBefore, BaseQuestionViewModel ethalon)
        {
            ApplyFormattingAction action = new ApplyFormattingAction(trackedElements, copiesBefore, ethalon);

            TrackAction(action);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplyFormattingAction"/> class
 /// </summary>
 /// <param name="trackedElements">Changed questions</param>
 /// <param name="copiesBefore">Copies of questions before the change</param>
 /// <param name="ethalon">Target ethalon question</param>
 public ApplyFormattingAction(List <BaseQuestionViewModel> trackedElements, List <BaseQuestionViewModel> copiesBefore, BaseQuestionViewModel ethalon)
 {
     this.questions    = trackedElements;
     this.copiesBefore = copiesBefore;
     this.ethalon      = ethalon;
 }