![]()
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>
T
The type of items in the tree.
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.
Inserts a new sibling immediately after node.
PromptPlusLibrary.ITreeMultiSelectNode<T> AddAfter(PromptPlusLibrary.ITreeNode<T> node, T value, bool disable=false, bool check=false);
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).
PromptPlusLibrary.ITreeMultiSelectNode<T>
System.InvalidOperationException
Thrown if node does not belong to this tree or is the root.
Inserts a new sibling immediately before node.
PromptPlusLibrary.ITreeMultiSelectNode<T> AddBefore(PromptPlusLibrary.ITreeNode<T> node, T value, bool disable=false, bool check=false);
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).
PromptPlusLibrary.ITreeMultiSelectNode<T>
System.InvalidOperationException
Thrown if node does not belong to this tree or is the root.
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);
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).
PromptPlusLibrary.ITreeMultiSelectNode<T>
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);
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).
PromptPlusLibrary.ITreeMultiSelectNode<T>
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);
value System.Boolean
PromptPlusLibrary.ITreeMultiSelectControl<T>
Dynamically updates the description area based on the node currently under the cursor.
PromptPlusLibrary.ITreeMultiSelectControl<T> ChangeDescription(System.Func<T,string> value);
value System.Func<T,System.String>
PromptPlusLibrary.ITreeMultiSelectControl<T>
Asynchronous variant of ChangeDescription(Func<T,string>).
PromptPlusLibrary.ITreeMultiSelectControl<T> ChangeDescriptionAsync(System.Func<T,System.Threading.Tasks.Task<string>> value);
value System.Func<T,System.Threading.Tasks.Task<System.String>>
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
value System.Boolean
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
values System.Collections.Generic.IEnumerable<T>
useDefaultHistory System.Boolean
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
comparer System.Func<T,T,System.Boolean>
PromptPlusLibrary.ITreeMultiSelectControl<T>
Enables history persistence. Previously checked items are restored on next run.
PromptPlusLibrary.ITreeMultiSelectControl<T> EnableHistory(string filename, System.Action<PromptPlusLibrary.IHistoryOptions>? options=null);
filename System.String
options System.Action<IHistoryOptions>
PromptPlusLibrary.ITreeMultiSelectControl<T>
Sets a function that returns optional extra information rendered next to each node label.
PromptPlusLibrary.ITreeMultiSelectControl<T> ExtraInfo(System.Func<T,string?> extraInfoNode);
extraInfoNode System.Func<T,System.String>
PromptPlusLibrary.ITreeMultiSelectControl<T>
System.ArgumentNullException
When extraInfoNode is null.
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);
extraInfoNode System.Func<T,System.Threading.Tasks.Task<System.String>>
PromptPlusLibrary.ITreeMultiSelectControl<T>
System.ArgumentNullException
When extraInfoNode is null.
Sets the filter strategy for the filter mode. Default is Disabled.
PromptPlusLibrary.ITreeMultiSelectControl<T> Filter(PromptPlusLibrary.FilterMode value);
value FilterMode
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
T1
items System.Collections.Generic.IEnumerable<T1>
interactionAction System.Action<T1,PromptPlusLibrary.ITreeMultiSelectControl<T>>
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
T1
items System.Collections.Generic.IEnumerable<T1>
interactionAction System.Func<T1,PromptPlusLibrary.ITreeMultiSelectControl<T>,System.Threading.Tasks.Task>
PromptPlusLibrary.ITreeMultiSelectControl<T>
Applies custom options to the control.
PromptPlusLibrary.ITreeMultiSelectControl<T> Options(System.Action<PromptPlusLibrary.IControlOptions> options);
options System.Action<IControlOptions>
PromptPlusLibrary.ITreeMultiSelectControl<T>
Sets the maximum number of visible rows per page.
PromptPlusLibrary.ITreeMultiSelectControl<T> PageSize(byte value);
value System.Byte
PromptPlusLibrary.ITreeMultiSelectControl<T>
Sets the path separator character used when showing full paths. Default is '/'.
PromptPlusLibrary.ITreeMultiSelectControl<T> PathSeparator(char value);
value System.Char
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
validselect System.Func<T,System.Boolean>
PromptPlusLibrary.ITreeMultiSelectControl<T>
Asynchronous variant of PredicateChecked(Func<T,bool>).
PromptPlusLibrary.ITreeMultiSelectControl<T> PredicateCheckedAsync(System.Func<T,System.Threading.Tasks.Task<bool>> validselect);
validselect System.Func<T,System.Threading.Tasks.Task<System.Boolean>>
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
minvalue System.Int32
Minimum number of checked items (≥ 0).
maxvalue System.Nullable<System.Int32>
Optional maximum. When null there is no upper bound.
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
value System.Boolean
true to use Ctrl+Space for recursive marking; otherwise, false.
PromptPlusLibrary.ITreeMultiSelectControl<T>
The same ITreeMultiSelectControl<T> instance for chaining.
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);
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)).
PromptPlusLibrary.ITreeMultiSelectControl<T>
System.ArgumentNullException
Thrown when value is null.
Runs the TreeMultiSelect control and returns the result.
PromptPlusLibrary.ResultPrompt<T[]> Run(System.Threading.CancellationToken token=default(System.Threading.CancellationToken));
token System.Threading.CancellationToken
Cancellation token. Defaults to System.Threading.CancellationToken.None.
PromptPlusLibrary.ResultPrompt<T[]>
A ResultPrompt<T> whose Content is the array of checked values,
or an aborted result if the user cancelled.
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);
value System.Boolean
PromptPlusLibrary.ITreeMultiSelectControl<T>
Overrides a style region for the TreeMultiSelect control.
PromptPlusLibrary.ITreeMultiSelectControl<T> Styles(PromptPlusLibrary.TreeMultiSelectStyles styleType, ConsolePlusLibrary.Style style);
styleType TreeMultiSelectStyles
style ConsolePlusLibrary.Style
PromptPlusLibrary.ITreeMultiSelectControl<T>
Sets the function used to obtain the display text for each node.
PromptPlusLibrary.ITreeMultiSelectControl<T> TextSelector(System.Func<T,string> selector);
selector System.Func<T,System.String>
PromptPlusLibrary.ITreeMultiSelectControl<T>
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);
value System.Boolean