public override object Build(FlowElementBuilderContext context, PrintElementList element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new List
            {
                MarkerStyle  = TextMarkerStyle.None,
                MarkerOffset = element.MarkerOffsetSize + DefaultMarkerOffsetSize
            };

            FlowElementBuilderHelper.ApplyBaseStyles(elementContent, element);
            FlowElementBuilderHelper.ApplyBlockStyles(elementContent, element);

            if (element.StartIndex != null)
            {
                elementContent.StartIndex = element.StartIndex.Value;
            }

            if (element.MarkerStyle != null)
            {
                elementContent.MarkerStyle = FlowElementBuilderHelper.GetMarkerStyle(element.MarkerStyle.Value);
            }

            foreach (var item in element.Items)
            {
                var itemContent = context.Build <Block>(item, elementMetadataMap);

                if (itemContent != null)
                {
                    var listItem = new ListItem();
                    listItem.Blocks.Add(itemContent);
                    elementContent.ListItems.Add(listItem);
                }
            }

            return(elementContent);
        }
        public override object Build(FlowElementBuilderContext context, PrintElementSection element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Section();

            FlowElementBuilderHelper.ApplyBaseStyles(elementContent, element);
            FlowElementBuilderHelper.ApplyBlockStyles(elementContent, element);

            foreach (var block in element.Blocks)
            {
                var newBlock = context.Build <Block>(block, elementMetadataMap);
                elementContent.Blocks.Add(newBlock);
            }

            return(elementContent);
        }
コード例 #3
0
        public override object Build(FlowElementBuilderContext context, PrintElementUnderline element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Underline();

            FlowElementBuilderHelper.ApplyBaseStyles(elementContent, element);
            FlowElementBuilderHelper.ApplyInlineStyles(elementContent, element);

            foreach (var inline in element.Inlines)
            {
                var inlineContent = context.Build <Inline>(inline, elementMetadataMap);

                elementContent.Inlines.Add(inlineContent);
            }

            return(elementContent);
        }
        public override object Build(FlowElementBuilderContext context, PrintElementHyperlink element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Hyperlink();

            FlowElementBuilderHelper.ApplyBaseStyles(elementContent, element);
            FlowElementBuilderHelper.ApplyInlineStyles(elementContent, element);

            elementContent.NavigateUri = element.Reference;

            foreach (var inline in element.Inlines)
            {
                var inlineContent = context.Build <Inline>(inline, elementMetadataMap);

                elementContent.Inlines.Add(inlineContent);
            }

            return(elementContent);
        }
        public override object Build(FlowElementBuilderContext context, PrintElementParagraph element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Paragraph();

            FlowElementBuilderHelper.ApplyBaseStyles(elementContent, element);
            FlowElementBuilderHelper.ApplyBlockStyles(elementContent, element);

            if (element.IndentSize != null)
            {
                elementContent.TextIndent = element.IndentSize.Value;
            }

            foreach (var inline in element.Inlines)
            {
                var newInline = context.Build <Inline>(inline, elementMetadataMap);

                if (newInline != null)
                {
                    elementContent.Inlines.Add(newInline);
                }
            }

            return(elementContent);
        }
コード例 #6
0
        public override object Build(FlowElementBuilderContext context, PrintElementTable element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Table
            {
                CellSpacing     = 0,
                BorderBrush     = Brushes.Black,
                BorderThickness = new Thickness(1, 1, 0, 0),
                RowGroups       = { new TableRowGroup() }
            };

            FlowElementBuilderHelper.ApplyBaseStyles(elementContent, element);
            FlowElementBuilderHelper.ApplyBlockStyles(elementContent, element);

            foreach (var column in element.Columns)
            {
                var columnContent = new TableColumn {
                    Width = new GridLength(column.Size ?? 1)
                };

                elementMetadataMap.RemapElement(column, columnContent);

                elementContent.Columns.Add(columnContent);
            }

            foreach (var row in element.Rows)
            {
                var rowContent = new TableRow();

                FlowElementBuilderHelper.ApplyRowStyles(rowContent, row);

                var colSpansCount = 0;

                foreach (var cell in row.Cells)
                {
                    var cellContent = new TableCell
                    {
                        ColumnSpan      = 1,
                        RowSpan         = 1,
                        BorderBrush     = Brushes.Black,
                        BorderThickness = new Thickness(0, 0, 1, 1)
                    };

                    //Check ColSpan and RowSpan

                    colSpansCount += cell.ColumnSpan ?? 1;

                    if (colSpansCount > element.Columns.Count)
                    {
                        cell.ColumnSpan = element.Columns.Count - (colSpansCount - cell.ColumnSpan);
                    }

                    FlowElementBuilderHelper.ApplyCellStyles(cellContent, cell);

                    var blockContent = context.Build <Block>(cell.Block, elementMetadataMap);

                    if (blockContent != null)
                    {
                        cellContent.Blocks.Add(blockContent);
                    }

                    elementMetadataMap.RemapElement(cell, cellContent);

                    rowContent.Cells.Add(cellContent);
                }

                elementMetadataMap.RemapElement(row, rowContent);

                elementContent.RowGroups[0].Rows.Add(rowContent);
            }

            return(elementContent);
        }