Beispiel #1
0
        /// <summary>
        /// Creates choice box view model from choice box model
        /// </summary>
        /// <param name="choiceBox">Choice box model data</param>
        /// <param name="templateViewModel">Parent template</param>
        /// <returns>Created choice box view model</returns>
        private static ChoiceBoxViewModel CreateChoiceBoxViewModel(ChoiceBoxElement choiceBox, TemplateViewModel templateViewModel)
        {
            ChoiceBoxViewModel choiceBoxViewModel = new ChoiceBoxViewModel(
                choiceBox.Name,
                choiceBox.Top,
                choiceBox.Left,
                choiceBox.Width,
                choiceBox.Height,
                templateViewModel,
                null);

            foreach (OmrBubble modelBubble in choiceBox.Bubbles)
            {
                BubbleViewModel bubbleViewModel = new BubbleViewModel(
                    choiceBox.BubbleWidth,
                    choiceBox.BubbleHeight,
                    modelBubble.Top - choiceBox.Top,
                    modelBubble.Left - choiceBox.Left,
                    choiceBoxViewModel);

                bubbleViewModel.Name    = modelBubble.Value;
                bubbleViewModel.IsValid = modelBubble.IsValid;

                choiceBoxViewModel.Bubbles.Add(bubbleViewModel);
            }

            return(choiceBoxViewModel);
        }
Beispiel #2
0
        /// <summary>
        /// Creates Grid element from GridViewModel and adds to the OmrPage
        /// </summary>
        /// <param name="page">Page to add element to</param>
        /// <param name="gridViewModel">ViewModel to take data from</param>
        private static void AddGridElement(OmrPage page, GridViewModel gridViewModel)
        {
            GridElement grid = page.AddGridElement(gridViewModel.Name, (int)gridViewModel.Width,
                                                   (int)gridViewModel.Height,
                                                   (int)gridViewModel.Top,
                                                   (int)gridViewModel.Left);

            foreach (ChoiceBoxViewModel choiceBoxViewModel in gridViewModel.ChoiceBoxes)
            {
                ChoiceBoxElement choiceBoxElement = grid.AddChoiceBox(
                    choiceBoxViewModel.Name,
                    (int)choiceBoxViewModel.Width,
                    (int)choiceBoxViewModel.Height,
                    (int)(gridViewModel.Top + choiceBoxViewModel.Top),
                    (int)(gridViewModel.Left + choiceBoxViewModel.Left));

                foreach (var bubble in choiceBoxViewModel.Bubbles)
                {
                    choiceBoxElement.AddBubble(
                        bubble.Name,
                        (int)bubble.Width,
                        (int)bubble.Height,
                        (int)(gridViewModel.Top + choiceBoxViewModel.Top + bubble.Top),
                        (int)(gridViewModel.Left + choiceBoxViewModel.Left + bubble.Left),
                        bubble.IsValid);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates ChoiceBox element from ChoiceBoxViewModel and adds to the OmrPage
        /// </summary>
        /// <param name="page">Page to add element to</param>
        /// <param name="choiceBoxViewModel">ViewModel to take data from</param>
        private static void AddChoiceBoxElement(OmrPage page, ChoiceBoxViewModel choiceBoxViewModel)
        {
            ChoiceBoxElement choiceBox = page.AddChoiceBoxElement(
                choiceBoxViewModel.Name,
                (int)choiceBoxViewModel.Width,
                (int)choiceBoxViewModel.Height,
                (int)choiceBoxViewModel.Top,
                (int)choiceBoxViewModel.Left);

            foreach (var bubble in choiceBoxViewModel.Bubbles)
            {
                choiceBox.AddBubble(
                    bubble.Name,
                    (int)bubble.Width,
                    (int)bubble.Height,
                    (int)(choiceBoxViewModel.Top + bubble.Top),
                    (int)(choiceBoxViewModel.Left + bubble.Left),
                    bubble.IsValid);
            }
        }
 public static void Run()
 {
     // ExStart:DynamicallyCreateOMRTemplates
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_OMR();
     OmrTemplate template = new OmrTemplate();
     OmrPage page = template.Pages[0];
     page.Width = 215.9;
     page.Height = 279.4;
     PointF choiceBoxPosition = new PointF(20, 5); // 20 mm to the right, 5 mm from the top
     SizeF choiceBoxSize = new SizeF(12, 24);
     ChoiceBoxElement choiceBox = new ChoiceBoxElement("AnotherElement", choiceBoxPosition, choiceBoxSize);
     choiceBox.IsHorizontal = false;
     choiceBox.Cells.Add(new OmrCell("A")); // Three marks: (A) (B) (C)
     choiceBox.Cells.Add(new OmrCell("B"));
     choiceBox.Cells.Add(new OmrCell("C"));
     page.Elements.Add(choiceBox);
     template.Save(dataDir + "New_template_out.amr");
     // ExEnd:DynamicallyCreateOMRTemplates
 }
        public static void Run()
        {
            // ExStart:DynamicallyCreateOMRTemplates
            // The path to the documents directory.
            string      dataDir  = RunExamples.GetDataDir_OMR();
            OmrTemplate template = new OmrTemplate();
            OmrPage     page     = template.Pages[0];

            page.Width  = 215.9;
            page.Height = 279.4;
            PointF           choiceBoxPosition = new PointF(20, 5); // 20 mm to the right, 5 mm from the top
            SizeF            choiceBoxSize     = new SizeF(12, 24);
            ChoiceBoxElement choiceBox         = new ChoiceBoxElement("AnotherElement", choiceBoxPosition, choiceBoxSize);

            choiceBox.IsHorizontal = false;
            choiceBox.Cells.Add(new OmrCell("A")); // Three marks: (A) (B) (C)
            choiceBox.Cells.Add(new OmrCell("B"));
            choiceBox.Cells.Add(new OmrCell("C"));
            page.Elements.Add(choiceBox);
            template.Save(dataDir + "New_template_out.amr");
            // ExEnd:DynamicallyCreateOMRTemplates
        }