public TreePathEventArgs(TreePath path) { if (path == null) throw new ArgumentNullException(); _path = path; }
public Node FindNode(TreePath path) { if (path.IsEmpty()) return _root; else return FindNode(_root, path, 0); }
public System.Collections.IEnumerable GetChildren(TreePath treePath) { Node node = FindNode(treePath); if (node != null) foreach (Node n in node.Nodes) yield return n; else yield break; }
/// <summary> /// /// </summary> /// <param name="parent">Path to a parent node</param> /// <param name="indices">Indices of children in parent nodes collection</param> /// <param name="children">Child nodes</param> public TreeModelEventArgs(TreePath parent, int[] indices, object[] children) : base(parent) { if (children == null) throw new ArgumentNullException(); if (indices != null && indices.Length != children.Length) throw new ArgumentException("indices and children arrays must have the same length"); _indices = indices; _children = children; }
public TreePathEventArgs() { _path = new TreePath(); }
/// <summary> /// /// </summary> /// <param name="parent">Path to a parent node</param> /// <param name="children">Child nodes</param> public TreeModelEventArgs(TreePath parent, object[] children) : this(parent, null, children) { }
public bool IsLeaf(TreePath treePath) { Node node = FindNode(treePath); if (node != null) return node.IsLeaf; else throw new ArgumentException("treePath"); }
private Node FindNode(Node root, TreePath path, int level) { foreach (Node node in root.Nodes) if (node == path.FullPath[level]) { if (level == path.FullPath.Length - 1) return node; else return FindNode(node, path, level + 1); } return null; }