Skip to content
ConsoleMonster
Class

ProgressBar

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

A labelled Line bar with a track and one value: Build ━━━━━━━╾────── 32/50, or a percentage for a total of 100. Live operations: set (Value, Total), advance (Value = amount), label (Text), state (State).

Inheritance

Usage

Explore 47 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 24

Constructors

public ProgressBar(string label = "", string widgetId = "progress") #

Creates a progress bar.

Parameters

label string = "" optional
The label (markup).
widgetId string = "progress" optional
The live name (default progress).

Methods

public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
public override string? Describe(LiveEvent liveEvent) #

Returns a line describing the event for line-based outputs (Stream/Plain), or null when the event is not worth a line (for example a single counter increment). Called after ILiveTarget.Apply.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event that was applied.

Returns

string? A plain line or null.
public string? GetSummaryLine() #

Returns the current status, or null to omit this target from the heartbeat.

Returns

string? The plain-text status line.
public ProgressHandle Handle(ILiveDispatcher dispatcher) #

Returns a handle that updates this bar through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

ProgressHandle The handle.
public override Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public override void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.
public bool TryGetTaskbarProgress(out TaskbarState state, out double fraction) #

The widget's contribution, if any.

Parameters

state ConsoleMonster.Output.TaskbarState required
The state (Normal, Indeterminate, Error or Paused).
fraction double required
The fraction done (0 to 1), or NaN when unknown.

Returns

bool False when the widget has nothing to report.

Properties

public string Label { get; set; } #

The label (markup).

public double Value { get; set; } #

The current value.

public double Total { get; set; } #

The total (default 100).

public StatusKind Status { get; set; } #

The status; Pass/Fail/Warn change the bar colour once finished.

public bool ShowCount { get; set; } #

Whether totals other than 100 show value/total (default true); false shows a percentage. A total of 100 always shows only a percentage.

public BarShape Shape { get; set; } #

The bar shape: BarShape.Line (default, a thin stroke) or BarShape.Block (solid blocks).

public ColumnFormat CountColumn { get; set; } #

Layout of the value in the value/total count (default right-aligned). The value reserves the width of the total, so the bar keeps its length as the value grows from 9 to 10.

public int? LabelWidth { get; set; } #

A fixed label column width, or null to fit the label.

public double Fraction { get; } #

The fraction complete (0-1).

public IList<ProgressColumn>? Columns { get; set; } #

The columns of the bar's row (see ProgressColumns: description, bar, percent, count, elapsed, remaining time, rate, custom...), or null (default) for the classic label, bar, percentage and count. With columns set, the stream heartbeat line summarises the bar through them.

public TimeSpan RateWindow { get; set; } #

The moving window that smooths the rate and the remaining time (default 10 seconds).

Extension Methods

public static ProgressBar Column(ProgressBar progressBar, ProgressColumn item) #

Adds an item to ProgressBar.Columns: The columns of the bar's row (see ProgressColumns: description, bar, percent, count, elapsed, remaining time, rate, custom...), or null (default) for the classic label, bar, percentage and count. With columns set, the stream heartbeat line summarises the bar through them.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
item ConsoleMonster.Widgets.ProgressColumn required
The item.

Returns

ProgressBar The same instance.
public static ProgressBar Columns(ProgressBar progressBar, IEnumerable<ProgressColumn> items) #

Adds items to ProgressBar.Columns: The columns of the bar's row (see ProgressColumns: description, bar, percent, count, elapsed, remaining time, rate, custom...), or null (default) for the classic label, bar, percentage and count. With columns set, the stream heartbeat line summarises the bar through them.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
items System.Collections.Generic.IEnumerable<ConsoleMonster.Widgets.ProgressColumn> required
The items, in order.

Returns

ProgressBar The same instance.
CountColumn 2 overloads
public static ProgressBar CountColumn(ProgressBar progressBar, ColumnFormat value) #

Sets ProgressBar.CountColumn: Layout of the value in the value/total count (default right-aligned). The value reserves the width of the total, so the bar keeps its length as the value grows from 9 to 10.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value ConsoleMonster.Layout.ColumnFormat required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                              // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { CountColumn = value };    Ui.ProgressBar().CountColumn(value);
public static ProgressBar CountColumn(ProgressBar progressBar, Action<ColumnFormat> configure) #

Configures ProgressBar.CountColumn in place: Layout of the value in the value/total count (default right-aligned). The value reserves the width of the total, so the bar keeps its length as the value grows from 9 to 10.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> required
Configures the value.

Returns

ProgressBar The same instance.
public static ProgressBar Label(ProgressBar progressBar, string value) #

Sets ProgressBar.Label: The label (markup).

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value string required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { Label = value };    Ui.ProgressBar().Label(value);
public static ProgressBar LabelWidth(ProgressBar progressBar, int? value) #

Sets ProgressBar.LabelWidth: A fixed label column width, or null to fit the label.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value int? required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                             // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { LabelWidth = value };    Ui.ProgressBar().LabelWidth(value);
public static ProgressBar RateWindow(ProgressBar progressBar, TimeSpan value) #

Sets ProgressBar.RateWindow: The moving window that smooths the rate and the remaining time (default 10 seconds).

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value System.TimeSpan required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                             // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { RateWindow = value };    Ui.ProgressBar().RateWindow(value);
public static ProgressBar Shape(ProgressBar progressBar, BarShape value) #

Sets ProgressBar.Shape: The bar shape: BarShape.Line (default, a thin stroke) or BarShape.Block (solid blocks).

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value ConsoleMonster.Widgets.BarShape required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { Shape = value };    Ui.ProgressBar().Shape(value);
public static ProgressBar ShowCount(ProgressBar progressBar, bool value = true) #

Sets ProgressBar.ShowCount: Whether totals other than 100 show value/total (default true); false shows a percentage. A total of 100 always shows only a percentage.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value bool = true optional
The value; true when omitted.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                            // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { ShowCount = value };    Ui.ProgressBar().ShowCount(value);
public static ProgressBar Status(ProgressBar progressBar, StatusKind value) #

Sets ProgressBar.Status: The status; Pass/Fail/Warn change the bar colour once finished.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value ConsoleMonster.Styling.StatusKind required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { Status = value };    Ui.ProgressBar().Status(value);
public static ProgressBar Total(ProgressBar progressBar, double value) #

Sets ProgressBar.Total: The total (default 100).

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value double required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { Total = value };    Ui.ProgressBar().Total(value);
public static ProgressBar Value(ProgressBar progressBar, double value) #

Sets ProgressBar.Value: The current value.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar required
The instance.
value double required
The value.

Returns

ProgressBar The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.ProgressBar { Value = value };    Ui.ProgressBar().Value(value);