protected internal override IRenderer CreateFlatRenderer()
        {
            AbstractSelectField   selectField = (AbstractSelectField)modelElement;
            IList <IBlockElement> options     = selectField.GetOptions();
            Div optionsContainer = new Div();

            foreach (IBlockElement option in options)
            {
                optionsContainer.Add(option);
            }
            IRenderer rendererSubTree;

            if (optionsContainer.GetChildren().IsEmpty())
            {
                Paragraph pStub = new Paragraph("\u00A0").SetMargin(0);
                pStub.SetProperty(Property.OVERFLOW_X, OverflowPropertyValue.VISIBLE);
                pStub.SetProperty(Property.OVERFLOW_Y, OverflowPropertyValue.VISIBLE);
                pStub.SetProperty(Html2PdfProperty.FORM_FIELD_SELECTED, false);
                // applying this property for the sake of finding this element as option
                optionsContainer.Add(pStub);
                rendererSubTree = optionsContainer.CreateRendererSubTree();
            }
            else
            {
                rendererSubTree = optionsContainer.CreateRendererSubTree();
                IList <IRenderer> selectedOptions = GetSelectedOptions(rendererSubTree);
                foreach (IRenderer selectedOption in selectedOptions)
                {
                    ApplySelectedStyle(selectedOption);
                }
            }
            return(rendererSubTree);
        }
Exemplo n.º 2
0
        // TODO DEVSIX-1901
        private IRenderer CreateFlatRenderer(bool addAllOptionsToChildren)
        {
            AbstractSelectField   selectField = (AbstractSelectField)modelElement;
            IList <IBlockElement> options     = selectField.GetOptions();
            Div pseudoContainer = new Div();

            foreach (IBlockElement option in options)
            {
                pseudoContainer.Add(option);
            }
            IList <Paragraph> allOptions;
            IRenderer         pseudoRendererSubTree = pseudoContainer.CreateRendererSubTree();

            if (addAllOptionsToChildren)
            {
                allOptions = GetAllOptionsFlatElements(pseudoRendererSubTree);
            }
            else
            {
                allOptions = GetSingleSelectedOptionFlatRenderer(pseudoRendererSubTree);
            }
            if (allOptions.IsEmpty())
            {
                allOptions.Add(CreateComboBoxOptionFlatElement());
            }
            pseudoContainer.GetChildren().Clear();
            foreach (Paragraph option in allOptions)
            {
                pseudoContainer.Add(option);
            }
            AccessiblePropHelper.TrySetLangAttribute(pseudoContainer, GetLang());
            IRenderer rendererSubTree = pseudoContainer.CreateRendererSubTree();

            return(rendererSubTree);
        }