PromptPlus

PromptPlus

PromptPlus

PromptPlusLibrary

ITreeMultiSelectControl<T> Interface

Provides a fluent API for configuring and running a generic multi-selection tree control that browses an arbitrary hierarchy of items of type T as an expandable/collapsible tree with tri-state checkboxes (unchecked / checked / indeterminate).

public interface ITreeMultiSelectControl<T>

Type parameters

T

The type of items in the tree.

Remarks

The tree structure is built the same way as ITreeSelectControl<T>: via Root(T, bool, bool), AddLast(T, bool, bool)/ AddFirst(T, bool, bool), AddAfter(ITreeNode<T>, T, bool, bool)/ AddBefore(ITreeNode<T>, T, bool, bool) and the ITreeMultiSelectNode<T> children helpers. Container nodes display a tri-state checkbox that reflects the aggregate check state of their descendants. Pressing the check key (Space) on a container cycles through Unchecked → Checked (all descendants) → Unchecked. Pressing Enter confirms the selection and returns all checked leaf (or all checked) values. Nodes can be marked disable at creation time: they are shown and navigable but cannot be checked/unchecked interactively; a cascading check still passes through a disabled node to reach its enabled descendants, and a disabled node force-marked via Default(IEnumerable<T>, bool) survives a mass-uncheck (F2) unaffected, same as IMultiSelectControl<T>. Nodes can also be marked check at creation time to start pre-checked (additive with Default(IEnumerable<T>, bool)/history — whichever marks a node checked, it stays checked). AddLast(T, bool, bool)/ AddFirst(T, bool, bool)/AddAfter(ITreeNode<T>, T, bool, bool)/ AddBefore(ITreeNode<T>, T, bool, bool) return ITreeMultiSelectNode<T> (not the plain ITreeNode<T>), so chaining further down the tree keeps access to check, not just the top-level calls made directly off the control.

Methods

ITreeMultiSelectControl<T>.AddAfter(ITreeNode<T>, T, bool, bool) Method

Inserts a new sibling immediately after node.

PromptPlusLibrary.ITreeMultiSelectNode<T> AddAfter(PromptPlusLibrary.ITreeNode<T> node, T value, bool disable=false, bool check=false);

Parameters

node PromptPlusLibrary.ITreeNode<T>

The reference sibling. Cannot be null.

value T

The value of the new node. Cannot be null.

disable System.Boolean

When true, the new node cannot be checked. Default is false.

check System.Boolean

Same semantics as in Root(T, bool, bool).

Returns

PromptPlusLibrary.ITreeMultiSelectNode<T>

Exceptions

System.InvalidOperationException
Thrown if node does not belong to this tree or is the root.

ITreeMultiSelectControl<T>.AddBefore(ITreeNode<T>, T, bool, bool) Method

Inserts a new sibling immediately before node.

PromptPlusLibrary.ITreeMultiSelectNode<T> AddBefore(PromptPlusLibrary.ITreeNode<T> node, T value, bool disable=false, bool check=false);

Parameters

node PromptPlusLibrary.ITreeNode<T>

The reference sibling. Cannot be null.

value T

The value of the new node. Cannot be null.

disable System.Boolean

When true, the new node cannot be checked. Default is false.

check System.Boolean

Same semantics as in Root(T, bool, bool).

Returns

PromptPlusLibrary.ITreeMultiSelectNode<T>

Exceptions

System.InvalidOperationException
Thrown if node does not belong to this tree or is the root.

ITreeMultiSelectControl<T>.AddFirst(T, bool, bool) Method

Adds a new node as the first child of the root and returns it.

PromptPlusLibrary.ITreeMultiSelectNode<T> AddFirst(T value, bool disable=false, bool check=false);

Parameters

value T

The value of the new node. Cannot be null.

disable System.Boolean

When true, the new node cannot be checked. Default is false.

check System.Boolean

Same semantics as in Root(T, bool, bool).

Returns

PromptPlusLibrary.ITreeMultiSelectNode<T>

ITreeMultiSelectControl<T>.AddLast(T, bool, bool) Method

Adds a new node as the last child of the root and returns it so children can be appended to it.

PromptPlusLibrary.ITreeMultiSelectNode<T> AddLast(T value, bool disable=false, bool check=false);

Parameters

value T

The value of the new node. Cannot be null.

disable System.Boolean

When true, the new node cannot be checked. Default is false.

check System.Boolean

Same semantics as in Root(T, bool, bool).

Returns

PromptPlusLibrary.ITreeMultiSelectNode<T>

ITreeMultiSelectControl<T>.CascadeCheck(bool) Method

When true (default), checking/unchecking a container propagates the new state to all its descendants. When false, only the container itself is toggled.

PromptPlusLibrary.ITreeMultiSelectControl<T> CascadeCheck(bool value=true);

Parameters

value System.Boolean

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.ChangeDescription(Func<T,string>) Method

Dynamically updates the description area based on the node currently under the cursor.

