// Summary: // Add the ControlTreeItem // Parameter: // path: path to the ControlTreeItem // A examples of path: // "Charts" public void add(ControlTreeItem item) { string path = item.displayPath; if (path == null || path.Length == 0) { this.items.Add(item); return; } string[] names = path.Split(new char[] { '\\', '/', '|' }); ControlTreeItem tree = this; string name = null; for (int i = 0; i < names.Count(); ++i) { name = names[i]; if (name.Length == 0) { continue; } ControlTreeItem child = tree.items.FirstOrDefault(x => x.displayName == name); if (child == null) { child = new ControlTreeItem(null, name); tree.add(child); } tree = child; } tree.items.Add(item); }
// Summary: // Find the ToolTree by a path and name // Remarks: // A examples of pathName: // "Toolsboxes|Geology|ToolName" public ControlTreeItem find(string pathName) { string[] names = pathName.Split(new char[] { '\\', '/', '|' }); ControlTreeItem 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); }