Skip to content
ConsoleMonster
Class

SummaryBar

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

One line that sums up a run: a thin progress bar, done of total, the percentage, the time left, and counters in a fixed order (passed, failed, skipped...) with zeros dimmed rather than hidden, so the line does not jump as counts appear. The time left is estimated from the elapsed time and the share done. In a live session the elapsed time follows the session's clock (LiveSessionOptions.Clock, so a simulated clock drives it too), from the first progress until progress reaches the total; elsewhere it is real time since the first progress. Live operations: progress (Value = done, Total = total; for either keeps what the bar has, so an update of done alone leaves the total as it is), counter (Key = label, Value = count, State = status word for its symbol and colour).

Inheritance

Usage

Explore 21 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 10

Constructors

public SummaryBar(string widgetId = "summary") #

Creates a summary bar.

Parameters

widgetId string = "summary" optional
The live name (default summary).

Methods

public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
public SummaryBar Counter(string label, int count, StatusKind? status = null) #

Adds or updates a counter; counters keep the order they were first added in.

Parameters

label string required
The label ("passed"), or a format with the count as {0} ("{0} passed", as the built-in labels are).
count int required
The count.
status ConsoleMonster.Styling.StatusKind? = null optional
A status for the symbol and colour, or null for plain text.

Returns

SummaryBar This instance.
public SummaryBarHandle Handle(ILiveDispatcher dispatcher) #

Returns a thread-safe handle that queues progress and counter changes for a live session.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

SummaryBarHandle The handle.
public StyledLine Line(int width, RenderContext context) #

The text after the bar at a width: done of total, the percentage, the time left, then as many counters as fit.

Parameters

width int required
The width.
context ConsoleMonster.Canvas.RenderContext required
The render context.

Returns

StyledLine The line.
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 SummaryBar Progress(double value, double total) #

Sets the progress.

Parameters

value double required
Items value.
total double required
Items in total (0 = unknown).

Returns

SummaryBar This instance.
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.

Properties

public double Value { get; private set; } #

Items done.

public double Total { get; private set; } #

Items in total (0 = unknown: no bar, percentage or time left).

public int BarWidth { get; set; } #

The bar width in cells (default 20; narrow regions shrink it).

public TimeSpan? Elapsed { get; set; } #

The elapsed time to estimate from, or null (default) for the time since the first progress: on the live session's clock while the bar is drawn in a session, real time otherwise.

public bool ShowElapsed { get; set; } #

Whether a finished run shows how long it took ("in 12s") after the counters (default true; needs SummaryBar.Elapsed or a live session's clock).

public string? DoneLabel { get; set; } #

The label for the count done while the total is unknown, with {0} for the count, or null (default) for "{0} done".

public TimeSpan? Remaining { get; } #

The time left, estimated from the elapsed time and the share done, or null while it cannot be known.

Fields

public const double Keep #

The value a progress event gives for done or total to keep what the bar has (any negative number or NaN does the same). Events are applied in order, so an update that keeps the total uses the total of the update before it, even when that one has not been drawn yet.

Value: -1

Extension Methods

public static SummaryBar BarWidth(SummaryBar summaryBar, int value) #

Sets SummaryBar.BarWidth: The bar width in cells (default 20; narrow regions shrink it).

Parameters

summaryBar ConsoleMonster.Widgets.SummaryBar required
The instance.
value int required
The value.

Returns

SummaryBar The same instance.

Examples

// C# initializer or property                                          // C# fluent
new global::ConsoleMonster.Widgets.SummaryBar { BarWidth = value };    Ui.SummaryBar().BarWidth(value);
public static SummaryBar DoneLabel(SummaryBar summaryBar, string? value) #

Sets SummaryBar.DoneLabel: The label for the count done while the total is unknown, with {0} for the count, or null (default) for "{0} done".

Parameters

summaryBar ConsoleMonster.Widgets.SummaryBar required
The instance.
value string? required
The value.

Returns

SummaryBar The same instance.

Examples

// C# initializer or property                                           // C# fluent
new global::ConsoleMonster.Widgets.SummaryBar { DoneLabel = value };    Ui.SummaryBar().DoneLabel(value);
public static SummaryBar Elapsed(SummaryBar summaryBar, TimeSpan? value) #

Sets SummaryBar.Elapsed: The elapsed time to estimate from, or null (default) for the time since the first progress: on the live session's clock while the bar is drawn in a session, real time otherwise.

Parameters

summaryBar ConsoleMonster.Widgets.SummaryBar required
The instance.
value System.TimeSpan? required
The value.

Returns

SummaryBar The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.SummaryBar { Elapsed = value };    Ui.SummaryBar().Elapsed(value);
public static SummaryBar ShowElapsed(SummaryBar summaryBar, bool value = true) #

Sets SummaryBar.ShowElapsed: Whether a finished run shows how long it took ("in 12s") after the counters (default true; needs SummaryBar.Elapsed or a live session's clock).

Parameters

summaryBar ConsoleMonster.Widgets.SummaryBar required
The instance.
value bool = true optional
The value; true when omitted.

Returns

SummaryBar The same instance.

Examples

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