Beispiel #1
0
 private static WordRenderData CreateText(PageRenderData context, TextElement element, bool bold, bool italic,
                                          double fontSize, double left, double top, Color? color)
 {
     return new WordRenderData
                {
                    Text = element.Text,
                    Bold = bold,
                    Italic = italic,
                    FontSize = fontSize,
                    Left = left + context.OffsetX,
                    Top = top + context.OffsetY,
                    Color = color
                };
 }
Beispiel #2
0
 private static TextRenderData CreateTextContext(PageRenderData context, int paragraphID, TextElement inlineItem,
                                                 double height, double tempLeftMargin, double topMargin)
 {
     return new TextRenderData
                {
                    Text = inlineItem.Text,
                    Rect = new Rect(tempLeftMargin + context.OffsetX, topMargin + context.OffsetY,
                                    inlineItem.Width, height),
                    ParagraphID = paragraphID,
                    TokenID = inlineItem.TokenID
                };
 }
Beispiel #3
0
        private static LinkRenderData CreateLinkContext(TextElement inlineItem, double height, double tempLeftMargin,
                                                        double topMargin)
        {
            string linkID = inlineItem.LinkID;
            if (linkID.StartsWith("#"))
                linkID = linkID.Remove(0, 1);

            var rect = new Rect(tempLeftMargin, topMargin, inlineItem.Width + 24.0, height + 24.0);

            return new LinkRenderData
                       {
                           LinkID = linkID,
                           Rect = rect
                       };
        }
Beispiel #4
0
        private static double BuildInlineItem(PageRenderData context, double top, double defaultFontSize, int paragraphID,
                                              TextElement inlineItem, double height, double tempLeftMargin, double wordSpacing)
        {
            double fontSize = inlineItem.Size;
            if (fontSize < 0.01 || !AppSettings.Default.UseCSSFontSize)
                fontSize = defaultFontSize;
            double topMargin = top;
            if (inlineItem.SubOption || inlineItem.SupOption)
                fontSize /= 2.0;
            if (inlineItem.SubOption)
                topMargin += height/2.0;
            if (!string.IsNullOrEmpty(inlineItem.Text) && !string.IsNullOrWhiteSpace(inlineItem.Text))
            {
                var textContext = CreateTextContext(context, paragraphID, inlineItem, height, tempLeftMargin, topMargin);
                context.Texts.Add(textContext);
            }
            var color = new Color?();

            if (!string.IsNullOrEmpty(inlineItem.LinkID))
            {
                var linkContext = CreateLinkContext(inlineItem, height, tempLeftMargin, topMargin);
                context.Links.Add(linkContext);
                color = context.LinkBrush;
            }

            var wordContext = CreateText(context, inlineItem, inlineItem.Bold, inlineItem.Italic, fontSize,
                                         tempLeftMargin, topMargin, color);
            context.Words.Add(wordContext);
            return tempLeftMargin + inlineItem.Width + wordSpacing;
        }