![]()
Provides a fluent API for configuring and running the TreeSelect control, which browses an arbitrary hierarchy of items of type T as an expandable/collapsible tree.
public interface ITreeSelectControl<T>
T
The type of items in the tree.
The tree structure is built explicitly by the caller through Root(T, bool),
AddLast(T, bool)/AddFirst(T, bool) (first-level nodes),
AddAfter(ITreeNode<T>, T, bool)/AddBefore(ITreeNode<T>, T, bool)
(sibling insertion) and AddLast(T, bool)/
AddFirst(T, bool) (nested children). Whether a node is a
container or a leaf is inferred from whether it has children. The rendered tree
materializes visible rows lazily on expand and releases them on collapse, keeping memory
proportional to what is visible. Nodes can be marked disable at creation time so
they are shown and navigable but cannot be confirmed.
Inserts a sibling immediately after node.
PromptPlusLibrary.ITreeNode<T> AddAfter(PromptPlusLibrary.ITreeNode<T> node, T value, bool disable=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 confirmed. Default is false.
PromptPlusLibrary.ITreeNode<T>
System.ArgumentNullException
When node is null.
System.InvalidOperationException
When node does not belong to this tree.
Inserts a sibling immediately before node.
PromptPlusLibrary.ITreeNode<T> AddBefore(PromptPlusLibrary.ITreeNode<T> node, T value, bool disable=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 confirmed. Default is false.
PromptPlusLibrary.ITreeNode<T>
System.ArgumentNullException
When node is null.
System.InvalidOperationException
When node does not belong to this tree.
Adds a first-level node (child of the root) at the beginning.
PromptPlusLibrary.ITreeNode<T> AddFirst(T value, bool disable=false);
value T
The value of the new node. Cannot be null.
disable System.Boolean
When true, the new node cannot be confirmed. Default is false.
PromptPlusLibrary.ITreeNode<T>
System.InvalidOperationException
When the root has not been set yet.
Adds a first-level node (child of the root) at the end.
PromptPlusLibrary.ITreeNode<T> AddLast(T value, bool disable=false);
value T
The value of the new node. Cannot be null.
disable System.Boolean
When true, the new node cannot be confirmed. Default is false.
PromptPlusLibrary.ITreeNode<T>
The newly created node so children can be attached to it.
System.InvalidOperationException
When the root has not been set yet.
Dynamically updates the prompt description based on the currently selected node.
PromptPlusLibrary.ITreeSelectControl<T> ChangeDescription(System.Func<T,string> value);
value System.Func<T,System.String>
A function that receives the current item and returns the description. Cannot be null.
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When value is null.
Asynchronous counterpart of ChangeDescription(Func<T,string>). The task is awaited synchronously (blocking) each frame.
PromptPlusLibrary.ITreeSelectControl<T> ChangeDescriptionAsync(System.Func<T,System.Threading.Tasks.Task<string>> value);
value System.Func<T,System.Threading.Tasks.Task<System.String>>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When value is null.
Pre-selects an item, expanding the tree down to it when reachable from the root.
PromptPlusLibrary.ITreeSelectControl<T> Default(T value, bool useDefaultHistory=true);
value T
useDefaultHistory System.Boolean
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When value is null.
Sets the item comparator used to locate the default value and the value restored from history within the tree. Required.
PromptPlusLibrary.ITreeSelectControl<T> DefaultMatchBy(System.Func<T,T,bool> comparer);
comparer System.Func<T,T,System.Boolean>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When comparer is null.
Enables history: the selected value is serialized as JSON and stored, and on the next run the tree is searched (using DefaultMatchBy(Func<T,T,bool>)) for an item that equals the restored value so that it can be pre-selected.
PromptPlusLibrary.ITreeSelectControl<T> EnableHistory(string filename, System.Action<PromptPlusLibrary.IHistoryOptions>? options=null);
filename System.String
options System.Action<IHistoryOptions>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When filename is null.
Sets an optional extra info selector rendered next to the node text.
PromptPlusLibrary.ITreeSelectControl<T> ExtraInfo(System.Func<T,string?> extraInfoNode);
extraInfoNode System.Func<T,System.String>
PromptPlusLibrary.ITreeSelectControl<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.ITreeSelectControl<T> ExtraInfoAsync(System.Func<T,System.Threading.Tasks.Task<string?>> extraInfoNode);
extraInfoNode System.Func<T,System.Threading.Tasks.Task<System.String>>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When extraInfoNode is null.
Enables interactive filtering. When the user types a printable character while the tree is in select mode the control switches to filter mode, flattens the whole tree once and applies the requested FilterMode against the node full path (parent chain joined by PathSeparator(char)). Clearing the filter restores the lazy tree view preserving the previous expand/collapse state.
PromptPlusLibrary.ITreeSelectControl<T> Filter(PromptPlusLibrary.FilterMode value);
value FilterMode
The FilterMode to apply.
PromptPlusLibrary.ITreeSelectControl<T>
Iterates items and invokes interactionAction for each element, giving the caller a chance to add first-level nodes (and further descendants) programmatically. Equivalent to calling AddLast(T, bool) inside the loop.
PromptPlusLibrary.ITreeSelectControl<T> Interaction<T1>(System.Collections.Generic.IEnumerable<T1> items, System.Action<T1,PromptPlusLibrary.ITreeSelectControl<T>> interactionAction);
T1
items System.Collections.Generic.IEnumerable<T1>
interactionAction System.Action<T1,PromptPlusLibrary.ITreeSelectControl<T>>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When items or interactionAction is null.
Asynchronous counterpart of Interaction<T1>(IEnumerable<T1>, Action<T1,ITreeSelectControl<T>>). The tasks are awaited sequentially (blocking) so tree construction remains deterministic.
PromptPlusLibrary.ITreeSelectControl<T> InteractionAsync<T1>(System.Collections.Generic.IEnumerable<T1> items, System.Func<T1,PromptPlusLibrary.ITreeSelectControl<T>,System.Threading.Tasks.Task> interactionAction);
T1
items System.Collections.Generic.IEnumerable<T1>
interactionAction System.Func<T1,PromptPlusLibrary.ITreeSelectControl<T>,System.Threading.Tasks.Task>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When items or interactionAction is null.
Applies the shared control options (prompt, tooltips, abort behavior).
PromptPlusLibrary.ITreeSelectControl<T> Options(System.Action<PromptPlusLibrary.IControlOptions> options);
options System.Action<IControlOptions>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When options is null.
Sets the maximum number of visible rows per page (0 = auto-fit).
PromptPlusLibrary.ITreeSelectControl<T> PageSize(byte value);
value System.Byte
PromptPlusLibrary.ITreeSelectControl<T>
Sets the character used to compose the full path in the answer line. Default is '/'.
PromptPlusLibrary.ITreeSelectControl<T> PathSeparator(char value);
value System.Char
PromptPlusLibrary.ITreeSelectControl<T>
Sets a validation predicate evaluated when the user presses Enter. When it returns
false, the selection is rejected and a generic error is shown.
PromptPlusLibrary.ITreeSelectControl<T> PredicateSelected(System.Func<T,bool> validselect);
validselect System.Func<T,System.Boolean>
PromptPlusLibrary.ITreeSelectControl<T>
Sets an asynchronous validation predicate evaluated (blocking) when the user presses Enter.
PromptPlusLibrary.ITreeSelectControl<T> PredicateSelectedAsync(System.Func<T,System.Threading.Tasks.Task<bool>> validselect);
validselect System.Func<T,System.Threading.Tasks.Task<System.Boolean>>
PromptPlusLibrary.ITreeSelectControl<T>
The asynchronous predicate is evaluated synchronously (blocking) on the UI thread.
Sets the root value shown as the top-level node. Required.
PromptPlusLibrary.ITreeSelectControl<T> Root(T value, bool disable=false);
value T
The root value. Cannot be null.
disable System.Boolean
When true, the root cannot be confirmed. Default is false.
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When value is null.
Displays the TreeSelect control and blocks until the user confirms or cancels.
PromptPlusLibrary.ResultPrompt<T?> Run(System.Threading.CancellationToken token=default(System.Threading.CancellationToken));
token System.Threading.CancellationToken
PromptPlusLibrary.ResultPrompt<T>
When enabled, blocks selection of container nodes (only leaves can be confirmed).
PromptPlusLibrary.ITreeSelectControl<T> SelectLeafOnly(bool value=true);
value System.Boolean
PromptPlusLibrary.ITreeSelectControl<T>
Shows the full path (parent chain) instead of only the entry name in the answer.
PromptPlusLibrary.ITreeSelectControl<T> ShowFullPath(bool value=true);
value System.Boolean
PromptPlusLibrary.ITreeSelectControl<T>
Overrides visual styles for a specific region of the TreeSelect control.
PromptPlusLibrary.ITreeSelectControl<T> Styles(PromptPlusLibrary.TreeSelectStyles styleType, ConsolePlusLibrary.Style style);
styleType TreeSelectStyles
style ConsolePlusLibrary.Style
PromptPlusLibrary.ITreeSelectControl<T>
Sets the display text selector. Required.
PromptPlusLibrary.ITreeSelectControl<T> TextSelector(System.Func<T,string> selector);
selector System.Func<T,System.String>
PromptPlusLibrary.ITreeSelectControl<T>
System.ArgumentNullException
When selector is null.
Configures the control for view-only mode, where nodes can be navigated but not selected.
PromptPlusLibrary.ITreeSelectControl<T> ViewOnly(bool value=true);
value System.Boolean
If true, enables view-only mode; otherwise, item selection is enabled.