Skip to content
ConsoleMonster

API Reference

Class

ProgressBar

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Modifiers sealed

A labelled progress bar with percentage and count: Build ████████▌░░░░ 64% 32/50. Live operations: set (Value, Total), advance (Value = amount), label (Text), state (State).

Inheritance

Usage

Explore 49 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 name = "progress") #

Creates a progress bar.

Parameters

label System.String = "" optionalposition: 0
The label (markup).
name System.String = "progress" optionalposition: 1
The live name (default progress).

Methods

public override Void Apply(LiveEvent liveEvent) #
Returns: Void

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent requiredposition: 0
The event.
public override String? Describe(LiveEvent liveEvent) #
Returns: String?

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 requiredposition: 0
The event that was applied.

Returns

A plain line or null.

public String? GetSummaryLine() #
Returns: String?

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

Returns

The plain-text status line.

public ProgressHandle Handle(ILiveDispatcher dispatcher) #
Returns: ProgressHandle

Returns a handle that updates this bar through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher requiredposition: 0
The dispatcher.

Returns

The handle.

public override Size Measure(Constraints constraints, RenderContext context) #
Returns: Size

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints requiredposition: 0
The space offered.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Returns

The desired size, never larger than the constraints.

public override Void Render(Region region, RenderContext context) #
Returns: Void

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

Parameters

region ConsoleMonster.Canvas.Region requiredposition: 0
The target region.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.
public Boolean TryGetTaskbarProgress(out TaskbarState state, out Double fraction) #
Returns: Boolean

The widget's contribution, if any.

Parameters

state ConsoleMonster.Output.TaskbarState requiredposition: 0
The state (Normal, Indeterminate, Error or Paused).
fraction System.Double requiredposition: 1
The fraction done (0 to 1), or NaN when unknown.

Returns

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 Boolean ShowCount { get; set; } #

Whether the value/total count is shown (default true).

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 Int32? 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 AddColumn(ProgressBar progressBar, ProgressColumn item) #
Returns: ProgressBar

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 requiredposition: 0
The instance.
item ConsoleMonster.Widgets.ProgressColumn requiredposition: 1
The item.

Returns

The same instance.

AddColumns 2 overloads
public static ProgressBar AddColumns(ProgressBar progressBar, params ProgressColumn[] items) #
Returns: ProgressBar

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 requiredposition: 0
The instance.
items ConsoleMonster.Widgets.ProgressColumn[] requiredposition: 1
The items, in order.

Returns

The same instance.

public static ProgressBar AddColumns(ProgressBar progressBar, IEnumerable<ProgressColumn> items) #
Returns: ProgressBar

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 requiredposition: 0
The instance.
items System.Collections.Generic.IEnumerable<ConsoleMonster.Widgets.ProgressColumn> requiredposition: 1
The items, in order.

Returns

The same instance.

public static ProgressBar WithColumns(ProgressBar progressBar, IList<ProgressColumn>? value) #
Returns: ProgressBar

Sets 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 requiredposition: 0
The instance.
value System.Collections.Generic.IList<ConsoleMonster.Widgets.ProgressColumn>? requiredposition: 1
The value.

Returns

The same instance.

WithCountColumn 2 overloads
public static ProgressBar WithCountColumn(ProgressBar progressBar, ColumnFormat value) #
Returns: ProgressBar

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 requiredposition: 0
The instance.
value ConsoleMonster.Layout.ColumnFormat requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithCountColumn(ProgressBar progressBar, Action<ColumnFormat> configure) #
Returns: ProgressBar

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 requiredposition: 0
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> requiredposition: 1
Configures the value.

Returns

The same instance.

public static ProgressBar WithLabel(ProgressBar progressBar, String value) #
Returns: ProgressBar

Sets ProgressBar.Label: The label (markup).

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value System.String requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithLabelWidth(ProgressBar progressBar, Int32? value) #
Returns: ProgressBar

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

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value System.Int32? requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithRateWindow(ProgressBar progressBar, TimeSpan value) #
Returns: ProgressBar

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

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value System.TimeSpan requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithShape(ProgressBar progressBar, BarShape value) #
Returns: ProgressBar

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

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value ConsoleMonster.Widgets.BarShape requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithShowCount(ProgressBar progressBar, Boolean value = true) #
Returns: ProgressBar

Sets ProgressBar.ShowCount: Whether the value/total count is shown (default true).

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value System.Boolean = true optionalposition: 1
The value (default true).

Returns

The same instance.

public static ProgressBar WithStatus(ProgressBar progressBar, StatusKind value) #
Returns: ProgressBar

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

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value ConsoleMonster.Styling.StatusKind requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithTotal(ProgressBar progressBar, Double value) #
Returns: ProgressBar

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

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value System.Double requiredposition: 1
The value.

Returns

The same instance.

public static ProgressBar WithValue(ProgressBar progressBar, Double value) #
Returns: ProgressBar

Sets ProgressBar.Value: The current value.

Parameters

progressBar ConsoleMonster.Widgets.ProgressBar requiredposition: 0
The instance.
value System.Double requiredposition: 1
The value.

Returns

The same instance.