private void WriteMessageInRichTextBox(string message, SolidColorBrush color) { var error = new Paragraph(new Run(DateTime.Now.ToString("HH:mm:ss") + ": " + message)) { Foreground = color }; InfoRichTextBox.Document.Blocks.Add(error); InfoRichTextBox.ScrollToEnd(); }
public LogsWindow(string logsContent) { InitializeComponent(); FlowDocument fd = new FlowDocument(); MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(logsContent)); TextRange textRange = new TextRange(fd.ContentStart, fd.ContentEnd); textRange.Load(ms, DataFormats.Rtf); InfoRichTextBox.Document = fd; var warning = new Paragraph(new Run("WARNING: THIS WINDOW ISN'T AUTOMATICALLY REFRESHED. CLOSE AND REOPEN IT TO SEE THE LAST LOGS.")) { Foreground = Brushes.Green }; InfoRichTextBox.Document.Blocks.Add(warning); InfoRichTextBox.Document.Blocks.Add(new Paragraph()); InfoRichTextBox.Focus(); InfoRichTextBox.CaretPosition = InfoRichTextBox.CaretPosition.DocumentEnd; InfoRichTextBox.ScrollToEnd(); }