Exemplo n.º 1
0
 private void FindRichTextBoxAndSendTheMessage(string logMessage, RichTextBoxRowColoringRule rule)
 {
     if (_control != null)
     {
         _control.Invoke(new DelSendTheMessageToRichTextBox(SendTheMessageToRichTextBox), new object[] { _control, logMessage, rule });
     }
 }
Exemplo n.º 2
0
        protected override void Write(LogEventInfo logEvent)
        {
            RichTextBoxRowColoringRule matchingRule = null;

            foreach (RichTextBoxRowColoringRule rr in RowColoringRules)
            {
                if (rr.CheckCondition(logEvent))
                {
                    matchingRule = rr;
                    break;
                }
            }

            if (UseDefaultRowColoringRules && matchingRule == null)
            {
                foreach (RichTextBoxRowColoringRule rr in _defaultRichTextBoxRowColoringRules)
                {
                    if (rr.CheckCondition(logEvent))
                    {
                        matchingRule = rr;
                        break;
                    }
                }
            }

            if (matchingRule == null)
            {
                matchingRule = RichTextBoxRowColoringRule.Default;
            }

            string logMessage = CompiledLayout.GetFormattedMessage(logEvent);

            FindRichTextBoxAndSendTheMessage(logMessage, matchingRule);
        }
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
0
 /// <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);
 }
Exemplo n.º 5
0
 /// <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));
 }
Exemplo n.º 6
0
 /// <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));
 }
Exemplo n.º 7
0
 /// <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);
 }
Exemplo n.º 8
0
        private void SendTheMessageToRichTextBox(RichTextBox rtbx, string logMessage, RichTextBoxRowColoringRule rule)
        {
            int startIndex = rtbx.TextLength;

            rtbx.SelectionStart     = startIndex;
            rtbx.SelectionBackColor = GetColorFromString(rule.BackgroundColor, rtbx.BackColor);
            rtbx.SelectionColor     = GetColorFromString(rule.FontColor, rtbx.ForeColor);
            rtbx.SelectionFont      = new Font(rtbx.SelectionFont, rtbx.SelectionFont.Style ^ rule.Style);
            rtbx.AppendText(logMessage + "\n");
            int newLength = rtbx.TextLength;

            if (newLength > _maxLength)
            {
                rtbx.ReadOnly = false;
                rtbx.Select(0, newLength - (int)(_maxLength * 0.8));
                rtbx.SelectedText = "";
                rtbx.ReadOnly     = true;
            }

            // 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;
            //        rtbx.SelectionBackColor = GetColorFromString(wordRule.BackgroundColor, rtbx.BackColor);
            //        rtbx.SelectionColor = GetColorFromString(wordRule.FontColor, rtbx.ForeColor);
            //        rtbx.SelectionFont = new Font(rtbx.SelectionFont, rtbx.SelectionFont.Style ^ wordRule.Style);
            //    }
            //}

            ScrollTextBoxEnd(rtbx);
        }