@@ -90,24 +90,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri
9090
9191 public static Color GetBackColorFromHighlightEntry ( HighlightEntry ? entry )
9292 {
93- var bgColor = Color . White ;
94-
95- if ( ! DebugOptions . DisableWordHighlight )
96- {
97- if ( entry != null )
98- {
99- bgColor = entry . BackgroundColor ;
100- }
101- }
102- else
103- {
104- if ( entry != null )
105- {
106- bgColor = entry . BackgroundColor ;
107- }
108- }
109-
110- return bgColor ;
93+ return entry ? . BackgroundColor ?? Color . White ;
11194 }
11295
11396 [ SupportedOSPlatform ( "windows" ) ]
@@ -305,52 +288,24 @@ public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bo
305288 }
306289
307290 [ SupportedOSPlatform ( "windows" ) ]
308- public static Rectangle BorderWidths ( DataGridViewAdvancedBorderStyle advancedBorderStyle )
291+ public static Rectangle BorderWidths ( DataGridViewAdvancedBorderStyle style )
309292 {
310- Rectangle rect = new ( )
311- {
312- X = advancedBorderStyle . Left == DataGridViewAdvancedCellBorderStyle . None
313- ? 0
314- : 1
315- } ;
316-
317- if ( advancedBorderStyle . Left is DataGridViewAdvancedCellBorderStyle . OutsetDouble or DataGridViewAdvancedCellBorderStyle . InsetDouble )
318- {
319- rect . X ++ ;
320- }
321-
322- rect . Y = advancedBorderStyle . Top == DataGridViewAdvancedCellBorderStyle . None
323- ? 0
324- : 1 ;
325-
326- if ( advancedBorderStyle . Top is DataGridViewAdvancedCellBorderStyle . OutsetDouble or DataGridViewAdvancedCellBorderStyle . InsetDouble )
327- {
328- rect . Y ++ ;
329- }
330-
331- rect . Width = advancedBorderStyle . Right == DataGridViewAdvancedCellBorderStyle . None
332- ? 0
333- : 1 ;
334-
335- if ( advancedBorderStyle . Right is DataGridViewAdvancedCellBorderStyle . OutsetDouble or DataGridViewAdvancedCellBorderStyle . InsetDouble )
336- {
337- rect . Width ++ ;
338- }
339-
340- rect . Height = advancedBorderStyle . Bottom == DataGridViewAdvancedCellBorderStyle . None
341- ? 0
342- : 1 ;
293+ return new Rectangle (
294+ GetBorderSize ( style . Left ) ,
295+ GetBorderSize ( style . Top ) ,
296+ GetBorderSize ( style . Right ) ,
297+ GetBorderSize ( style . Bottom ) ) ;
298+ }
343299
344- if ( advancedBorderStyle . Bottom is DataGridViewAdvancedCellBorderStyle . OutsetDouble or
345- DataGridViewAdvancedCellBorderStyle . InsetDouble )
300+ [ SupportedOSPlatform ( "windows" ) ]
301+ private static int GetBorderSize ( DataGridViewAdvancedCellBorderStyle borderStyle )
302+ {
303+ return borderStyle switch
346304 {
347- rect . Height ++ ;
348- }
349-
350- //rect.Width += this.owningColumn.DividerWidth;
351- //rect.Height += this.owningRow.DividerHeight;
352-
353- return rect ;
305+ DataGridViewAdvancedCellBorderStyle . None => 0 ,
306+ DataGridViewAdvancedCellBorderStyle . InsetDouble or DataGridViewAdvancedCellBorderStyle . OutsetDouble => 2 ,
307+ _ => 1
308+ } ;
354309 }
355310
356311 #endregion
@@ -366,9 +321,10 @@ private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellP
366321 [ SupportedOSPlatform ( "windows" ) ]
367322 private static void PaintHighlightedCell ( ILogPaintContextUI logPaintCtx , DataGridViewCellPaintingEventArgs e , BufferedDataGridView gridView , bool noBackgroundFill , HighlightEntry groundEntry )
368323 {
324+ //TODO Refactor if possible since Column is ITextValue
369325 var value = e . Value ?? string . Empty ;
370326
371- var matchList = logPaintCtx . FindHighlightMatches ( value as ILogLine ) ;
327+ var matchList = logPaintCtx . FindHighlightMatches ( value as ITextValue ) ;
372328 // too many entries per line seem to cause problems with the GDI
373329 while ( matchList . Count > 50 )
374330 {
@@ -463,18 +419,18 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr
463419 Rectangle wordRect = new ( wordPos , wordSize ) ;
464420
465421 var foreColor = matchEntry . HighlightEntry . ForegroundColor ;
466- if ( ( e . State & DataGridViewElementStates . Selected ) != DataGridViewElementStates . Selected )
422+ if ( e . State . HasFlag ( DataGridViewElementStates . Selected ) )
467423 {
468- if ( ! noBackgroundFill && bgBrush != null && ! matchEntry . HighlightEntry . NoBackground )
424+ if ( foreColor . Equals ( Color . Black ) )
469425 {
470- e . Graphics . FillRectangle ( bgBrush , wordRect ) ;
426+ foreColor = Color . White ;
471427 }
472428 }
473429 else
474430 {
475- if ( foreColor . Equals ( Color . Black ) )
431+ if ( ! noBackgroundFill && bgBrush != null && ! matchEntry . HighlightEntry . NoBackground )
476432 {
477- foreColor = Color . White ;
433+ e . Graphics . FillRectangle ( bgBrush , wordRect ) ;
478434 }
479435 }
480436
0 commit comments