protected void CreateItemIfNotNull(InlineCollection inlines, String title, bool boldTitle, String value, String end, bool linebreak) { List <Inline> list = CreateItemIfNotNull(title, boldTitle, value, end, linebreak); if (list != null && list.Count > 0) { inlines.AddRange(list); } }
void AddContactSays(InlineCollection inlines) { string text = String.Format("{0} " + Translation.Instance.Global_ContactSaid + " ({1}): ", this.User, Stamp.ToShortTimeString()); var items = Parsers.ParseText(text); foreach (var item in items) { item.Foreground = Brushes.Gray; } inlines.AddRange(items); }
private static void OnFormattedTextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { InlineCollection inlines = null; var textBlock = o as TextBlock; if (textBlock != null) { inlines = textBlock.Inlines; } else { var paragraph = o as Paragraph; if (paragraph != null) { inlines = paragraph.Inlines; } else { var span = o as Span; if (span != null) { inlines = span.Inlines; } } } if (inlines == null) { return; } inlines.Clear(); if (e.NewValue == null) { return; } var formattedInlines = FormattedTextConverter.Instance.Convert( e.NewValue, typeof(IEnumerable <Inline>), null, CultureInfo.InvariantCulture) as IEnumerable <Inline>; if (formattedInlines != null) { inlines.AddRange(formattedInlines); } }
protected void HandleInlines(InlineCollection destInlineColl, TreeNode node, Inline nodeRun) { if (nodeRun != null) { destInlineColl.Add(nodeRun); } if (node.ChildCount > 0) { HtmlInlineExtractionVisitor inlineVisitor = new HtmlInlineExtractionVisitor(TextChannel); foreach (TreeNode child in node.ListOfChildren) { child.AcceptDepthFirst(inlineVisitor); } destInlineColl.AddRange(inlineVisitor.ExtractedInlines); } }
void AddMessage(InlineCollection inlines) { var items = Parsers.ParseText(Message); var fontsettings = new FontSetting(Color, FontName, FontSize, FontStyle); foreach (var item in items) { item.FontFamily = fontsettings.Family; item.FontSize = fontsettings.Size; item.Foreground = fontsettings.Foreground; item.FontStyle = fontsettings.Style; item.FontWeight = fontsettings.Weight; } inlines.AddRange(items); }
protected override void Write(string parsedSourceCode, IList <Scope> scopes) { inlineCollection.AddRange(SelectSpans(parsedSourceCode, scopes)); }
void InternalRender(XContainer content, InlineCollection inlines, ListContext list) { foreach (var item in content.Nodes()) { switch (item.NodeType) { case XmlNodeType.Element: var e = item as XElement; switch (e.Name.LocalName) { case "list": list = list == null ? new ListContext(e.Attribute("type")?.Value) : new ListContext(e.Attribute("type")?.Value, list); InternalRender(e, inlines, list); list = list.Parent; break; case "para": var isOnlyChildOfItem = list != null && e.Parent.Name == "item" && e.Parent.FirstNode == e.Parent.LastNode && e.Parent.FirstNode == item; if (isOnlyChildOfItem) { ParagraphCount++; } else if (inlines.LastInline != null && inlines.LastInline is LineBreak == false) { inlines.AppendLineWithMargin(); ParagraphCount++; } InternalRender(e, inlines, list); if (inlines.FirstInline == null && isOnlyChildOfItem == false) { inlines.Add(new LineBreak()); } break; case "listheader": RenderBlockContent(inlines, list, e, BLOCK_OTHER); break; case "h1": RenderBlockContent(inlines, list, e, BLOCK_TITLE).FontSize = ThemeHelper.ToolTipFontSize + 5; break; case "h2": RenderBlockContent(inlines, list, e, BLOCK_TITLE).FontSize = ThemeHelper.ToolTipFontSize + 3; break; case "h3": RenderBlockContent(inlines, list, e, BLOCK_TITLE).FontSize = ThemeHelper.ToolTipFontSize + 2; break; case "h4": RenderBlockContent(inlines, list, e, BLOCK_TITLE).FontSize = ThemeHelper.ToolTipFontSize + 1; break; case "h5": RenderBlockContent(inlines, list, e, BLOCK_TITLE).FontSize = ThemeHelper.ToolTipFontSize + 0.5; break; case "h6": RenderBlockContent(inlines, list, e, BLOCK_TITLE); break; case "code": ++_isCode; var span = RenderBlockContent(inlines, list, e, BLOCK_OTHER); span.FontFamily = GetCodeFont(); span.Background = ThemeHelper.ToolWindowBackgroundBrush; span.Foreground = ThemeHelper.ToolWindowTextBrush; --_isCode; break; case "item": RenderBlockContent(inlines, list, e, BLOCK_ITEM); break; case "see": case "seealso": RenderSee(inlines, e); break; case "paramref": RenderParamRef(inlines, e); break; case "typeparamref": RenderTypeParamRef(inlines, e); break; case "c": case "tt": ++_isCode; StyleInner(e, inlines, new Span() { FontFamily = GetCodeFont(), Background = ThemeHelper.ToolWindowBackgroundBrush, Foreground = ThemeHelper.ToolWindowTextBrush }); --_isCode; break; case "b": case "strong": case "term": StyleInner(e, inlines, new Bold()); break; case "i": case "em": StyleInner(e, inlines, new Italic()); break; case "u": StyleInner(e, inlines, new Underline()); break; case "a": var a = e.Attribute("href"); if (a != null && IsUrl(a)) { CreateLink(inlines, e, a); } else { goto case "u"; } break; case "br": inlines.Add(new LineBreak()); break; case "hr": inlines.AddRange(new Inline[] { new LineBreak(), new InlineUIContainer(new Border { Height = 1, Background = ThemeHelper.DocumentTextBrush, Margin = WpfHelper.MiddleVerticalMargin, Opacity = 0.5 }.Bind(FrameworkElement.WidthProperty, new Binding { RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ThemedTipText), 1), Path = new PropertyPath("ActualWidth") })), new LineBreak() }); break; //case "list": //case "description": default: InternalRender(e, inlines, list); break; } break; case XmlNodeType.Text: string t = ((XText)item).Value; if (_isCode == 0) { var previous = (item.PreviousNode as XElement)?.Name?.LocalName; if (previous == null || IsInlineElementName(previous) == false) { t = item.NextNode == null?t.Trim() : t.TrimStart(); } else if (item.NextNode == null) { t = t.TrimEnd(); } if (t.Length == 0) { break; } t = _FixWhitespaces.Replace(t.Replace('\n', ' '), " "); } else { t = t.Replace("\n ", "\n"); } if (t.Length > 0) { inlines.Add(new Run(t)); } break; case XmlNodeType.CDATA: inlines.Add(_isCode == 0 ? new Run(((XText)item).Value) : new Run(((XText)item).Value.Replace("\n ", "\n").TrimEnd())); break; case XmlNodeType.EntityReference: case XmlNodeType.Entity: inlines.Add(new Run(item.ToString())); break; } } var lastNode = content.LastNode; if (lastNode != null && (lastNode.NodeType != XmlNodeType.Element || ((XElement)lastNode).Name != "para") && IsInlineElementName((lastNode.PreviousNode as XElement)?.Name.LocalName) == false) { ParagraphCount++; } }