using System; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Media; namespace ArcasDevTools { public static class Extensions { public static void AddText(this RichTextBox box, string text, string color = "") { box.Dispatcher.Invoke(() => { if (color == "") { color = Application.Current.Resources["ADT_LowGrey"].ToString(); } BrushConverter bc = new BrushConverter(); TextRange tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd); tr.Text = $"({DateTime.Now.ToString("h:mm:ss tt")}): {text}\r"; try { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString(color)); } catch (FormatException) { } box.ScrollToEnd(); }); } } }