PromptPlusLibrary.ITreeMultiSelectControl<T> ChangeDescription(System.Func<T,string> value);

Parameters

value System.Func<T,System.String>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.ChangeDescriptionAsync(Func<T,Task<string>>) Method

Asynchronous variant of ChangeDescription(Func<T,string>).

PromptPlusLibrary.ITreeMultiSelectControl<T> ChangeDescriptionAsync(System.Func<T,System.Threading.Tasks.Task<string>> value);

Parameters

value System.Func<T,System.Threading.Tasks.Task<System.String>>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.CheckLeafOnly(bool) Method

When true, only leaf nodes (nodes without children) can be checked. Checking a container is blocked. Default is false.

PromptPlusLibrary.ITreeMultiSelectControl<T> CheckLeafOnly(bool value=true);

Parameters

value System.Boolean

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.Default(IEnumerable<T>, bool) Method

Pre-checks one or more items. The tree auto-expands to each pre-checked node. When useDefaultHistory is true and history is enabled, the history values override values.

PromptPlusLibrary.ITreeMultiSelectControl<T> Default(System.Collections.Generic.IEnumerable<T> values, bool useDefaultHistory=true);

Parameters

values System.Collections.Generic.IEnumerable<T>

useDefaultHistory System.Boolean

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.DefaultMatchBy(Func<T,T,bool>) Method

Sets the equality comparer used to match items (e.g. for Default(IEnumerable<T>, bool) lookup).

PromptPlusLibrary.ITreeMultiSelectControl<T> DefaultMatchBy(System.Func<T,T,bool> comparer);

Parameters

comparer System.Func<T,T,System.Boolean>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.EnableHistory(string, Action<IHistoryOptions>) Method

Enables history persistence. Previously checked items are restored on next run.

PromptPlusLibrary.ITreeMultiSelectControl<T> EnableHistory(string filename, System.Action<PromptPlusLibrary.IHistoryOptions>? options=null);

Parameters

filename System.String

options System.Action<IHistoryOptions>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.ExtraInfo(Func<T,string>) Method

Sets a function that returns optional extra information rendered next to each node label.

PromptPlusLibrary.ITreeMultiSelectControl<T> ExtraInfo(System.Func<T,string?> extraInfoNode);

Parameters

extraInfoNode System.Func<T,System.String>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

Exceptions

System.ArgumentNullException
When extraInfoNode is null.

ITreeMultiSelectControl<T>.ExtraInfoAsync(Func<T,Task<string>>) Method

Asynchronous counterpart of ExtraInfo(Func<T,string>). The task is awaited synchronously (blocking) once per node, per render frame.

PromptPlusLibrary.ITreeMultiSelectControl<T> ExtraInfoAsync(System.Func<T,System.Threading.Tasks.Task<string?>> extraInfoNode);

Parameters

extraInfoNode System.Func<T,System.Threading.Tasks.Task<System.String>>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

Exceptions

System.ArgumentNullException
When extraInfoNode is null.

ITreeMultiSelectControl<T>.Filter(FilterMode) Method

Sets the filter strategy for the filter mode. Default is Disabled.

PromptPlusLibrary.ITreeMultiSelectControl<T> Filter(PromptPlusLibrary.FilterMode value);

Parameters

value FilterMode

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.Interaction<T1>(IEnumerable<T1>, Action<T1,ITreeMultiSelectControl<T>>) Method

Iterates over items and invokes interactionAction for each element, allowing bulk population of the tree.

PromptPlusLibrary.ITreeMultiSelectControl<T> Interaction<T1>(System.Collections.Generic.IEnumerable<T1> items, System.Action<T1,PromptPlusLibrary.ITreeMultiSelectControl<T>> interactionAction);

Type parameters

T1

Parameters

items System.Collections.Generic.IEnumerable<T1>

interactionAction System.Action<T1,PromptPlusLibrary.ITreeMultiSelectControl<T>>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.InteractionAsync<T1>(IEnumerable<T1>, Func<T1,ITreeMultiSelectControl<T>,Task>) Method

Asynchronous variant of Interaction<T1>(IEnumerable<T1>, Action<T1,ITreeMultiSelectControl<T>>). Each callback is awaited synchronously so the tree is fully populated before Run is called.

PromptPlusLibrary.ITreeMultiSelectControl<T> InteractionAsync<T1>(System.Collections.Generic.IEnumerable<T1> items, System.Func<T1,PromptPlusLibrary.ITreeMultiSelectControl<T>,System.Threading.Tasks.Task> interactionAction);

Type parameters

T1

Parameters

items System.Collections.Generic.IEnumerable<T1>

interactionAction System.Func<T1,PromptPlusLibrary.ITreeMultiSelectControl<T>,System.Threading.Tasks.Task>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.Options(Action<IControlOptions>) Method

Applies custom options to the control.

PromptPlusLibrary.ITreeMultiSelectControl<T> Options(System.Action<PromptPlusLibrary.IControlOptions> options);

Parameters

options System.Action<IControlOptions>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.PageSize(byte) Method

