Avalonia solo in codiceEnglish

API › RAVAL

RTreeNode class

Il riferimento e' in inglese: viene dai commenti del sorgente di RAVAL, che dalla 2.0 ha nomi e commenti in inglese.

public sealed class RTreeNode

A node of an RTree, with children added or loaded when needed.

Costruttori

RTreeNode(string text, string value = null)

A node with a text and, if given, a value.

RTreeNode(string text, Func<RTreeNode, IEnumerable<RTreeNode>> loader)

A node whose children are read by the loader the first time they are needed (when it is opened, searched or walked).

Proprietà

string Text { get; set; }

The text shown.

string Value { get; set; }

The value, shown dimmed after the text (null: none).

string Key { get; set; }

The segment of the path: the text, unless set.

object Tag { get; set; }

Anything the caller wants to keep with the node.

Color? Color { get; set; }

The color of the text (null: the color of the theme).

TreeViewItem Item { get; }

The item on the screen (null until the node above is opened): for a context menu, a tooltip, a style.

RTreeNode Parent { get; }

The node above (null for a root).

bool Loaded { get; }

Whether the children are known (added, or already loaded).

bool HasChildren { get; }

Whether the node has children, or may have (not yet loaded).

IReadOnlyList<RTreeNode> Children { get; }

The children, read by the loader the first time.

IReadOnlyList<RTreeNode> KnownChildren { get; }

The children already known, without loading (empty if not loaded).

int Depth { get; }

How deep the node is: 0 for a root.

Metodi

RTreeNode Add(params RTreeNode[] children)

Adds children at the end.

bool Remove(RTreeNode child)

Removes a child; false if it is not a child of this node.

void Reload()

Forgets the loaded children: the loader reads them again (a folder whose files have changed). Nothing for a node without a loader.

string Path(string separator = "/")

The path from the root: the keys joined by the separator, and the keys that begin with «[» (the items of an array) attached without it. Path(".") of a JSON value is «server.port» or «items[2].name», the same keys RSettings reads.

IEnumerable<RTreeNode> Descendants()

The node and all the nodes below it, depth first. Only the children already known: a loader is not called (a disk is not read whole).

RTreeNode Child(string key)

The child with the key (null if none); loads the children.

string ToString()

The text and the value, as a line.

static RTreeNode FromJson(string json, string name = "json")

The tree of a JSON text (RNode.FromJson): objects and arrays are nodes with their members as children (the value shows how many: «{3}», «[12]»), texts, numbers and true/false are leaves with their value. Throws JsonException if the text is not JSON.

static RTreeNode FromXml(string xml)

The tree of an XML text (RNode.FromXml): one node for each element, its text as the value, the attributes as the first children with the key «@name». Throws XmlException if the text is not XML.

static RTreeNode FromNode(RNode data, string name = "data")

The tree of an RNode already read or built, the RNode kept in Tag of each node. A root without a name takes the given one.

static RTreeNode FromFolder(string path)

A folder whose content is read when the node is opened: the folders first, then the files with their size, both in alphabetical order. The full path is in Tag. A folder that cannot be read shows the error as its only child.