Class ColorResolver
- Namespace
- SharpConsoleUI.Helpers
- Assembly
- SharpConsoleUI.dll
Provides centralized color resolution logic for controls. Extracted from 11+ controls that had identical cascading null-coalescing chains.
public static class ColorResolver
- Inheritance
-
ColorResolver
- Inherited Members
Methods
ResolveBackground(Color?, IContainer?, Color)
Resolves a background color using the standard fallback chain: explicit value → container background → theme window background → default.
public static Color ResolveBackground(Color? explicitValue, IContainer? container, Color defaultColor = default)
Parameters
explicitValueColor?The explicitly set color value, if any.
containerIContainerThe parent container to inherit colors from.
defaultColorColorThe default color to use if no other source is available. Defaults to Black.
Returns
- Color
The resolved background color.
ResolveForeground(Color?, IContainer?, Color)
Resolves a foreground color using the standard fallback chain: explicit value → container foreground → theme window foreground → default.
public static Color ResolveForeground(Color? explicitValue, IContainer? container, Color defaultColor = default)
Parameters
explicitValueColor?The explicitly set color value, if any.
containerIContainerThe parent container to inherit colors from.
defaultColorColorThe default color to use if no other source is available. Defaults to White.
Returns
- Color
The resolved foreground color.
ResolveMenuBarBackground(Color?, IContainer?, Color)
Resolves a menu bar background color using the menu-specific fallback chain.
public static Color ResolveMenuBarBackground(Color? explicitValue, IContainer? container, Color defaultColor = default)
Parameters
explicitValueColor?The explicitly set color value, if any.
containerIContainerThe parent container to inherit colors from.
defaultColorColorThe default color to use if no other source is available. Defaults to Black.
Returns
- Color
The resolved menu bar background color.
ResolveMenuBarForeground(Color?, IContainer?, Color)
Resolves a menu bar foreground color using the menu-specific fallback chain.
public static Color ResolveMenuBarForeground(Color? explicitValue, IContainer? container, Color defaultColor = default)
Parameters
explicitValueColor?The explicitly set color value, if any.
containerIContainerThe parent container to inherit colors from.
defaultColorColorThe default color to use if no other source is available. Defaults to White.
Returns
- Color
The resolved menu bar foreground color.