public static void SelectText(this TextBoxBase self, Range range) { self.SelectionStart = range.Begin; self.SelectionLength = range.Length; }
public static void SelectAndApply(this RichTextBox self, Range r, Proc p) { Range old = SelectedRange(self); try { SelectText(self, r); p(); } finally { SelectText(self, old); } }
public static void ColorText(this RichTextBox self, Range r, Color c) { self.SelectAndApply(r, () => { self.SelectionColor = c; }); }
public static Match MatchWithin(this string self, Regex regex, Range r) { return regex.Match(self.Substring(r)); }
public static String Substring(this String self, Range range) { return self.Substring(range.Begin, range.Length); }
public static string GetText(this TextBoxBase self, Range r) { return self.Text.Substring(r); }
public static void SetTextColor(this RichTextBox self, Color c, Range r) { SelectAndApply(self, r, () => self.SelectionColor = c); }