@@ -86,8 +86,8 @@ public FontStyle? FontStyle {
8686 }
8787
8888 /// <summary>
89- /// Gets/sets the underline flag. Null if the underline status does not change the font style.
90- /// </summary>
89+ /// Gets/sets the underline flag. Null if the underline status does not change the font style.
90+ /// </summary>
9191 public bool ? Underline {
9292 get {
9393 return underline ;
@@ -97,7 +97,7 @@ public bool? Underline {
9797 throw new InvalidOperationException ( ) ;
9898 underline = value ;
9999 }
100- }
100+ }
101101
102102 /// <summary>
103103 /// Gets/sets the foreground color applied by the highlighting.
@@ -146,6 +146,8 @@ protected HighlightingColor(SerializationInfo info, StreamingContext context)
146146 this . FontWeight = System . Windows . FontWeight . FromOpenTypeWeight ( info . GetInt32 ( "Weight" ) ) ;
147147 if ( info . GetBoolean ( "HasStyle" ) )
148148 this . FontStyle = ( FontStyle ? ) new FontStyleConverter ( ) . ConvertFromInvariantString ( info . GetString ( "Style" ) ) ;
149+ if ( info . GetBoolean ( "HasUnderline" ) )
150+ this . Underline = info . GetBoolean ( "Underline" ) ;
149151 this . Foreground = ( HighlightingBrush ) info . GetValue ( "Foreground" , typeof ( HighlightingBrush ) ) ;
150152 this . Background = ( HighlightingBrush ) info . GetValue ( "Background" , typeof ( HighlightingBrush ) ) ;
151153 }
@@ -169,6 +171,9 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte
169171 info . AddValue ( "HasStyle" , this . FontStyle . HasValue ) ;
170172 if ( this . FontStyle . HasValue )
171173 info . AddValue ( "Style" , this . FontStyle . Value . ToString ( ) ) ;
174+ info . AddValue ( "HasUnderline" , this . Underline . HasValue ) ;
175+ if ( this . Underline . HasValue )
176+ info . AddValue ( "Underline" , this . Underline . Value ) ;
172177 info . AddValue ( "Foreground" , this . Foreground ) ;
173178 info . AddValue ( "Background" , this . Background ) ;
174179 }
@@ -196,6 +201,12 @@ public virtual string ToCss()
196201 b . Append ( FontStyle . Value . ToString ( ) . ToLowerInvariant ( ) ) ;
197202 b . Append ( "; " ) ;
198203 }
204+ if ( Underline != null )
205+ {
206+ b . Append ( "text-decoration: " ) ;
207+ b . Append ( Underline . Value ? "underline" : "none" ) ;
208+ b . Append ( "; " ) ;
209+ }
199210 return b . ToString ( ) ;
200211 }
201212
@@ -247,7 +258,9 @@ public virtual bool Equals(HighlightingColor other)
247258 {
248259 if ( other == null )
249260 return false ;
250- return this . name == other . name && this . fontWeight == other . fontWeight && this . fontStyle == other . fontStyle && object . Equals ( this . foreground , other . foreground ) && object . Equals ( this . background , other . background ) ;
261+ return this . name == other . name && this . fontWeight == other . fontWeight
262+ && this . fontStyle == other . fontStyle && this . underline == other . underline
263+ && object . Equals ( this . foreground , other . foreground ) && object . Equals ( this . background , other . background ) ;
251264 }
252265
253266 /// <inheritdoc/>
@@ -282,11 +295,14 @@ public void MergeWith(HighlightingColor color)
282295 this . foreground = color . foreground ;
283296 if ( color . background != null )
284297 this . background = color . background ;
298+ if ( color . underline != null )
299+ this . underline = color . underline ;
285300 }
286301
287302 internal bool IsEmptyForMerge {
288303 get {
289- return fontWeight == null && fontStyle == null && foreground == null && background == null ;
304+ return fontWeight == null && fontStyle == null && underline == null
305+ && foreground == null && background == null ;
290306 }
291307 }
292308 }
0 commit comments