SummaryBar
ConsoleMonster.Widgets
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
- LiveWidget
- SummaryBar
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.
Returned or exposed by 11
- Method Ui.SummaryBar
- Extension method SummaryBar.BarWidth
- Extension method SummaryBar.DoneLabel
- Extension method SummaryBar.Elapsed
- Extension method SummaryBar.ShowElapsed
- Method SummaryBar.Counter
- Method SummaryBar.Progress
- Method SummaryBarFluent.BarWidth
- Method SummaryBarFluent.DoneLabel
- Method SummaryBarFluent.Elapsed
- Method SummaryBarFluent.ShowElapsed
Accepted by parameters 10
- Method ContentBuilder.SummaryBar
- Method ContentBuilder.SummaryBar
- Extension method SummaryBar.BarWidth
- Extension method SummaryBar.DoneLabel
- Extension method SummaryBar.Elapsed
- Extension method SummaryBar.ShowElapsed
- Method SummaryBarFluent.BarWidth
- Method SummaryBarFluent.DoneLabel
- Method SummaryBarFluent.Elapsed
- Method SummaryBarFluent.ShowElapsed
Constructors
public SummaryBar(string widgetId = "summary") #Creates a summary bar.
Parameters
- widgetId string = "summary"
- 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
- 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
- The label ("passed"), or a format with the count as {0} ("{0} passed", as the built-in labels are).
- count int
- The count.
- status ConsoleMonster.Styling.StatusKind? = null
- A status for the symbol and colour, or null for plain text.
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
- The dispatcher.
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
- The width.
- context ConsoleMonster.Canvas.RenderContext
- The render context.
public override Size Measure(Constraints constraints, RenderContext context) #Returns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public SummaryBar Progress(double value, double total) #Sets the progress.
Parameters
- value double
- Items value.
- total double
- Items in total (0 = unknown).
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
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Inherited Methods
public virtual string? Describe(LiveEvent liveEvent) #Parameters
- liveEvent LiveEvent
Returns
string?Properties
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.
Inherited Properties
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.
-1Extension 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
- The instance.
- value int
- The value.
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
- The instance.
- value string?
- The value.
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
- The instance.
- value System.TimeSpan?
- The value.
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
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.SummaryBar { ShowElapsed = value }; Ui.SummaryBar().ShowElapsed(value);