Table of Contents

Class ThemeStateService

Namespace
SharpConsoleUI.Core
Assembly
SharpConsoleUI.dll

Centralized service for managing theme state. Provides change notifications when theme is updated.

public class ThemeStateService : IDisposable
Inheritance
ThemeStateService
Implements
Inherited Members

Constructors

ThemeStateService()

Creates a new theme state service with the default theme

public ThemeStateService()

ThemeStateService(ITheme, ILogService?)

Creates a new theme state service with the specified theme

public ThemeStateService(ITheme initialTheme, ILogService? logService = null)

Parameters

initialTheme ITheme
logService ILogService

Properties

CurrentTheme

Gets the current theme

public ITheme CurrentTheme { get; }

Property Value

ITheme

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetButtonColors(bool, bool)

Gets the color set for a button control based on its state

public ButtonColorSet GetButtonColors(bool isFocused, bool isEnabled)

Parameters

isFocused bool
isEnabled bool

Returns

ButtonColorSet

GetDebugInfo()

Gets a debug string representation of current theme

public string GetDebugInfo()

Returns

string

GetDesktopColors()

Gets desktop colors

public (Color Background, Color Foreground, char BackgroundChar) GetDesktopColors()

Returns

(Color Background, Color Foreground, char BackgroundChar)

GetHistory()

Gets recent theme history for debugging

public IReadOnlyList<ITheme> GetHistory()

Returns

IReadOnlyList<ITheme>

GetInputColors()

Gets input control colors

public (Color Background, Color Foreground, Color FocusedBackground, Color FocusedForeground) GetInputColors()

Returns

(Color TopBarBackground, Color TopBarForeground, Color BottomBarBackground, Color BottomBarForeground)

GetNotificationColors()

Gets notification window colors

public (Color Default, Color Info, Color Success, Color Warning, Color Danger) GetNotificationColors()

Returns

(Color Default, Color Info, Color Success, Color Warning, Color Danger)

GetStatusBarColors()

Gets status bar colors

public (Color TopBarBackground, Color TopBarForeground, Color BottomBarBackground, Color BottomBarForeground) GetStatusBarColors()

Returns

(Color TopBarBackground, Color TopBarForeground, Color BottomBarBackground, Color BottomBarForeground)

GetWindowColors(bool, bool)

Gets the color set for a window based on its state

public WindowColorSet GetWindowColors(bool isActive, bool isModal)

Parameters

isActive bool
isModal bool

Returns

WindowColorSet

NotifyPropertyChanged()

Notifies that a theme property has changed. Call this after modifying individual theme properties.

public void NotifyPropertyChanged()

SetTheme(ITheme)

Sets a new theme

public void SetTheme(ITheme newTheme)

Parameters

newTheme ITheme

SetWindowSystemContext(Func<ConsoleWindowSystem>)

Sets the window system context for window invalidation during theme changes. Must be called after ConsoleWindowSystem is fully initialized.

public void SetWindowSystemContext(Func<ConsoleWindowSystem> getContext)

Parameters

getContext Func<ConsoleWindowSystem>

ShowThemeSelector()

Shows the theme selector dialog for interactive theme selection.

public void ShowThemeSelector()

SwitchTheme(string)

Switches to a theme by name and automatically invalidates all windows.

public bool SwitchTheme(string themeName)

Parameters

themeName string

Name of the theme to switch to.

Returns

bool

True if theme was found and applied, false otherwise.

Events

ThemeChanged

Event fired when the theme changes

public event EventHandler<ThemeChangedEventArgs>? ThemeChanged

Event Type

EventHandler<ThemeChangedEventArgs>

ThemePropertyChanged

Event fired when any theme property changes (for partial updates)

public event EventHandler? ThemePropertyChanged

Event Type

EventHandler