Thursday, September 19, 2024 9:22:27 PM
> settings

Customize


Authenticate

> Extensions.cs
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();
            });
        }
    }
}
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b