API Reference
Form
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
- Method Form.Page
- Property MenuItem.FormDefinition
Accepted by parameters 1
- Method MenuItem.Form
Constructors
Methods
public T Add<T>(T field) #TAdds a field to the last page.
Type Parameters
- T
- The field type.
Parameters
- field T
- The field.
Returns
The field.
public IReadOnlyList<String> ApplyStored(IDictionary<String, Object?> stored) #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?>
- The values.
Returns
Names whose options are not loaded yet (applied after loading).
public String BuildCommand() #StringThe command line equivalent to the current values.
Returns
The command line.
public Field? Find(String name) #Field?Finds a field by name.
Parameters
- name System.String
- The name.
Returns
The field, or null.
public FormValues GetValues() #FormValuesThe current values, with visibility evaluated.
Returns
The values.
public ChoiceField MultiSelect(String name, String? label = null, IEnumerable<Choice>? choices = null) #ChoiceFieldAdds a multi-choice field to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
- choices System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.Choice>? = null
- The choices, or null when a loader provides them.
Returns
The field.
public NumberField Number(String name, String? label = null) #NumberFieldAdds a number field to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
Returns
The field.
public FormPage Page(String title, String? description = null) #FormPageAdds a page.
Parameters
- title System.String
- The page title.
- description System.String? = null
- A sentence under it.
Returns
The page.
public Form Page(String title, Action<FormPage> configure) #FormAdds a page and configures it.
Parameters
- title System.String
- The page title.
- configure System.Action<ConsoleMonster.Interactive.FormPage>
- Adds the fields.
Returns
The form.
public PathField Path(String name, String? label = null) #PathFieldAdds a path field to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
Returns
The field.
public SecretField Secret(String name, String? label = null) #SecretFieldAdds a secret field to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
Returns
The field.
public ChoiceField Select(String name, String? label = null, IEnumerable<Choice>? choices = null) #ChoiceFieldAdds a single-choice field to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
- choices System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.Choice>? = null
- The choices, or null when a loader provides them.
Returns
The field.
public FormResult Show(FormOptions? options = null, CancellationToken cancellationToken = default) #FormResultShows the form and waits for it to be submitted or cancelled.
Parameters
- options ConsoleMonster.Interactive.FormOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the form.
Returns
The result.
public Task<FormResult> ShowAsync(FormOptions? options = null, CancellationToken cancellationToken = default) #Task<FormResult>Shows the form on a worker thread.
Parameters
- options ConsoleMonster.Interactive.FormOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the form.
Returns
The result.
public TextField Text(String name, String? label = null) #TextFieldAdds a text field to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
Returns
The field.
public ToggleField Toggle(String name, String? label = null) #ToggleFieldAdds a toggle to the last page.
Parameters
- name System.String
- The key.
- label System.String? = null
- The label.
Returns
The field.
public Dictionary<String, Object?> ToStored() #Dictionary<String, Object?>The storable values (no secrets, only fields that are remembered).
Returns
The values.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
Properties
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 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.