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 }; }
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 }; }
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); // var rect = new Rect(tempLeftMargin, topMargin, inlineItem.Width , height ); return new LinkRenderData { LinkID = linkID, Rect = rect }; }
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; }