public TextureBrowserDialog(string initialSelectedPath) { InitializeComponent(); int initialSelectedNodeIndex = -1; graphicsControl.Size = new Size(0, 0); ResizePanel(); paths = TextureLoader.GetAllPaths(); foreach (string path in paths) { //Check if the folderNode is created Node parent = MakeFolderNode(path); Node textureNode = new Node(path.Substring(path.LastIndexOfAny(new[] { '\\', '/' }) + 1)); textureNode.Image = File; textureNode.Tag = textureNodes.Count; if (path == initialSelectedPath) { initialSelectedNodeIndex = textureNodes.Count; } textureNodes.Add(textureNode); if (parent != null) { parents[textureNode] = parent; } } //Build the tree view includeSnapshots.Add(new List <int>()); int i = 0; foreach (Node textureNode in textureNodes) { includeSnapshots[0].Add(i++); Node node = textureNode; Node parent = parents.ContainsKey(node) ? parents[node] : null; while (parent != null) { if (parent.Nodes.Contains(node)) { node = null; break; } parent.Nodes.Add(node); node = parent; parent = parents.ContainsKey(node) ? parents[node] : null; } if (node != null && !model.Nodes.Contains(node)) { model.Nodes.Add(node); } } TVTextures.Model = model; if (initialSelectedNodeIndex != -1) { initialSelection = TVTextures.FindNode(model.GetPath(textureNodes[initialSelectedNodeIndex])); } }
public void setupNewSearch(string initialSelectedPath) { for (int i = 0; i < paths.Count; ++i) { if (paths[i] == initialSelectedPath) { initialSelection = TVTextures.FindNode(model.GetPath(textureNodes[i])); break; } } }