/// <summary> /// Adds the node. /// </summary> /// <param name="node">The node.</param> public virtual void AddNode(ZeroitFastTreeNode node) { if (node.Parent != this) { childs.Add(node); } SetParent(this); }
/// <summary> /// Sets the parent. /// </summary> /// <param name="value">The value.</param> protected virtual void SetParent(ZeroitFastTreeNode value) { if (parent != null && parent != value) { parent.childs.Remove(this); } parent = value; }
/// <summary> /// Gets the parent. /// </summary> /// <param name="tagCondition">The tag condition.</param> /// <returns>ZeroitFastTreeNode.</returns> public ZeroitFastTreeNode GetParent(Predicate <object> tagCondition) { var parent = Parent; while (parent != null && !tagCondition(parent.Tag)) { parent = parent.parent; } return(parent); }
/// <summary> /// Inserts the node before. /// </summary> /// <param name="existsNode">The exists node.</param> /// <param name="nodes">The nodes.</param> public virtual void InsertNodeBefore(ZeroitFastTreeNode existsNode, IEnumerable <ZeroitFastTreeNode> nodes) { var i = childs.IndexOf(existsNode); if (i < 0) { i = 0; } InsertNode(i, nodes); }
/// <summary> /// Inserts the node before. /// </summary> /// <param name="existsNode">The exists node.</param> /// <param name="node">The node.</param> public virtual void InsertNodeBefore(ZeroitFastTreeNode existsNode, ZeroitFastTreeNode node) { var i = childs.IndexOf(existsNode); if (i < 0) { i = 0; } InsertNode(i, node); }
/// <summary> /// Removes the node. /// </summary> /// <param name="node">The node.</param> public virtual void RemoveNode(ZeroitFastTreeNode node) { childs.Remove(node); SetParent(null); }
/// <summary> /// Indexes the of. /// </summary> /// <param name="node">The node.</param> /// <returns>System.Int32.</returns> public int IndexOf(ZeroitFastTreeNode node) { return(childs.IndexOf(node)); }
/// <summary> /// Inserts the node after. /// </summary> /// <param name="existsNode">The exists node.</param> /// <param name="nodes">The nodes.</param> public virtual void InsertNodeAfter(ZeroitFastTreeNode existsNode, IEnumerable <ZeroitFastTreeNode> nodes) { var i = childs.IndexOf(existsNode) + 1; InsertNode(i, nodes); }
/// <summary> /// Inserts the node after. /// </summary> /// <param name="existsNode">The exists node.</param> /// <param name="node">The node.</param> public virtual void InsertNodeAfter(ZeroitFastTreeNode existsNode, ZeroitFastTreeNode node) { var i = childs.IndexOf(existsNode) + 1; InsertNode(i, node); }
/// <summary> /// Inserts the node. /// </summary> /// <param name="index">The index.</param> /// <param name="node">The node.</param> public virtual void InsertNode(int index, ZeroitFastTreeNode node) { childs.Insert(index, node); SetParent(this); }