Skip to content
ConsoleMonster

API Reference

Class

SummaryBar

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Implements
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. Live operations: progress (Value = done, Total = total), counter (Key = label, Value = count, State = status word for its symbol and colour).

Inheritance

Usage

Explore 18 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 8

Constructors

public SummaryBar(String name = "summary") #

Creates a summary bar.

Parameters

name System.String = "summary" optionalposition: 0
The live name (default summary).

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 StyledLine Line(Int32 width, RenderContext context) #
Returns: StyledLine

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

Parameters

width System.Int32 requiredposition: 0
The width.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
The render context.

Returns

The line.

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 SummaryBar SetCounter(String label, Int32 count, StatusKind? status = null) #
Returns: SummaryBar

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

Parameters

label System.String requiredposition: 0
The label ("passed"), or a format with the count as {0} ("{0} passed", as the built-in labels are).
count System.Int32 requiredposition: 1
The count.
status ConsoleMonster.Styling.StatusKind? = null optionalposition: 2
A status for the symbol and colour, or null for plain text.

Returns

This instance.

public SummaryBar SetProgress(Double done, Double total) #
Returns: SummaryBar

Sets the progress.

Parameters

done System.Double requiredposition: 0
Items done.
total System.Double requiredposition: 1
Items in total (0 = unknown).

Returns

This instance.

Properties

public Double Done { get; private set; } #

Items done.

public Double Total { get; private set; } #

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

public Int32 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.

public Boolean ShowDuration { get; set; } #

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

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.

Extension Methods

public static SummaryBar WithBarWidth(SummaryBar summaryBar, Int32 value) #
Returns: SummaryBar

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

Parameters

summaryBar ConsoleMonster.Widgets.SummaryBar requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

public static SummaryBar WithDoneLabel(SummaryBar summaryBar, String? value) #
Returns: SummaryBar

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 requiredposition: 0
The instance.
value System.String? requiredposition: 1
The value.

Returns

The same instance.

public static SummaryBar WithElapsed(SummaryBar summaryBar, TimeSpan? value) #
Returns: SummaryBar

Sets SummaryBar.Elapsed: The elapsed time to estimate from, or null (default) for the time since the first progress.

Parameters

summaryBar ConsoleMonster.Widgets.SummaryBar requiredposition: 0
The instance.
value System.TimeSpan? requiredposition: 1
The value.

Returns

The same instance.

public static SummaryBar WithShowDuration(SummaryBar summaryBar, Boolean value = true) #
Returns: SummaryBar

Sets SummaryBar.ShowDuration: Whether a finished run shows how long it took ("in 12s") after the counters (default true; needs SummaryBar.Elapsed).

Parameters

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

Returns

The same instance.