Exemple #1
0
        // Summary:
        //     Add the ToolTree
        // Parameter:
        //     path: path to the ToolTree
        //     A examples of path:
        //       "Toolsboxes|Geology|"
        public void add(ToolTreeItem item)
        {
            string path = item.displayPath;

            if (path == null || path.Length == 0)
            {
                this.items.Add(item);
                return;
            }

            string[]     names = path.Split(new char[] { '\\', '/', '|' });
            ToolTreeItem tree  = this;
            string       name  = null;

            for (int i = 0; i < names.Count(); ++i)
            {
                name = names[i];
                if (name.Length == 0)
                {
                    continue;
                }
                ToolTreeItem child = tree.items.FirstOrDefault(x => x.displayName == name);
                if (child == null)
                {
                    child = new ToolTreeItem(null, name);
                    tree.add(child);
                }
                tree = child;
            }
            tree.items.Add(item);
        }
Exemple #2
0
        // Summary:
        //     Find the ToolTree by a path and name
        // Remarks:
        //     A examples of pathName:
        //       "Toolsboxes|Geology|ToolName"
        public ToolTreeItem find(string pathName)
        {
            string[]     names = pathName.Split(new char[] { '\\', '/', '|' });
            ToolTreeItem tree  = this;
            string       name  = null;

            for (int i = 0; i < names.Count(); ++i)
            {
                name = names[i];
                tree = tree.items.FirstOrDefault(x => x.displayName == name);
                if (tree == null)
                {
                    return(null);
                }
            }
            return(tree);
        }