public PlaylistTreeModel() { Root = new PlaylistTreeNodeBase { Model = this }; }
internal void OnNodeRemoved(PlaylistTreeNodeBase parent, int index, PlaylistTreeNodeBase node) { if (NodesRemoved != null) { var args = new TreeModelEventArgs(GetPath(parent), new[] { index }, new object[] { node }); NodesRemoved(this, args); } }
public TreePath GetPath(PlaylistTreeNodeBase node) { if (node == Root) { return(TreePath.Empty); } var stack = new Stack <object>(); while (node != Root) { stack.Push(node); node = node.Parent; } return(new TreePath(stack.ToArray())); }
private static PlaylistTreeNodeBase FindNode(PlaylistTreeNodeBase root, TreePath path, int level) { foreach (var 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); }