Table of Contents

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

int

BackgroundColor

Gets or sets the background color. When null, inherits from the container.

public Color? BackgroundColor { get; set; }

Property Value

Color?

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

IContainer

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

Color?

Header

Gets or sets the header text displayed above the bar.

public string? Header { get; set; }

Property Value

string

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

bool

MaxValue

Gets or sets the maximum value for the progress bar (default: 100).

public double MaxValue { get; set; }

Property Value

double

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

Color?

PulseWidth

Gets or sets the width of the pulse segment in indeterminate mode (default: 5).

public int PulseWidth { get; set; }

Property Value

int

ShowHeader

Gets or sets whether to show the header text above the bar.

public bool ShowHeader { get; set; }

Property Value

bool

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

bool

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

Color?

Value

Gets or sets the current progress value (0 to MaxValue).

public double Value { get; set; }

Property Value

double

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

constraints LayoutConstraints

The 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

buffer CharacterBuffer

The buffer to paint to.

bounds LayoutRect

The absolute bounds where the control should paint.

clipRect LayoutRect

The clipping rectangle (visible area).

defaultFg Color
defaultBg Color