/// <summary> /// Adds the elements of an array to the end of this RichTextBoxRowColoringRuleCollection. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the end of this RichTextBoxRowColoringRuleCollection. /// </param> public virtual void AddRange(RichTextBoxRowColoringRule[] items) { foreach (RichTextBoxRowColoringRule item in items) { this.List.Add(item); } }
private void SendTheMessageToRichTextBox(RichTextBox rtbx, string logMessage, RichTextBoxRowColoringRule rule) { int startIndex = rtbx.Text.Length; rtbx.SelectionStart = startIndex; #if DOTNET_2_0 rtbx.SelectionBackColor = GetColorFromString(rule.BackgroundColor, rtbx.BackColor); #endif rtbx.SelectionColor = GetColorFromString(rule.FontColor, rtbx.ForeColor); rtbx.SelectionFont = new Font(rtbx.SelectionFont, rtbx.SelectionFont.Style ^ rule.Style); rtbx.AppendText(logMessage + "\n"); rtbx.SelectionLength = rtbx.Text.Length - rtbx.SelectionStart; // find word to color foreach (RichTextBoxWordColoringRule wordRule in WordColoringRules) { MatchCollection mc = wordRule.CompiledRegex.Matches(rtbx.Text, startIndex); foreach (Match m in mc) { rtbx.SelectionStart = m.Index; rtbx.SelectionLength = m.Length; #if DOTNET_2_0 rtbx.SelectionBackColor = GetColorFromString(wordRule.BackgroundColor, rtbx.BackColor); #endif rtbx.SelectionColor = GetColorFromString(wordRule.FontColor, rtbx.ForeColor); rtbx.SelectionFont = new Font(rtbx.SelectionFont, rtbx.SelectionFont.Style ^ wordRule.Style); } } }
private void FindRichTextBoxAndSendTheMessage(string logMessage, RichTextBoxRowColoringRule rule) { Form form = null; bool createdForm = false; if (Form.ActiveForm != null && Form.ActiveForm.Name == FormName) { form = Form.ActiveForm; } #if DOTNET_2_0 if (form == null && Application.OpenForms[FormName] != null) form = Application.OpenForms[FormName]; #endif if (form == null) { form = FormHelper.CreateForm(FormName, 0, 0, true); createdForm = true; } RichTextBox rtbx = (RichTextBox)FormHelper.FindControl(ControlName, form, typeof(RichTextBox)); if (rtbx == null && createdForm) rtbx = FormHelper.CreateRichTextBox(ControlName, form); else if (rtbx == null && !createdForm) return; rtbx.Invoke(new DelSendTheMessageToRichTextBox(SendTheMessageToRichTextBox), new object[] { rtbx, logMessage, rule }); }
/// <summary> /// Initializes a new instance of the RichTextBoxRowColoringRuleCollection class, containing elements /// copied from an array. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the new RichTextBoxRowColoringRuleCollection. /// </param> public RichTextBoxRowColoringRuleCollection(RichTextBoxRowColoringRule[] items) { this.AddRange(items); }
/// <summary> /// Removes the first occurrence of a specific RichTextBoxRowColoringRule from this RichTextBoxRowColoringRuleCollection. /// </summary> /// <param name="value"> /// The RichTextBoxRowColoringRule value to remove from this RichTextBoxRowColoringRuleCollection. /// </param> public virtual void Remove(RichTextBoxRowColoringRule value) { this.List.Remove(value); }
/// <summary> /// Inserts an element into the RichTextBoxRowColoringRuleCollection at the specified index /// </summary> /// <param name="index"> /// The index at which the RichTextBoxRowColoringRule is to be inserted. /// </param> /// <param name="value"> /// The RichTextBoxRowColoringRule to insert. /// </param> public virtual void Insert(int index, RichTextBoxRowColoringRule value) { this.List.Insert(index, value); }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this RichTextBoxRowColoringRuleCollection /// </summary> /// <param name="value"> /// The RichTextBoxRowColoringRule value to locate in the RichTextBoxRowColoringRuleCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(RichTextBoxRowColoringRule value) { return this.List.IndexOf(value); }
/// <summary> /// Determines whether a specfic RichTextBoxRowColoringRule value is in this RichTextBoxRowColoringRuleCollection. /// </summary> /// <param name="value"> /// The RichTextBoxRowColoringRule value to locate in this RichTextBoxRowColoringRuleCollection. /// </param> /// <returns> /// true if value is found in this RichTextBoxRowColoringRuleCollection; /// false otherwise. /// </returns> public virtual bool Contains(RichTextBoxRowColoringRule value) { return this.List.Contains(value); }
/// <summary> /// Adds an instance of type RichTextBoxWordColoringRule to the end of this RichTextBoxRowColoringRuleCollection. /// </summary> /// <param name="value"> /// The RichTextBoxRowColoringRule to be added to the end of this RichTextBoxRowColoringRuleCollection. /// </param> public virtual void Add(RichTextBoxRowColoringRule value) { this.List.Add(value); }