Skip to content
ConsoleMonster
Class

FormPreset

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed
Attributes
Fluent

A preset a form comes with (Form.Presets): a name and field values. It is listed before the presets people save, marked as built in, and cannot be overwritten or deleted; applying it sets the fields the way a saved preset does.

Inheritance

  • object
  • FormPreset

Usage

Explore 15 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 6

Accepted by parameters 9

Constructors

public FormPreset(string name, IDictionary<string, object?> values) #

Creates a built-in preset.

Parameters

name string required
The name; a saved preset cannot take it.
values System.Collections.Generic.IDictionary<string, object?> required
Field values by field name (ignoring case), as the fields take them: a string, a number, a bool, or a list for a multi-choice field.

Methods

public override string ToString() #

Returns a string that represents the current object.

Returns

string A string that represents the current object.
public FormPreset Value(string field, object? value) #

Sets a field's value.

Parameters

field string required
The field name (ignoring case).
value object? required
The value, as the field takes it: a string, a number, a bool, or a list for a multi-choice field.

Returns

FormPreset The preset.

Properties

public string Name { get; } #

The name.

public string? Description { get; set; } #

A sentence about the preset, shown with it, or null.

public IDictionary<string, object?> Values { get; } #

The field values by field name (ignoring case).

public IWidget? Preview { get; set; } #

Content describing the preset (what it fills in), for lists that show a preview while a preset has focus; the command palette, where a form's presets are listed today, shows the FormPreset.Description only.

Extension Methods

public static FormPreset Description(FormPreset formPreset, string? value) #

Sets FormPreset.Description: A sentence about the preset, shown with it, or null.

Parameters

formPreset ConsoleMonster.Interactive.FormPreset required
The instance.
value string? required
The value.

Returns

FormPreset The same instance.

Examples

// C# initializer or property      // C# fluent
formPreset.Description = value;    formPreset.Description(value);
public static FormPreset Preview(FormPreset formPreset, IWidget? value) #

Sets FormPreset.Preview: Content describing the preset (what it fills in), for lists that show a preview while a preset has focus; the command palette, where a form's presets are listed today, shows the FormPreset.Description only.

Parameters

formPreset ConsoleMonster.Interactive.FormPreset required
The instance.
value ConsoleMonster.Layout.IWidget? required
The value.

Returns

FormPreset The same instance.

Examples

// C# initializer or property    // C# fluent
formPreset.Preview = value;      formPreset.Preview(value);