Beispiel #1
0
        /// <summary>
        /// Position bubbles inside vertically oriented question
        /// </summary>
        /// <param name="count">Amount of bubbles</param>
        private void FitBubblesVertical(int count)
        {
            double questionWidth  = this.Width - 2 * BorderOffset - 2 * BorderThickness;
            double questionHeight = this.Height - 2 * BorderOffset - 2 * BorderThickness;

            double bubbleHeight = (questionHeight - (count - 1) * ItemsOffset) / count;
            double bubbleWidth  = questionWidth;

            // if can't fit bubbles by width, do not add any bubbles
            if (bubbleWidth < MinBubbleSize)
            {
                return;
            }

            // if can't fit bubbles by height, reduce bubbles count and recalculate
            while (bubbleHeight < MinBubbleSize)
            {
                count--;
                bubbleHeight = (questionHeight - (count - 1) * ItemsOffset) / count;
            }

            for (int i = 0; i < count; i++)
            {
                double topPosition = BorderOffset + i * ItemsOffset + i * bubbleHeight;
                var    bubble      = new BubbleViewModel(bubbleWidth, bubbleHeight, topPosition, BorderOffset);
                this.Bubbles.Add(bubble);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates copy of current question
        /// </summary>
        /// <returns>Question copy</returns>
        public override BaseQuestionViewModel CreateCopy()
        {
            ChoiceBoxViewModel elementCopy = new ChoiceBoxViewModel(this.Name, this.Top, this.Left, this.Width, this.Height);

            elementCopy.SelectedMapping = this.SelectedMapping;

            foreach (BubbleViewModel bubble in this.Bubbles)
            {
                var bubbleCopy = new BubbleViewModel(bubble.Width, bubble.Height, bubble.Top, bubble.Left);
                bubbleCopy.Name = bubble.Name;
                elementCopy.bubbles.Add(bubbleCopy);
            }

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

            this.SelectedMapping = ethalon.SelectedMapping;

            // update bubbles collection
            this.Bubbles.Clear();
            foreach (BubbleViewModel bubble in ethalon.Bubbles)
            {
                var newBubble = new BubbleViewModel(bubble.Width, bubble.Height, bubble.Top, bubble.Left);
                newBubble.Name = bubble.Name;
                this.Bubbles.Add(newBubble);
            }
        }