/// <summary> /// Конструктор. /// </summary> /// <param name="source">Источник.</param> public ColorsCacheCallback(ITextRender2RenderCallback source) { if (source == null) throw new ArgumentNullException(nameof(source)); this.source = source; postFontSize = new Lazy<double>(() => source.PostFontSize); postNormalTextBrush = new Lazy<Brush>(() => source.PostNormalTextBrush); postNormalTextColor = new Lazy<Color>(() => source.PostNormalTextColor); postSpoilerBackgroundBrush = new Lazy<Brush>(() => source.PostSpoilerBackgroundBrush); postSpoilerBackgroundColor = new Lazy<Color>(() => source.PostSpoilerBackgroundColor); postSpoilerTextBrush = new Lazy<Brush>(() => source.PostSpoilerTextBrush); postSpoilerTextColor = new Lazy<Color>(() => source.PostSpoilerTextColor); postQuoteTextBrush = new Lazy<Brush>(() => source.PostQuoteTextBrush); postQuoteTextColor = new Lazy<Color>(() => source.PostQuoteTextColor); postLinkTextBrush = new Lazy<Brush>(() => source.PostLinkTextBrush); postLinkTextColor = new Lazy<Color>(() => source.PostLinkTextColor); }
/// <summary> /// Конструктор. /// </summary> /// <param name="callback">Обратный вызов.</param> public XamlCanvasTextRender2Renderer(ITextRender2RenderCallback callback) { if (callback == null) throw new ArgumentNullException(nameof(callback)); Callback = new ColorsCacheCallback(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; }
/// <summary> /// Конструктор. /// </summary> /// <param name="callback">Обратный вызов.</param> public Direct2DTextRender2Renderer(ITextRender2RenderCallback callback) { if (callback == null) throw new ArgumentNullException(nameof(callback)); Callback = callback; }
/// <summary> /// »нициализирует новый экземпл¤р класса <see cref="T:System.Object"/>. /// </summary> public RenderCallbackWrapper(ITextRender2RenderCallback src) { if (src == null) throw new ArgumentNullException(nameof(src)); this.src = src; }