1- using System ;
1+ using Newtonsoft . Json ;
2+
3+ using System ;
24using System . Drawing ;
35using System . Text . RegularExpressions ;
4- using Newtonsoft . Json ;
5- //using System.Linq;
66
77namespace LogExpert . Classes . Highlight
88{
99 [ Serializable ]
10- public class HilightEntry
10+ [ method: JsonConstructor ]
11+ public class HilightEntry ( ) : ICloneable
1112 {
1213 #region Fields
1314
14- private ActionEntry actionEntry ;
15- private Color bgColor ;
16- private string bookmarkComment ;
17- private Color fgColor ;
18- private bool isActionEntry ;
19- private bool isBold ;
20- private bool isCaseSensitive ;
21- private bool isLedSwitch ;
22- private bool isRegEx ;
23-
24- [ NonSerialized ] private bool isSearchHit ; // highlightes search result
25-
26- private bool isSetBookmark ;
27- private bool isStopTail ;
28- private bool isWordMatch ;
29- private bool noBackground ;
30-
3115 [ NonSerialized ] private Regex regex = null ;
3216
33- private string searchText = "" ;
34-
35- #endregion
36-
37- #region cTor
38-
39- [ JsonConstructor ]
40- public HilightEntry ( )
41- {
42-
43- }
44-
45- public HilightEntry ( string searchText , Color fgColor , Color bgColor , bool isWordMatch )
46- {
47- this . searchText = searchText ;
48- this . fgColor = fgColor ;
49- this . bgColor = bgColor ;
50- this . isRegEx = false ;
51- this . isCaseSensitive = false ;
52- this . isLedSwitch = false ;
53- this . isStopTail = false ;
54- this . isSetBookmark = false ;
55- this . isActionEntry = false ;
56- this . actionEntry = null ;
57- this . IsWordMatch = isWordMatch ;
58- }
59-
60-
61- public HilightEntry ( string searchText , Color fgColor , Color bgColor ,
62- bool isRegEx , bool isCaseSensitive , bool isLedSwitch ,
63- bool isStopTail , bool isSetBookmark , bool isActionEntry , ActionEntry actionEntry , bool isWordMatch )
64- {
65- this . searchText = searchText ;
66- this . fgColor = fgColor ;
67- this . bgColor = bgColor ;
68- this . isRegEx = isRegEx ;
69- this . isCaseSensitive = isCaseSensitive ;
70- this . isLedSwitch = isLedSwitch ;
71- this . isStopTail = isStopTail ;
72- this . isSetBookmark = isSetBookmark ;
73- this . isActionEntry = isActionEntry ;
74- this . actionEntry = actionEntry ;
75- this . IsWordMatch = isWordMatch ;
76- }
17+ private string _searchText = string . Empty ;
7718
78- #endregion
19+ #endregion Fields
7920
8021 #region Properties
8122
82- public bool IsStopTail
83- {
84- get { return isStopTail ; }
85- set { isStopTail = value ; }
86- }
23+ public bool IsStopTail { get ; set ; }
8724
88- public bool IsSetBookmark
89- {
90- get { return isSetBookmark ; }
91- set { isSetBookmark = value ; }
92- }
25+ public bool IsSetBookmark { get ; set ; }
9326
94- public bool IsRegEx
95- {
96- get { return isRegEx ; }
97- set { isRegEx = value ; }
98- }
27+ public bool IsRegEx { get ; set ; }
9928
100- public bool IsCaseSensitive
101- {
102- get { return isCaseSensitive ; }
103- set
104- {
105- isCaseSensitive = value ;
106- this . regex = null ;
107- }
108- }
29+ public bool IsCaseSensitive { get ; set ; }
10930
31+ public Color ForegroundColor { get ; set ; }
11032
111- public Color ForegroundColor
112- {
113- get { return this . fgColor ; }
114- set { this . fgColor = value ; }
115- }
116-
117- public Color BackgroundColor
118- {
119- get { return this . bgColor ; }
120- set { this . bgColor = value ; }
121- }
33+ public Color BackgroundColor { get ; set ; }
12234
12335 public string SearchText
12436 {
125- get { return this . searchText ; }
37+ get => _searchText ;
12638 set
12739 {
128- this . searchText = value ;
129- this . regex = null ;
40+ _searchText = value ;
41+ regex = null ;
13042 }
13143 }
13244
133- public bool IsLedSwitch
134- {
135- get { return this . isLedSwitch ; }
136- set { this . isLedSwitch = value ; }
137- }
45+ public bool IsLedSwitch { get ; set ; }
13846
139- public ActionEntry ActionEntry
140- {
141- get { return this . actionEntry ; }
142- set { this . actionEntry = value ; }
143- }
47+ public ActionEntry ActionEntry { get ; set ; }
14448
145- public bool IsActionEntry
146- {
147- get { return this . isActionEntry ; }
148- set { this . isActionEntry = value ; }
149- }
49+ public bool IsActionEntry { get ; set ; }
15050
151- public string BookmarkComment
152- {
153- get { return this . bookmarkComment ; }
154- set { this . bookmarkComment = value ; }
155- }
51+ public string BookmarkComment { get ; set ; }
15652
15753 public Regex Regex
15854 {
15955 get
16056 {
161- if ( this . regex == null )
57+ if ( regex == null )
16258 {
163- if ( this . IsRegEx )
59+ if ( IsRegEx )
16460 {
165- this . regex = new Regex ( this . SearchText ,
166- this . IsCaseSensitive ? RegexOptions . None : RegexOptions . IgnoreCase ) ;
61+ regex = new Regex ( SearchText , IsCaseSensitive ? RegexOptions . None : RegexOptions . IgnoreCase ) ;
16762 }
16863 else
16964 {
170- this . regex = new Regex ( Regex . Escape ( this . SearchText ) ,
171- this . IsCaseSensitive ? RegexOptions . None : RegexOptions . IgnoreCase ) ;
65+ regex = new Regex ( Regex . Escape ( SearchText ) , IsCaseSensitive ? RegexOptions . None : RegexOptions . IgnoreCase ) ;
17266 }
17367 }
174- return this . regex ;
68+ return regex ;
17569 }
17670 }
17771
178- public bool IsWordMatch
179- {
180- get { return this . isWordMatch ; }
181- set { this . isWordMatch = value ; }
182- }
72+ public bool IsWordMatch { get ; set ; }
18373
184- public bool IsSearchHit
185- {
186- get { return this . isSearchHit ; }
187- set { this . isSearchHit = value ; }
188- }
74+ // highlightes search result
75+ [ field: NonSerialized ]
76+ public bool IsSearchHit { get ; set ; }
18977
190- public bool IsBold
191- {
192- get { return this . isBold ; }
193- set { this . isBold = value ; }
194- }
78+ public bool IsBold { get ; set ; }
19579
196- public bool NoBackground
197- {
198- get { return noBackground ; }
199- set { noBackground = value ; }
200- }
80+ public bool NoBackground { get ; set ; }
20181
202- #endregion
82+ public object Clone ( )
83+ {
84+ var highLightEntry = new HilightEntry
85+ {
86+ SearchText = SearchText ,
87+ ForegroundColor = ForegroundColor ,
88+ BackgroundColor = BackgroundColor ,
89+ IsRegEx = IsRegEx ,
90+ IsCaseSensitive = IsCaseSensitive ,
91+ IsLedSwitch = IsLedSwitch ,
92+ IsStopTail = IsStopTail ,
93+ IsSetBookmark = IsSetBookmark ,
94+ IsActionEntry = IsActionEntry ,
95+ ActionEntry = ActionEntry != null ? ( ActionEntry ) ActionEntry . Clone ( ) : null ,
96+ IsWordMatch = IsWordMatch ,
97+ IsBold = IsBold ,
98+ BookmarkComment = BookmarkComment ,
99+ NoBackground = NoBackground ,
100+ IsSearchHit = IsSearchHit
101+ } ;
102+
103+ return highLightEntry ;
104+ }
105+
106+ #endregion Properties
203107 }
204108}
0 commit comments