Sets the maximum number of visible rows per page.

PromptPlusLibrary.ITreeMultiSelectControl<T> PageSize(byte value);

Parameters

value System.Byte

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.PathSeparator(char) Method

Sets the path separator character used when showing full paths. Default is '/'.

PromptPlusLibrary.ITreeMultiSelectControl<T> PathSeparator(char value);

Parameters

value System.Char

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.PredicateChecked(Func<T,bool>) Method

Sets a predicate that decides whether a node can be checked. Nodes that fail the predicate show an error when the user tries to check them. Only evaluated when marking a node as checked — unchecking an already-checked node is always allowed (subject only to it not being disabled) and never runs this predicate.

PromptPlusLibrary.ITreeMultiSelectControl<T> PredicateChecked(System.Func<T,bool> validselect);

Parameters

validselect System.Func<T,System.Boolean>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.PredicateCheckedAsync(Func<T,Task<bool>>) Method

Asynchronous variant of PredicateChecked(Func<T,bool>).

PromptPlusLibrary.ITreeMultiSelectControl<T> PredicateCheckedAsync(System.Func<T,System.Threading.Tasks.Task<bool>> validselect);

Parameters

validselect System.Func<T,System.Threading.Tasks.Task<System.Boolean>>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.Range(int, Nullable<int>) Method

Defines the valid range for the number of checked items. Confirmation is blocked until the count falls within [minvalue, maxvalue].

PromptPlusLibrary.ITreeMultiSelectControl<T> Range(int minvalue, System.Nullable<int> maxvalue=null);

Parameters

minvalue System.Int32

Minimum number of checked items (≥ 0).

maxvalue System.Nullable<System.Int32>

Optional maximum. When null there is no upper bound.

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.RecursiveMarkWithCtrlSpace(bool) Method

Enables using Ctrl+Space for the recursive container selection (check/uncheck the container and all descendants). When enabled, plain Space only toggles the checked state of the selected node itself, and the recursive action is moved to Ctrl+Space. When disabled (default), plain Space performs the recursive selection on containers (if CascadeCheck(bool) is true).

PromptPlusLibrary.ITreeMultiSelectControl<T> RecursiveMarkWithCtrlSpace(bool value=true);

Parameters

value System.Boolean

true to use Ctrl+Space for recursive marking; otherwise, false.

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>
The same ITreeMultiSelectControl<T> instance for chaining.

ITreeMultiSelectControl<T>.Root(T, bool, bool) Method

Sets the root value of the tree. Must be called before adding any children.

PromptPlusLibrary.ITreeMultiSelectControl<T> Root(T value, bool disable=false, bool check=false);

Parameters

value T

The root value. Cannot be null.

disable System.Boolean

When true, the root cannot be checked. Default is false.

check System.Boolean

When true, the root starts pre-checked. Additive with Default(IEnumerable<T>, bool)/ history — whichever marks it, it stays checked. Subject to cascade the same way an interactive check would be; does not auto-expand the tree to reveal it (unlike Default(IEnumerable<T>, bool)).

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

Exceptions

System.ArgumentNullException
Thrown when value is null.

ITreeMultiSelectControl<T>.Run(CancellationToken) Method

Runs the TreeMultiSelect control and returns the result.

PromptPlusLibrary.ResultPrompt<T[]> Run(System.Threading.CancellationToken token=default(System.Threading.CancellationToken));

Parameters

token System.Threading.CancellationToken

Cancellation token. Defaults to System.Threading.CancellationToken.None.

Returns

PromptPlusLibrary.ResultPrompt<T[]>
A ResultPrompt<T> whose Content is the array of checked values, or an aborted result if the user cancelled.

ITreeMultiSelectControl<T>.ShowFullPath(bool) Method

When true, the answer line shows the full ancestor path for each checked item instead of just its own name. Default is false.

PromptPlusLibrary.ITreeMultiSelectControl<T> ShowFullPath(bool value=true);

Parameters

value System.Boolean

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.Styles(TreeMultiSelectStyles, Style) Method

Overrides a style region for the TreeMultiSelect control.

PromptPlusLibrary.ITreeMultiSelectControl<T> Styles(PromptPlusLibrary.TreeMultiSelectStyles styleType, ConsolePlusLibrary.Style style);

Parameters

styleType TreeMultiSelectStyles

style ConsolePlusLibrary.Style

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.TextSelector(Func<T,string>) Method

Sets the function used to obtain the display text for each node.

PromptPlusLibrary.ITreeMultiSelectControl<T> TextSelector(System.Func<T,string> selector);

Parameters

selector System.Func<T,System.String>

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>

ITreeMultiSelectControl<T>.ViewOnly(bool) Method

Puts the control into view-only mode. The user can navigate and expand/collapse the tree but cannot check items. Enter returns the pre-checked defaults.

PromptPlusLibrary.ITreeMultiSelectControl<T> ViewOnly(bool value=true);

Parameters

value System.Boolean

Returns

PromptPlusLibrary.ITreeMultiSelectControl<T>