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 : IWindowControl, IDOMPaintable, IDisposable
Inheritance
ProgressBarControl
Implements
Inherited Members
Extension Methods

Constructors

ProgressBarControl()

Initializes a new instance of the ProgressBarControl class.

public ProgressBarControl()

Properties

ActualWidth

Gets the actual rendered width of the control, or null if not yet rendered.

public int? ActualWidth { get; }

Property Value

int?

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 IContainer? Container { get; set; }

Property Value

IContainer

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

HorizontalAlignment

Gets or sets the horizontal alignment of the control within its container.

public HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

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

Margin

Gets or sets the margin (spacing) around the control.

public Margin Margin { get; set; }

Property Value

Margin

MaxValue

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

public double MaxValue { get; set; }

Property Value

double

Name

Gets or sets the unique name identifier for this control, used for lookup.

public string? Name { get; set; }

Property Value

string

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

StickyPosition

Gets or sets whether this control should stick to the top or bottom during scrolling.

public StickyPosition StickyPosition { get; set; }

Property Value

StickyPosition

Tag

Gets or sets an arbitrary object value that can be used to store custom data.

public object? Tag { get; set; }

Property Value

object

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

VerticalAlignment

Gets or sets the vertical alignment of the control within its container.

public VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

Visible

Gets or sets whether this control is visible.

public bool Visible { get; set; }

Property Value

bool

Width

Gets or sets the explicit width of the control, or null for automatic sizing.

public int? Width { get; set; }

Property Value

int?

Methods

Dispose()

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

public void Dispose()

GetLogicalContentSize()

Gets the logical size of the control's content without rendering.

public Size GetLogicalContentSize()

Returns

Size

The size representing the content's natural dimensions.

Invalidate()

Marks this control as needing to be re-rendered.

public void Invalidate()

MeasureDOM(LayoutConstraints)

Measures the control's desired size given the available constraints.

public LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

The layout constraints (min/max width/height).

Returns

LayoutSize

The desired size of the control.

PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)

Paints the control's content directly to a CharacterBuffer.

public 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