Class ProgressBarControl
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A progress bar control with both determinate (percentage) and indeterminate (pulsing) modes. Uses box-drawing character ━ (U+2501) for clean terminal rendering.
public class ProgressBarControl : BaseControl, IWindowControl, IDisposable, IDOMPaintable, INotifyPropertyChanged
- Inheritance
-
ProgressBarControl
- Implements
- Inherited Members
- Extension Methods
Constructors
ProgressBarControl()
Initializes a new instance of the ProgressBarControl class.
public ProgressBarControl()
Properties
AnimationInterval
Gets or sets the animation interval in milliseconds (default: 100). Only affects indeterminate mode.
public int AnimationInterval { get; set; }
Property Value
BackgroundColor
Gets or sets the background color. When null, inherits from the container.
public Color? BackgroundColor { get; set; }
Property Value
BarWidth
Gets or sets the fixed width of the bar in characters. When null, the bar stretches to fill available width.
public int? BarWidth { get; set; }
Property Value
- int?
Container
Gets or sets the parent container that hosts this control.
public override IContainer? Container { get; set; }
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?
FilledColor
Gets or sets the color for the filled portion of the bar. When null, uses theme color or default (Cyan1).
public Color? FilledColor { get; set; }
Property Value
Header
Gets or sets the header text displayed above the bar.
public string? Header { get; set; }
Property Value
IsIndeterminate
Gets or sets whether the progress bar is in indeterminate mode (pulsing animation). Setting this to true starts the internal animation timer; false stops it.
public bool IsIndeterminate { get; set; }
Property Value
MaxValue
Gets or sets the maximum value for the progress bar (default: 100).
public double MaxValue { get; set; }
Property Value
PercentageColor
Gets or sets the color for the percentage text. When null, uses theme color or default (White).
public Color? PercentageColor { get; set; }
Property Value
PulseWidth
Gets or sets the width of the pulse segment in indeterminate mode (default: 5).
public int PulseWidth { get; set; }
Property Value
ShowHeader
Gets or sets whether to show the header text above the bar.
public bool ShowHeader { get; set; }
Property Value
ShowPercentage
Gets or sets whether to show the percentage text after the bar. Only displayed in determinate mode.
public bool ShowPercentage { get; set; }
Property Value
UnfilledColor
Gets or sets the color for the unfilled portion of the bar. When null, uses theme color or default (Grey35).
public Color? UnfilledColor { get; set; }
Property Value
Value
Gets or sets the current progress value (0 to MaxValue).
public double Value { get; set; }
Property Value
Width
Gets or sets the explicit width of the control, or null for automatic sizing.
public override int? Width { get; set; }
Property Value
- int?
Methods
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