コード例 #1
0
 public PlaylistTreeModel()
 {
     Root = new PlaylistTreeNodeBase
     {
         Model = this
     };
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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()));
        }
コード例 #4
0
 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);
 }