Skip to content
ConsoleMonster

API Reference

Class

Form

Namespace ConsoleMonster.Interactive
Assembly ConsoleMonster
Source Form.cs:31
Modifiers sealed

A form or wizard: fields on one or more pages, a review page with the equivalent command line, named presets and (opt-in) remembered choices. Show it on its own (Form.Show) or open it from a menu item.

Inheritance

  • Object
  • Form

Usage

Explore 3 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 2

Accepted by parameters 1

Constructors

public Form(String title) #

Creates a form.

Parameters

title System.String requiredposition: 0
The title.

Methods

public T Add<T>(T field) #
Returns: T

Adds a field to the last page.

Type Parameters

T
The field type.

Parameters

field T requiredposition: 0
The field.

Returns

The field.

public IReadOnlyList<String> ApplyStored(IDictionary<String, Object?> stored) #
Returns: IReadOnlyList<String>

Applies stored values (a preset or remembered choices); returns the names that could not be applied yet.

Parameters

stored System.Collections.Generic.IDictionary<System.String, System.Object?> requiredposition: 0
The values.

Returns

Names whose options are not loaded yet (applied after loading).

public String BuildCommand() #
Returns: String

The command line equivalent to the current values.

Returns

The command line.

public Field? Find(String name) #
Returns: Field?

Finds a field by name.

Parameters

name System.String requiredposition: 0
The name.

Returns

The field, or null.

public FormValues GetValues() #
Returns: FormValues

The current values, with visibility evaluated.

Returns

The values.

public ChoiceField MultiSelect(String name, String? label = null, IEnumerable<Choice>? choices = null) #
Returns: ChoiceField

Adds a multi-choice field to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.
choices System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.Choice>? = null optionalposition: 2
The choices, or null when a loader provides them.

Returns

The field.

public NumberField Number(String name, String? label = null) #
Returns: NumberField

Adds a number field to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.

Returns

The field.

Page 2 overloads
public FormPage Page(String title, String? description = null) #
Returns: FormPage

Adds a page.

Parameters

title System.String requiredposition: 0
The page title.
description System.String? = null optionalposition: 1
A sentence under it.

Returns

The page.

public Form Page(String title, Action<FormPage> configure) #
Returns: Form

Adds a page and configures it.

Parameters

title System.String requiredposition: 0
The page title.
configure System.Action<ConsoleMonster.Interactive.FormPage> requiredposition: 1
Adds the fields.

Returns

The form.

public PathField Path(String name, String? label = null) #
Returns: PathField

Adds a path field to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.

Returns

The field.

public SecretField Secret(String name, String? label = null) #
Returns: SecretField

Adds a secret field to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.

Returns

The field.

public ChoiceField Select(String name, String? label = null, IEnumerable<Choice>? choices = null) #
Returns: ChoiceField

Adds a single-choice field to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.
choices System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.Choice>? = null optionalposition: 2
The choices, or null when a loader provides them.

Returns

The field.

public FormResult Show(FormOptions? options = null, CancellationToken cancellationToken = default) #
Returns: FormResult

Shows the form and waits for it to be submitted or cancelled.

Parameters

options ConsoleMonster.Interactive.FormOptions? = null optionalposition: 0
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 1
Cancels the form.

Returns

The result.

public Task<FormResult> ShowAsync(FormOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Task<FormResult>

Shows the form on a worker thread.

Parameters

options ConsoleMonster.Interactive.FormOptions? = null optionalposition: 0
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 1
Cancels the form.

Returns

The result.

public TextField Text(String name, String? label = null) #
Returns: TextField

Adds a text field to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.

Returns

The field.

public ToggleField Toggle(String name, String? label = null) #
Returns: ToggleField

Adds a toggle to the last page.

Parameters

name System.String requiredposition: 0
The key.
label System.String? = null optionalposition: 1
The label.

Returns

The field.

public Dictionary<String, Object?> ToStored() #
Returns: Dictionary<String, Object?>

The storable values (no secrets, only fields that are remembered).

Returns

The values.

Properties

public String Title { get; set; } #

The title.

public String? Description { get; set; } #

A sentence under the title.

public String? Command { get; set; } #

The command the equivalent command line starts with (Install-Toolbox, toolbox install).

public CommandStyle CommandStyle { get; set; } #

How the equivalent command line is written.

public IList<FormPage> Pages { get; } #

The pages, in order.

public Boolean Review { get; set; } #

Whether a review page (summary, equivalent command, run) comes after the last page.

public String? SubmitText { get; set; } #

The caption of the button that submits the form; null uses "Run".

public String? StorageKey { get; set; } #

The key presets and remembered choices are stored under; null uses the title.

public IEnumerable<Field> Fields { get; } #

Every field, page by page.