private void InnerWrite(FlowDocumentScrollViewer rtb, Paragraph p, string text, ConsoleColor foreground) { InlineCollection list = p.Inlines; // 满1000行删除500行 if (list.Count > 1000) { int delLines = 500; while (delLines-- > 0) { ((IList)list).RemoveAt(0); } } Run run = new Run(text) { Foreground = new SolidColorBrush(foreground.ToMediaColor()) }; list.Add(run); if (ChkbIsConsoleAutoScrollToEnd.IsChecked.HasValue && ChkbIsConsoleAutoScrollToEnd.IsChecked.Value) { ScrollViewer(rtb)?.ScrollToEnd(); } }
private void InnerWrite(string text, ConsoleColor foreground) { Run run = new Run(text) { Foreground = new SolidColorBrush(foreground.ToMediaColor()) }; this.ConsoleParagraph.Inlines.Add(run); InlineCollection list = this.ConsoleParagraph.Inlines; // 满1000行删除500行 if (list.Count > 1000) { int delLines = 500; while (delLines-- > 0) { list.Remove(list.FirstInline); } } if (ChkbIsConsoleAutoScrollToEnd.IsChecked.HasValue && ChkbIsConsoleAutoScrollToEnd.IsChecked.Value) { this.RichTextBox.ScrollToEnd(); } }
private void InnerWrite(string text, ConsoleColor foreground) { InlineCollection list = this.ConsoleParagraph.Inlines; if (list.Count > MAXLINE) { int delLines = HALFLINE; while (delLines-- > 0) { ((IList)list).RemoveAt(0); } } Run run = new Run(text) { Foreground = new SolidColorBrush(foreground.ToMediaColor()) }; list.Add(run); if (ChkbIsConsoleAutoScrollToEnd.IsChecked.HasValue && ChkbIsConsoleAutoScrollToEnd.IsChecked.Value) { this.ScrollViewer?.ScrollToEnd(); } }