11using System ;
22using System . Collections . Generic ;
33using System . Collections . ObjectModel ;
4- using System . ComponentModel ;
54using System . Drawing ;
65using System . Linq ;
76using System . Text . RegularExpressions ;
@@ -213,7 +212,6 @@ public RichTextBoxTarget()
213212 /// Gets or sets a value indicating whether to use default coloring rules.
214213 /// </summary>
215214 /// <docgen category='Highlighting Options' order='10' />
216- [ DefaultValue ( false ) ]
217215 public bool UseDefaultRowColoringRules { get ; set ; }
218216
219217 /// <summary>
@@ -238,7 +236,6 @@ public RichTextBoxTarget()
238236 /// Tool windows have thin border, and do not show up in the task bar.
239237 /// </remarks>
240238 /// <docgen category='Form Options' order='10' />
241- [ DefaultValue ( true ) ]
242239 public bool ToolWindow { get ; set ; }
243240
244241 /// <summary>
@@ -305,7 +302,6 @@ public RichTextBoxTarget()
305302 /// If set to false and the control was not found during target initialization, the target would skip events until the control is found during <see cref="ReInitializeAllTextboxes(System.Windows.Forms.Form)"/> call
306303 /// </remarks>
307304 /// <docgen category='Form Options' order='10' />
308- [ DefaultValue ( true ) ]
309305 public bool AllowAccessoryFormCreation { get ; set ; }
310306
311307
@@ -315,7 +311,6 @@ public RichTextBoxTarget()
315311 /// <remarks>
316312 /// </remarks>
317313 /// <docgen category='Form Options' order='10' />
318- [ DefaultValue ( RichTextBoxTargetMessageRetentionStrategy . None ) ]
319314 public RichTextBoxTargetMessageRetentionStrategy MessageRetention
320315 {
321316 get { return messageRetention ; }
@@ -364,13 +359,10 @@ public RichTextBoxTargetMessageRetentionStrategy MessageRetention
364359 /// </summary>
365360 private volatile Queue < MessageInfo > messageQueue ;
366361
367-
368-
369362 /// <summary>
370363 /// If set to true, using "rtb-link" renderer (<see cref="RichTextBoxLinkLayoutRenderer"/>) would create clickable links in the control.
371364 /// <seealso cref="LinkClicked"/>
372365 /// </summary>
373- [ DefaultValue ( false ) ]
374366 public bool SupportLinks
375367 {
376368 get { return supportLinks ; }
@@ -711,7 +703,7 @@ private void DetachFromControl()
711703 }
712704 catch ( Exception ex )
713705 {
714- InternalLogger . Warn ( ex . ToString ( ) ) ;
706+ InternalLogger . Warn ( ex , "Failed DetachFromControl" ) ;
715707
716708 if ( LogManager . ThrowExceptions )
717709 {
@@ -811,7 +803,7 @@ private bool DoSendMessageToTextbox(string logMessage, RichTextBoxRowColoringRul
811803 }
812804 catch ( Exception ex )
813805 {
814- InternalLogger . Warn ( ex . ToString ( ) ) ;
806+ InternalLogger . Warn ( ex , "Failed to append RichTextBox" ) ;
815807
816808 if ( LogManager . ThrowExceptions )
817809 {
@@ -879,7 +871,12 @@ private void SendTheMessageToRichTextBox(string logMessage, RichTextBoxRowColori
879871 // find word to color
880872 foreach ( RichTextBoxWordColoringRule wordRule in WordColoringRules )
881873 {
882- MatchCollection matches = wordRule . CompileRegex ( logEvent ) . Matches ( textBox . Text , startIndex ) ;
874+ var wordRulePattern = RenderLogEvent ( wordRule . Regex , logEvent ) ;
875+ var wordRuleText = RenderLogEvent ( wordRule . Text , logEvent ) ;
876+ var wordRuleWholeWords = RenderLogEvent ( wordRule . WholeWords , logEvent ) ;
877+ var wordRuleIgnoreCase = RenderLogEvent ( wordRule . IgnoreCase , logEvent ) ;
878+
879+ MatchCollection matches = wordRule . ResolveRegEx ( wordRulePattern , wordRuleText , wordRuleWholeWords , wordRuleIgnoreCase ) . Matches ( textBox . Text , startIndex ) ;
883880 foreach ( Match match in matches )
884881 {
885882 textBox . SelectionStart = match . Index ;
@@ -993,7 +990,7 @@ private void StoreMessage(string logMessage, RichTextBoxRowColoringRule rule, Lo
993990 }
994991 }
995992
996- private class MessageInfo
993+ private sealed class MessageInfo
997994 {
998995 internal string Message { get ; private set ; }
999996 internal RichTextBoxRowColoringRule Rule { get ; private set ; }
0 commit comments