/// <summary>
        /// Creates copy of current question
        /// </summary>
        /// <returns>Question copy</returns>
        public override BaseQuestionViewModel CreateCopy()
        {
            GridViewModel elementCopy = new GridViewModel(this.Name, this.Top, this.Left, this.Width, this.Height, this.ParentTemplate, this.Orientation);

            elementCopy.SelectedMapping = this.SelectedMapping;

            foreach (ChoiceBoxViewModel choiceBox in this.ChoiceBoxes)
            {
                BaseQuestionViewModel choiceBoxCopy = choiceBox.CreateCopy();
                elementCopy.ChoiceBoxes.Add((ChoiceBoxViewModel)choiceBoxCopy);
            }

            return(elementCopy);
        }
        /// <summary>
        /// Applyes to current element style and properties of provided element
        /// </summary>
        /// <param name="ethalon">Ethalon element</param>
        public void ApplyStyle(GridViewModel ethalon)
        {
            // update size
            this.Width  = ethalon.Width;
            this.Height = ethalon.Height;

            this.SelectedMapping = ethalon.SelectedMapping;

            // update child collection
            this.ChoiceBoxes.Clear();
            foreach (var item in ethalon.ChoiceBoxes)
            {
                var copy = item.CreateCopy();
                this.ChoiceBoxes.Add((ChoiceBoxViewModel)copy);
            }
        }
        /// <summary>
        /// Add new element via selection rectangle
        /// </summary>
        /// <param name="area">Element area</param>
        public void AddQuestion(Rect area)
        {
            string nextName = NamingManager.GetNextAvailableElementName(this.PageQuestions);

            BaseQuestionViewModel newQuestion;

            if (this.IsAddingChoiceBox)
            {
                newQuestion            = new ChoiceBoxViewModel(nextName, area);
                this.IsAddingChoiceBox = false;
            }
            else
            {
                newQuestion       = new GridViewModel(nextName, area);
                this.IsAddingGrid = false;
            }

            this.OnAddQuestion(newQuestion);
            newQuestion.IsSelected = true;

            ActionTracker.TrackAction(new AddElementsAction(new[] { newQuestion }, this.PageQuestions));
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChoiceBoxViewModel"/> class.
        /// This constructor is called when user creates new questions
        /// </summary>
        /// <param name="name">Question name</param>
        /// <param name="area">Question area</param>
        /// <param name="parentTemplate">The view model of parent template</param>
        /// <param name="parentGrid">The parent grid view model</param>
        public ChoiceBoxViewModel(string name, Rect area, TemplateViewModel parentTemplate, GridViewModel parentGrid)
        {
            this.InitializeValues(name, area.Top, area.Left, area.Width, area.Height);
            this.ParentTemplate = parentTemplate;
            this.ParentGrid     = parentGrid;

            this.Orientation = this.Width >= this.Height ? Orientations.Horizontal : Orientations.Vertical;

            if (this.Orientation == Orientations.Horizontal)
            {
                this.FitBubblesHorizontal(latestBubblesCount);
            }
            else
            {
                this.FitBubblesVertical(latestBubblesCount);
            }

            this.SelectedMapping = this.AnswersMapping[latestSelectedMapping];
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChoiceBoxViewModel"/> class.
 /// This constructor is used in copying and model convertions
 /// </summary>
 /// <param name="name">Question name</param>
 /// <param name="top">Top position on parent canvas</param>
 /// <param name="left">Left position on parent canvas</param>
 /// <param name="width">Question's width</param>
 /// <param name="height">Question's height</param>
 /// <param name="parentTemplate">The view model of parent template</param>
 /// <param name="parentGrid">The parent grid view model</param>
 public ChoiceBoxViewModel(string name, double top, double left, double width, double height, TemplateViewModel parentTemplate, GridViewModel parentGrid)
 {
     this.InitializeValues(name, top, left, width, height);
     this.SelectedMapping = this.AnswersMapping[latestSelectedMapping];
     this.ParentTemplate  = parentTemplate;
     this.ParentGrid      = parentGrid;
 }