private IEnumerable<IRenderArgument> DoRenderLine(ITextRender2MeasureMap map, ITextRender2MeasureMapLine line) { foreach (var el in line.GetMeasureMap()) { yield return DoRenderElement(map, line, el); } }
private IRenderArgument DoRenderElement(ITextRender2MeasureMap map, ITextRender2MeasureMapLine line, TextRender2MeasureMapElement el) { return new NativeRenderArgument(map, line, el, Callback); }
public NativeRenderArgument(ITextRender2MeasureMap map, ITextRender2MeasureMapLine line, TextRender2MeasureMapElement el, ITextRender2RenderCallback callback) { if (map == null) throw new ArgumentNullException(nameof(map)); if (line == null) throw new ArgumentNullException(nameof(line)); if (callback == null) throw new ArgumentNullException(nameof(callback)); var command = el.Command; string text; var textCnt = command.Content as ITextRenderTextContent; if (textCnt != null) { text = textCnt.Text ?? ""; } else { text = ""; } Text = text; ElementSize = el.Size; Placement = el.Placement; LineHeight = line.Height; StrikethrougKoef = map.StrikethrougKoef; if (command.Attributes.Attributes.ContainsKey(CommonTextRenderAttributes.Link)) { var linkAttribute = command.Attributes.Attributes[CommonTextRenderAttributes.Link] as ITextRenderLinkAttribute; if (linkAttribute != null) { Link = new LinkDataWrapper(linkAttribute); } } Callback = new RenderCallbackWrapper(callback); TextAttributeFlags flags = 0; var attr = command.Attributes.Attributes; if (attr.ContainsKey(CommonTextRenderAttributes.Link)) { flags = flags | TextAttributeFlags.Link; } if (attr.ContainsKey(CommonTextRenderAttributes.Bold)) { flags = flags | TextAttributeFlags.Bold; } if (attr.ContainsKey(CommonTextRenderAttributes.Fixed)) { flags = flags | TextAttributeFlags.Fixed; } if (attr.ContainsKey(CommonTextRenderAttributes.Italic)) { flags = flags | TextAttributeFlags.Italic; } if (attr.ContainsKey(CommonTextRenderAttributes.Overline)) { flags = flags | TextAttributeFlags.Overline; } if (attr.ContainsKey(CommonTextRenderAttributes.Quote)) { flags = flags | TextAttributeFlags.Quote; } if (attr.ContainsKey(CommonTextRenderAttributes.Spoiler)) { flags = flags | TextAttributeFlags.Spoiler; } if (attr.ContainsKey(CommonTextRenderAttributes.Strikethrough)) { flags = flags | TextAttributeFlags.Strikethrough; } if (attr.ContainsKey(CommonTextRenderAttributes.Subscript)) { flags = flags | TextAttributeFlags.Subscript; } if (attr.ContainsKey(CommonTextRenderAttributes.Superscript)) { flags = flags | TextAttributeFlags.Superscript; } if (attr.ContainsKey(CommonTextRenderAttributes.Undeline)) { flags = flags | TextAttributeFlags.Undeline; } Flags = flags; }
public MeasureMap(ITextRender2MeasureMapLine[] lines, double width, int? maxLines, double strikethrougKoef) { if (lines == null) throw new ArgumentNullException(nameof(lines)); this.lines = lines; MaxLines = maxLines; var h = 0.0; foreach (var l in lines) { if (maxLines.HasValue) { if (l.LineNumber >= maxLines.Value) { ExceedLines = true; break; } } h += l.Height; } Bounds = new Size(width, h); StrikethrougKoef = strikethrougKoef; }