RBXLegacy-src/RBXLegacyLauncher/RBXLegacyLauncher/RichTextBoxExtensions.cs

25 lines
706 B
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
// you need this once (only), and it must be in this namespace
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
| AttributeTargets.Method)]
public sealed class ExtensionAttribute : Attribute {}
}
public static class RichTextBoxExtensions
{
public static void AppendText(this RichTextBox box, string text, Color color)
{
box.SelectionStart = box.TextLength;
box.SelectionLength = 0;
box.SelectionColor = color;
box.AppendText(text);
box.SelectionColor = box.ForeColor;
}
}