Interface ITreeNode<TItem>
A node in a tree. A tree is a structure in which every node can have one parent (or no parent if it's the root) and several children (or no children, which will make it a leaf in the tree).
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface ITreeNode<TItem> : IDisposable where TItem : class, IInTree<TItem>
Type Parameters
Name | Description |
---|---|
TItem |
Properties
| Improve this Doc View SourceChildren
Gets the items contained in the children.
Declaration
IAGSBindingList<TItem> Children { get; }
Property Value
Type | Description |
---|---|
IAGSBindingList<TItem> | The children. |
ChildrenCount
Gets the number of children this node has.
Declaration
int ChildrenCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The children count. |
Node
Gets the item contained in the node.
Declaration
TItem Node { get; }
Property Value
Type | Description |
---|---|
TItem | The node. |
OnParentChanged
An event which fires whenever the parent for a node changes.
Declaration
IBlockingEvent OnParentChanged { get; }
Property Value
Type | Description |
---|---|
IBlockingEvent | The event. |
Parent
Gets the item contained in the parent.
Declaration
TItem Parent { get; }
Property Value
Type | Description |
---|---|
TItem | The parent. |
Methods
| Improve this Doc View SourceAddChild(TItem)
Adds a child to the node.
Declaration
void AddChild(TItem child)
Parameters
Type | Name | Description |
---|---|---|
TItem | child | Child. |
AddChildren(List<TItem>)
Adds the list of children to the node.
Declaration
void AddChildren(List<TItem> children)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TItem> | children | Children. |
FindDescendant(Predicate<TItem>)
Find a descendant who matches a specific predicate.
Declaration
TItem FindDescendant(Predicate<TItem> isMatch)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<TItem> | isMatch | The predicate. |
Returns
Type | Description |
---|---|
TItem | The descendant, or null if not found. |
Examples
For example, to find a child with a specific id:
var child = tree.FindDescendant(item => item.Entity.ID == "My ID");
|
Improve this Doc
View Source
FindPreviousSibling(Predicate<TItem>)
Finds the previous sibling which matches a specific predicate.
Declaration
TItem FindPreviousSibling(Predicate<TItem> isMatch)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<TItem> | isMatch | Is match. |
Returns
Type | Description |
---|---|
TItem | The previous sibling. |
GetRoot()
Returns the root of the tree (the node which has no parent).
Declaration
TItem GetRoot()
Returns
Type | Description |
---|---|
TItem | The root. |
HasChild(TItem)
Is the specified item a child of this node?
Declaration
bool HasChild(TItem child)
Parameters
Type | Name | Description |
---|---|---|
TItem | child | Child. |
Returns
Type | Description |
---|---|
System.Boolean |
|
InsertChild(Int32, TItem)
Inserts the child to the node at the specified index.
Declaration
void InsertChild(int index, TItem child)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index. |
TItem | child | Child. |
RemoveChild(TItem)
Removes the specified child from the node.
Declaration
void RemoveChild(TItem child)
Parameters
Type | Name | Description |
---|---|---|
TItem | child | Child. |
SetParent(ITreeNode<TItem>)
Sets a new parent for the node.
Declaration
void SetParent(ITreeNode<TItem> parent)
Parameters
Type | Name | Description |
---|---|---|
ITreeNode<TItem> | parent | Parent. |
StealParent(ITreeNode<TItem>)
"Steals" the parent from the specified node: this will make this node have the specified node's parent as its parent, and the specified node will remain with no parent.
Declaration
void StealParent(ITreeNode<TItem> victim)
Parameters
Type | Name | Description |
---|---|---|
ITreeNode<TItem> | victim | Victim. |