@@ -30,8 +30,8 @@ public class TableControl : IWindowControl, IDOMPaintable, IMouseAwareControl
3030
3131 private HorizontalAlignment _horizontalAlignment = HorizontalAlignment . Left ;
3232 private VerticalAlignment _verticalAlignment = VerticalAlignment . Top ;
33- private Color ? _backgroundColorValue ;
34- private Color ? _foregroundColorValue ;
33+ private Color ? _backgroundColorValue = Color . Default ;
34+ private Color ? _foregroundColorValue = Color . Default ;
3535 private Margin _margin = new Margin ( 0 , 0 , 0 , 0 ) ;
3636 private StickyPosition _stickyPosition = StickyPosition . None ;
3737 private bool _visible = true ;
@@ -43,8 +43,8 @@ public class TableControl : IWindowControl, IDOMPaintable, IMouseAwareControl
4343 private List < TableRow > _rows = new ( ) ;
4444 private BorderStyle _borderStyle = BorderStyle . Single ;
4545 private Color ? _borderColorValue ;
46- private Color ? _headerBackgroundColorValue ;
47- private Color ? _headerForegroundColorValue ;
46+ private Color ? _headerBackgroundColorValue = Color . Default ;
47+ private Color ? _headerForegroundColorValue = Color . Default ;
4848 private bool _showHeader = true ;
4949 private bool _showRowSeparators = false ;
5050 private bool _useSafeBorder = false ;
@@ -485,41 +485,66 @@ public void SetData(IEnumerable<TableRow> rows)
485485
486486 #region Color Resolution Methods
487487
488+ /// <summary>
489+ /// Three-state resolution: null = inherit from container,
490+ /// Color.Default = use theme, explicit color = use as-is.
491+ /// </summary>
488492 private Color ResolveBackgroundColor ( Color defaultBg )
489493 {
490- var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
491- return _backgroundColorValue
492- ?? theme ? . TableBackgroundColor
493- ?? Container ? . BackgroundColor
494- ?? defaultBg ;
494+ if ( _backgroundColorValue == null )
495+ return Container ? . BackgroundColor ?? defaultBg ;
496+ if ( _backgroundColorValue . Value == Color . Default )
497+ {
498+ var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
499+ return theme ? . TableBackgroundColor
500+ ?? Container ? . BackgroundColor
501+ ?? defaultBg ;
502+ }
503+ return _backgroundColorValue . Value ;
495504 }
496505
497506 private Color ResolveForegroundColor ( Color defaultFg )
498507 {
499- var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
500- return _foregroundColorValue
501- ?? theme ? . TableForegroundColor
502- ?? Container ? . ForegroundColor
503- ?? defaultFg ;
508+ if ( _foregroundColorValue == null )
509+ return Container ? . ForegroundColor ?? defaultFg ;
510+ if ( _foregroundColorValue . Value == Color . Default )
511+ {
512+ var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
513+ return theme ? . TableForegroundColor
514+ ?? Container ? . ForegroundColor
515+ ?? defaultFg ;
516+ }
517+ return _foregroundColorValue . Value ;
504518 }
505519
506520 private Color ResolveHeaderBackgroundColor ( )
507521 {
508- var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
509- return _headerBackgroundColorValue
510- ?? theme ? . TableHeaderBackgroundColor
511- ?? theme ? . TableBackgroundColor
512- ?? Container ? . BackgroundColor
513- ?? Color . Black ;
522+ if ( _headerBackgroundColorValue == null )
523+ return Container ? . BackgroundColor ?? Color . Black ;
524+ if ( _headerBackgroundColorValue . Value == Color . Default )
525+ {
526+ var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
527+ return theme ? . TableHeaderBackgroundColor
528+ ?? theme ? . TableBackgroundColor
529+ ?? Container ? . BackgroundColor
530+ ?? Color . Black ;
531+ }
532+ return _headerBackgroundColorValue . Value ;
514533 }
515534
516535 private Color ResolveHeaderForegroundColor ( )
517536 {
518- var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
519- return _headerForegroundColorValue
520- ?? theme ? . TableHeaderForegroundColor
521- ?? theme ? . TableForegroundColor
522- ?? Color . White ;
537+ if ( _headerForegroundColorValue == null )
538+ return Container ? . ForegroundColor ?? Color . White ;
539+ if ( _headerForegroundColorValue . Value == Color . Default )
540+ {
541+ var theme = Container ? . GetConsoleWindowSystem ? . Theme ;
542+ return theme ? . TableHeaderForegroundColor
543+ ?? theme ? . TableForegroundColor
544+ ?? Container ? . ForegroundColor
545+ ?? Color . White ;
546+ }
547+ return _headerForegroundColorValue . Value ;
523548 }
524549
525550 private Color ResolveBorderColor ( )
0 commit comments