Class StatusBarControl
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A single-row status bar with left/center/right alignment zones, clickable items, and optional shortcut key hints. Does not receive keyboard focus — display and click only.
public class StatusBarControl : BaseControl, IDOMPaintable, INotifyPropertyChanged, IMouseAwareControl, IWindowControl, IDisposable
- Inheritance
-
StatusBarControl
- Implements
- Inherited Members
- Extension Methods
Constructors
StatusBarControl(bool)
Initializes a new instance of the StatusBarControl class.
public StatusBarControl(bool stickyBottom = true)
Parameters
stickyBottomboolWhen true (default), the control sticks to the bottom of the window. Set to false to place the status bar anywhere in the DOM layout.
Properties
AboveLineColor
Color of the above line. Null uses the foreground color.
public Color? AboveLineColor { get; set; }
Property Value
BackgroundColor
Gets or sets the status bar background color. Null inherits from theme/container.
public Color? BackgroundColor { get; set; }
Property Value
CanFocusWithMouse
Whether this control can receive focus via mouse clicks
public bool CanFocusWithMouse { get; }
Property Value
CenterItems
Gets the items in the center alignment zone.
public IReadOnlyList<StatusBarItem> CenterItems { get; }
Property Value
ContentWidth
Gets the minimum width needed to display the control's content, including margins. Returns null if width cannot be determined. This is calculated based on content (text length, child controls, etc.) and represents the natural/intrinsic size.
public override int? ContentWidth { get; }
Property Value
- int?
ForegroundColor
Gets or sets the status bar foreground (label) color. Null inherits from theme/container.
public Color ForegroundColor { get; set; }
Property Value
ItemSpacing
Gets or sets spacing in characters between adjacent items. Default 2.
public int ItemSpacing { get; set; }
Property Value
LeftItems
Gets the items in the left alignment zone.
public IReadOnlyList<StatusBarItem> LeftItems { get; }
Property Value
RightItems
Gets the items in the right alignment zone.
public IReadOnlyList<StatusBarItem> RightItems { get; }
Property Value
SeparatorChar
Gets or sets the separator character rendered between sections. Default "|".
public string SeparatorChar { get; set; }
Property Value
ShortcutForegroundColor
Accent color for shortcut key hints. Falls back to theme, then Cyan1.
public Color ShortcutForegroundColor { get; set; }
Property Value
ShortcutLabelSeparator
Gets or sets the separator between shortcut and label text within an item. Default ":".
public string ShortcutLabelSeparator { get; set; }
Property Value
ShowAboveLine
When true, renders a horizontal line above the status bar content. Default false.
public bool ShowAboveLine { get; set; }
Property Value
WantsMouseEvents
Whether this control wants to receive mouse events
public bool WantsMouseEvents { get; }
Property Value
Methods
AddCenter(StatusBarItem)
Adds a pre-configured item to the center zone.
public void AddCenter(StatusBarItem item)
Parameters
itemStatusBarItem
AddCenter(string, string, Action?)
Adds an item with shortcut and label to the center zone.
public StatusBarItem AddCenter(string shortcut, string label, Action? onClick = null)
Parameters
Returns
AddCenterSeparator()
Adds a separator item to the center zone.
public void AddCenterSeparator()
AddCenterText(string, Action?)
Adds a label-only item (no shortcut) to the center zone.
public StatusBarItem AddCenterText(string text, Action? onClick = null)
Parameters
Returns
AddLeft(StatusBarItem)
Adds a pre-configured item to the left zone.
public void AddLeft(StatusBarItem item)
Parameters
itemStatusBarItem
AddLeft(string, string, Action?)
Adds an item with shortcut and label to the left zone.
public StatusBarItem AddLeft(string shortcut, string label, Action? onClick = null)
Parameters
Returns
AddLeftSeparator()
Adds a separator item to the left zone.
public void AddLeftSeparator()
AddLeftText(string, Action?)
Adds a label-only item (no shortcut) to the left zone.
public StatusBarItem AddLeftText(string text, Action? onClick = null)
Parameters
Returns
AddRight(StatusBarItem)
Adds a pre-configured item to the right zone.
public void AddRight(StatusBarItem item)
Parameters
itemStatusBarItem
AddRight(string, string, Action?)
Adds an item with shortcut and label to the right zone.
public StatusBarItem AddRight(string shortcut, string label, Action? onClick = null)
Parameters
Returns
AddRightSeparator()
Adds a separator item to the right zone.
public void AddRightSeparator()
AddRightText(string, Action?)
Adds a label-only item (no shortcut) to the right zone.
public StatusBarItem AddRightText(string text, Action? onClick = null)
Parameters
Returns
BatchUpdate(Action)
Executes multiple item changes with a single invalidation at the end.
public void BatchUpdate(Action updateAction)
Parameters
updateActionAction
ClearAll()
Removes all items from all zones.
public void ClearAll()
ClearCenter()
Removes all items from the center zone.
public void ClearCenter()
ClearLeft()
Removes all items from the left zone.
public void ClearLeft()
ClearRight()
Removes all items from the right zone.
public void ClearRight()
GetLogicalContentSize()
Gets the logical size of the control's content without rendering.
public override Size GetLogicalContentSize()
Returns
- Size
The size representing the content's natural dimensions.
MeasureDOM(LayoutConstraints)
Measures the control's desired size given the available constraints.
public override LayoutSize MeasureDOM(LayoutConstraints constraints)
Parameters
constraintsLayoutConstraintsThe layout constraints (min/max width/height).
Returns
- LayoutSize
The desired size of the control.
OnDisposing()
Called during Dispose() before Container is set to null.
Override to perform control-specific cleanup (null events, close portals, clear data, etc.).
protected override void OnDisposing()
PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)
Paints the control's content directly to a CharacterBuffer.
public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultFg, Color defaultBg)
Parameters
bufferCharacterBufferThe buffer to paint to.
boundsLayoutRectThe absolute bounds where the control should paint.
clipRectLayoutRectThe clipping rectangle (visible area).
defaultFgColordefaultBgColor
ProcessMouseEvent(MouseEventArgs)
Processes a mouse event for this control
public bool ProcessMouseEvent(MouseEventArgs args)
Parameters
argsMouseEventArgsMouse event arguments with control-relative coordinates
Returns
- bool
True if the event was handled and should not propagate further
RemoveCenter(StatusBarItem)
Removes an item from the center zone. Returns true if found.
public bool RemoveCenter(StatusBarItem item)
Parameters
itemStatusBarItem
Returns
RemoveLeft(StatusBarItem)
Removes an item from the left zone. Returns true if found.
public bool RemoveLeft(StatusBarItem item)
Parameters
itemStatusBarItem
Returns
RemoveRight(StatusBarItem)
Removes an item from the right zone. Returns true if found.
public bool RemoveRight(StatusBarItem item)
Parameters
itemStatusBarItem
Returns
Events
ItemClicked
Fired when any item in the status bar is clicked.
public event EventHandler<StatusBarItemClickedEventArgs>? ItemClicked
Event Type
MouseClick
Event fired when the control is clicked
public event EventHandler<MouseEventArgs>? MouseClick
Event Type
MouseDoubleClick
Event fired when the control is double-clicked
public event EventHandler<MouseEventArgs>? MouseDoubleClick
Event Type
MouseEnter
Event fired when the mouse enters the control area
public event EventHandler<MouseEventArgs>? MouseEnter
Event Type
MouseLeave
Event fired when the mouse leaves the control area
public event EventHandler<MouseEventArgs>? MouseLeave
Event Type
MouseMove
Event fired when the mouse moves over the control
public event EventHandler<MouseEventArgs>? MouseMove
Event Type
MouseRightClick
Event fired when the control is right-clicked (Button3)
public event EventHandler<MouseEventArgs>? MouseRightClick