RTree class
public sealed class RTree : UserControlA tree of RTreeNode with selection, search and lazy items.
Constructors
RTree()An empty tree, without the search box.
Properties
TreeView View { get; }The TreeView inside, for styles and properties not given here.
TextBox SearchBox { get; }The search box, for its placeholder in another language.
bool Searchable { get; set; }Whether the search box above the tree is shown (false).
IReadOnlyList<RTreeNode> Roots { get; }The nodes at the top.
RTreeNode Selected { get; }The selected node (null: none).
string Filter { get; set; }The words searched: the nodes whose text or value contains them (case not counted) stay, with those above and below; the empty text shows everything. Only the children already known are searched: a loader is not called by the filter.
int Found { get; }How many nodes matched the last filter.
Methods
static RTree FromJson(string json)The tree of a JSON text (RTreeNode.FromJson): its members at the top.
static RTree FromXml(string xml)The tree of an XML text (RTreeNode.FromXml): the root element at the top.
RTree Add(params RTreeNode[] nodes)Adds nodes at the top.
bool Remove(RTreeNode node)Removes a node at the top; false if it is not one.
void Clear()Removes every node.
void LoadJson(string json)Shows a JSON text in place of what is there.
void LoadXml(string xml)Shows an XML text in place of what is there.
void LoadNode(RNode data)Shows a tree of data in place of what is there: a root without a name (a JSON document) leaves its members at the top, a root with a name (an XML element) is the only node at the top. Each node keeps its RNode in Tag.
void Select(RTreeNode node)Selects a node, opening the nodes above it and scrolling to it.
void Expand(RTreeNode node)Opens a node, and the nodes above it.
void Collapse(RTreeNode node)Closes a node (its children keep their state).
void ExpandAll(int levels = 2147483647)Opens the nodes down to the given depth (1: the roots only). Every loader on the way is called: on a disk, keep the depth small.
void CollapseAll()Closes every node.
RTreeNode Find(string path, string separator = "/")The node at a path written as RTreeNode.Path writes it, «server/port» or, with «.», «items[2].name» (null if there is none). The children are loaded on the way.
Events
event Action<RTreeNode> SelectionChangedWhen the selected node changes (null: none).
event Action<RTreeNode> OpenedWhen a node is opened: double click, or Enter on the selection.