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, PrintElementLineBreak element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new LineBreak();

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

            return(elementContent);
        }
        public override object Build(FlowElementBuilderContext context, PrintElementRun element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Run {
                Text = element.Text
            };

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

            return(elementContent);
        }
Exemplo n.º 4
0
        public override object Build(FlowElementBuilderContext context, PrintElementPageBreak element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Paragraph
            {
                FontSize        = 0.1,
                BreakPageBefore = true
            };

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

            return(elementContent);
        }
Exemplo n.º 5
0
        public override object Build(FlowElementBuilderContext context, PrintElementLine element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new Paragraph
            {
                FontSize        = 0.1,
                BorderBrush     = Brushes.Black,
                BorderThickness = new Thickness(0, 0, 0, 1)
            };

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

            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);
        }
Exemplo n.º 7
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);
        }
        public override object Build(FlowElementBuilderContext context, PrintElementImage element, PrintElementMetadataMap elementMetadataMap)
        {
            var elementContent = new InlineUIContainer {
                BaselineAlignment = BaselineAlignment.Baseline
            };

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

            var imageSource = new BitmapImage();

            imageSource.BeginInit();

            var elementSourceStream = new MemoryStream();

            element.Source.Save(elementSourceStream, ImageFormat.Png);
            imageSource.StreamSource = elementSourceStream;
            imageSource.EndInit();

            var imageControl = new Image();

            imageControl.BeginInit();
            imageControl.Width = (element.Size != null
                                      ? element.Size.Width
                                      : null) ?? imageSource.Width;
            imageControl.Height = (element.Size != null
                                       ? element.Size.Height
                                       : null) ?? imageSource.Height;
            imageControl.Source  = imageSource;
            imageControl.Stretch = Stretch.Fill;
            imageControl.EndInit();

            elementContent.Child = imageControl;

            return(elementContent);
        }
Exemplo n.º 11
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);
        }