public static void SetLinkedText(this BetterRichTextbox richTextBox, string htmlFragment) { var regEx = new Regex( @"\<a\s(href\=""|[^\>]+?\shref\="")(?<link>[^""]+)"".*?\>(?<text>.*?)(\<\/a\>|$)", RegexOptions.IgnoreCase | RegexOptions.Multiline); richTextBox.Blocks.Clear(); int nextOffset = 0; foreach (Match match in regEx.Matches(htmlFragment)) { if (match.Index > nextOffset) { string url = match.Groups["link"].Value.TrimStart('/'); if (!url.Contains("http://")) { url = "http://" + url; } richTextBox.AppendText(htmlFragment.Substring(nextOffset, match.Index - nextOffset)); nextOffset = match.Index + match.Length; richTextBox.AppendLink(match.Groups["text"].Value, new Uri(url)); } Debug.WriteLine(match.Groups["text"] + ":" + match.Groups["link"]); } if (nextOffset < htmlFragment.Length) { richTextBox.AppendText(htmlFragment.Substring(nextOffset)); } }
public static void WriteLine(this TextBox tb, string s, params object [] args) { if (args.Length == 0) tb.AppendText (s); else tb.AppendText (string.Format (s, args)); tb.AppendText (CRLF); }
public static void AppendTextLine(this TextBox textBox, string message) { if (!String.IsNullOrEmpty(message)) { textBox.InvokeIfNeeded(delegate { textBox.AppendText(message); textBox.AppendText("\r\n"); }, InvocationMethod.Asynchronous); } }
public static void AppendLine(this RichTextBox box, int space, string text, Color color) { box.AppendText("\n"); box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.AppendText(text.PadLeft(space + text.Length, ' ')); box.SelectionColor = box.ForeColor; }
public static void AppendLine(this RichTextBox ed, string s) { int ss = ed.SelectionStart; ed.AppendText(s); int sl = ed.SelectionStart - ss + 1; Font bold = new Font(ed.Font, FontStyle.Regular); ed.Select(ss, sl); ed.SelectionFont = bold; ed.AppendText(NewLine); }
/// <summary> /// Thread-safe wrapper for <see cref="System.Windows.Forms.TextBoxBase.AppendText(string)"/>. /// </summary> /// <param name="control">The <see cref="System.Windows.Forms.TextBoxBase"/>.</param> /// <param name="value">The <see cref="string"/> to set.</param> public static void AppendTextSafe(this TextBoxBase control, string value) { if (control.InvokeRequired) { control.Invoke((Action<string>)((string var) => control.AppendText(var)), value); } else { control.AppendText(value); } }
public static void AppendBoldColoredLine(this RichTextBox ed, string s,Color passedInColor) { int ss = ed.SelectionStart; ed.AppendText(s); int sl = ed.SelectionStart - ss + 1; Font bold = new Font(ed.Font, FontStyle.Bold); ed.Select(ss, sl); ed.SelectionFont = bold; ed.SelectionColor = passedInColor; ed.AppendText(NewLine); }
public static void AppendFormatLine(this TextBoxBase textbox, string format, params object[] args) { Contract.Requires(format != null); Contract.Requires(args != null); textbox.AppendText(String.Format(format, args) + Environment.NewLine); }
public static void AppendLine(this TextBox source, string value) { if (source.Text.Length == 0) source.Text = value; else source.AppendText(Environment.NewLine + value); }
public static void AppendFormatLine(this RichTextBox textbox, string format, params object[] arg0) { Contract.Requires(format != null); Contract.Requires(arg0 != null); textbox.AppendText(String.Format(format, arg0) + Environment.NewLine); SetDefaultStyle(textbox); }
public static void AppendLine(this TextBox textBox) { textBox.InvokeIfNeeded(delegate { textBox.AppendText("\r\n"); }, InvocationMethod.Asynchronous); }
//function allowing to add strings in textBox1 public static void AppendLine(this TextBox source, string value) { if (source.Text.Length == 0) source.Text = value; else source.AppendText("\r\n" + value); }
public static async Task AppendText(this IFileInfo fileInfo, string text) { using (var writer = fileInfo.AppendText()) { await writer.WriteAsync(text); } }
public static void AppendBold(this RichTextBox tb, string text) { Font orig = tb.SelectionFont; tb.SelectionFont = new Font(orig.FontFamily, orig.Size, FontStyle.Bold); tb.AppendText(text); tb.SelectionFont = orig; }
/// <summary> /// Appends bold and colored text to the RichTextBox /// </summary> /// <param name="box">The RichTextBox</param> /// <param name="text">Text being added</param> /// <param name="color">Color of the text being added.</param> public static void AppendColorBoldText(this System.Windows.Forms.RichTextBox box, string text, System.Drawing.Color color) { box.SelectionFont = new Font(box.Font, FontStyle.Bold); box.SelectionColor = color; box.AppendText(text); box.SelectionFont = new Font(box.Font, FontStyle.Regular); box.SelectionColor = box.ForeColor; }
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; }
/// <summary> /// Appends <see cref="text"/> of color <see cref="color"/> to <see cref="richTextBox"/>. /// </summary> /// <param name="richTextBox">The <see cref="RichTextBox"/> to which <see cref="text"/> should be appended.</param> /// <param name="text">The text to be appended.</param> /// <param name="color">The color of the text to be appended</param> public static void AppendColoredText(this RichTextBox richTextBox, string text, Color color) { int intialLength = richTextBox.TextLength; richTextBox.AppendText(text); richTextBox.Select(intialLength, richTextBox.TextLength); richTextBox.SelectionColor = color; richTextBox.DeselectAll(); }
/// <summary> /// Restores the default search box watermark text. /// </summary> /// <param name="richTextBox">The rich text box.</param> /// <param name="defaultText">The default text.</param> /// <param name="isRealTextSet">if set to <c>true</c> real text is set.</param> public static void RestoreDefaultText(this RichTextBox richTextBox, string defaultText, ref bool isRealTextSet) { if (string.IsNullOrEmpty(richTextBox.GetText())) { richTextBox.AppendText(defaultText); isRealTextSet = false; } }
/// <summary> /// This appends text of a certain color in a RichTextBox /// </summary> /// <param name="box">The RichTextBox </param> /// <param name="text">Text being added</param> /// <param name="color">The color of the text</param> public static void AppendText(this System.Windows.Forms.RichTextBox box, string text, System.Drawing.Color color) { /* box.SelectionStart = box.TextLength; box.SelectionLength = 0; */ //testing! box.SelectionColor = color; box.AppendText(text); box.SelectionColor = box.ForeColor; }
public static void AppendColorLine(this RichTextBox box, Color color, string line) { box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.AppendText(line + Environment.NewLine); box.SelectionColor = box.ForeColor; }
public static void AgregarLinea(this RichTextBox source, string value) { if (source.Text.Length == 0) source.Text = value; else source.AppendText("\r\n" + value); source.ScrollToCaret(); }
/// <summary> /// method to display the data to & from the port /// on the screen /// </summary> /// <param name="type">MessageType of the message</param> /// <param name="msg">Message to display</param> public static void InvokeDisplayMessage(this RichTextBox TextBox, string message, MessageType type, bool addNewline = true) { TextBox.Invoke(new Action(() => { TextBox.SelectedText = string.Empty; TextBox.SelectionFont = new Font(TextBox.SelectionFont, FontStyle.Bold); TextBox.SelectionColor = type.GetFontColor(); if (type == MessageType.Incoming) TextBox.AppendText(String.Format("{0} <- ", DateTime.Now)); if (type == MessageType.Outgoing) TextBox.AppendText(String.Format("{0} -> ", DateTime.Now)); if (type == MessageType.Error) TextBox.AppendText(String.Format("{0} ", DateTime.Now)); TextBox.AppendText(message); if (addNewline) TextBox.AppendText("\n"); TextBox.ScrollToCaret(); })); }
public static void AppendText(this RichTextBox box, string text, Color color, bool bold) { box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.SelectionFont = new Font(box.Font, bold ? FontStyle.Bold : FontStyle.Regular); box.AppendText(text); box.SelectionColor = box.ForeColor; }
public static RichTextBox append_Text(this RichTextBox richTextBox, string contents) { return (RichTextBox)richTextBox.invokeOnThread( () => { if (contents!= null) richTextBox.AppendText(contents); return richTextBox; }); }
public static void AppendColoredText(this RichTextBox box, string text, Color color) { box.SelectionColor = color; box.AppendText(text); box.SelectionColor = box.ForeColor; box.SelectionStart = 0; box.SelectionLength = box.TextLength; box.SelectionFont = new Font(new FontFamily("Consolas"), 10); }
public static void AppendColouredText(this RichTextBox box, string text, Color color) { int start = box.TextLength; box.AppendText(text); int oldStart = box.SelectionStart; box.SelectionStart = start; box.SelectionLength = text.Length; box.SelectionColor = color; box.SelectionStart = oldStart; }
public static void AddString(this RichTextBox textBox, Color foreColor, String format, params object[] args) { PerformOnMainThread(textBox, () => { Int32 pos = textBox.TextLength; textBox.AppendText(String.Format(format, args)); textBox.Select(pos, textBox.TextLength); textBox.SelectionColor = foreColor; }); }
public static void AppendText(this ConsoleRichTextbox box, string text, Color color) { box._Paint = false; box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.AppendText(text); box.SelectionColor = box.ForeColor; box._Paint = true; }
public static void AppendText(this RichTextBoxAdvanced box, string text, Color foreColor, Color backColor) { text += '\n'; box.SelectionStart = box.TextLength; box.SelectionLength = text.Length; box.SelectionColor = foreColor; box.SelectionBackColor = backColor; box.AppendText(text); }
public static void AppendTextInvoke(this RichTextBox box, string text, bool isDesc = false) { if (box != null) { if (box.IsHandleCreated) { if (box.InvokeRequired) { box.Invoke((Action)delegate { box.AppendText(text); }); } else { box.AppendText(text); } } } }