Class StatusBarStateService
- Namespace
- SharpConsoleUI.Core
- Assembly
- SharpConsoleUI.dll
Manages status bar state, Start menu actions, and status bar bounds. Centralized state service for all status bar and start menu functionality.
public class StatusBarStateService
- Inheritance
-
StatusBarStateService
- Inherited Members
Constructors
StatusBarStateService(ILogService, Func<ConsoleWindowSystem>)
Initializes a new instance of the StatusBarStateService class.
public StatusBarStateService(ILogService logService, Func<ConsoleWindowSystem> getWindowSystem)
Parameters
logServiceILogServiceService for debug logging.
getWindowSystemFunc<ConsoleWindowSystem>Function to get the window system (lazy to avoid circular dependency).
Properties
BottomStatus
Gets or sets the text displayed in the bottom status bar.
public string BottomStatus { get; set; }
Property Value
BottomStatusBarBounds
Gets the bottom status bar bounds for mouse hit testing.
public Rectangle BottomStatusBarBounds { get; }
Property Value
ShowBottomStatus
Gets or sets whether the bottom status bar is visible. Changing this affects desktop dimensions and triggers window invalidation.
public bool ShowBottomStatus { get; set; }
Property Value
ShowTopStatus
Gets or sets whether the top status bar is visible. Changing this affects desktop dimensions and triggers window invalidation.
public bool ShowTopStatus { get; set; }
Property Value
StartButtonBounds
Gets the start button bounds for mouse hit testing.
public Rectangle StartButtonBounds { get; }
Property Value
TopStatus
Gets or sets the text displayed in the top status bar.
public string TopStatus { get; set; }
Property Value
TopStatusBarBounds
Gets the top status bar bounds for mouse hit testing.
public Rectangle TopStatusBarBounds { get; }
Property Value
Methods
GetBottomStatusHeight(bool, bool, bool, StatusBarLocation)
Gets the height occupied by the bottom status bar (0 or 1). Accounts for both status text and Start button.
public int GetBottomStatusHeight(bool showBottomStatus, bool showTaskBar, bool showStartButton, StatusBarLocation startButtonLocation)
Parameters
showBottomStatusboolWhether the bottom status bar is enabled.
showTaskBarboolWhether the task bar (window list) is enabled.
showStartButtonboolWhether the start button is enabled.
startButtonLocationStatusBarLocationLocation of the start button.
Returns
- int
Height in rows (0 or 1).
GetStartMenuActions()
Gets all registered Start menu actions.
public IReadOnlyList<StartMenuAction> GetStartMenuActions()
Returns
- IReadOnlyList<StartMenuAction>
Read-only list of actions.
GetTopStatusHeight(bool, bool)
Gets the height occupied by the top status bar (0 or 1). Accounts for both status text and performance metrics.
public int GetTopStatusHeight(bool showTopStatus, bool enablePerformanceMetrics)
Parameters
showTopStatusboolWhether the top status bar is enabled.
enablePerformanceMetricsboolWhether performance metrics are enabled.
Returns
- int
Height in rows (0 or 1).
HandleStatusBarClick(int, int)
Handles status bar mouse click (e.g., start button).
public bool HandleStatusBarClick(int x, int y)
Parameters
Returns
- bool
True if the click was handled; false otherwise.
RegisterStartMenuAction(string, Action, string?, int)
Registers a new action in the Start menu.
public void RegisterStartMenuAction(string name, Action callback, string? category = null, int order = 0)
Parameters
namestringDisplay name of the action.
callbackActionCallback to execute when action is selected.
categorystringOptional category for grouping actions.
orderintDisplay order (lower values appear first).
ShowStartMenu()
Shows the Start menu dialog.
public void ShowStartMenu()
UnregisterStartMenuAction(string)
Removes an action from the Start menu by name.
public void UnregisterStartMenuAction(string name)
Parameters
namestringName of the action to remove.
UpdateStatusBarBounds(int, int, bool, bool, StatusBarOptions)
Updates the status bar bounds based on current screen size and configuration. Call this after screen resizes or configuration changes.
public void UpdateStatusBarBounds(int screenWidth, int screenHeight, bool showTopStatus, bool showBottomStatus, StatusBarOptions options)
Parameters
screenWidthintCurrent screen width.
screenHeightintCurrent screen height.
showTopStatusboolWhether the top status bar is enabled.
showBottomStatusboolWhether the bottom status bar is enabled.
optionsStatusBarOptionsStatus bar configuration options.