Beispiel #1
0
        private void SetSelectedFiles()
        {
            selectedFiles.Clear();
            foreach (TreeListNode node in list.Selection)
            {
                if (node.Tag is VPK.File)
                {
                    // It's a file
                    VPK.File file = node.Tag as VPK.File;
                    this.selectedFiles.Add(file);
                }
                else
                {
                    // It's a folder
                }
            }

            if ((selectedFiles.Count == 1 && MultiSelect == false) || (selectedFiles.Count > 0 && MultiSelect == true))
            {
                okButton.Enabled = true;
            }
            else
            {
                okButton.Enabled = false;
            }
        }
Beispiel #2
0
        private List <string> GetSelectedPaths()
        {
            List <string> selectedPaths = new List <string>();

            foreach (TreeListNode node in list.Selection)
            {
                if (!(node.Tag is VPK.File))
                {
                    // It's a folder
                    selectedPaths.Add(node.Tag.ToString());
                }
                else
                {
                    // It's a file
                    VPK.File file = node.Tag as VPK.File;
                    selectedPaths.Add(file.path);
                }
            }
            return(selectedPaths);
        }
Beispiel #3
0
        private void traverseFileTree()
        {
            tree.BeginUnboundLoad();
            tree.Nodes.Clear();

            Stack <TreeListNode> stack       = new Stack <TreeListNode>();
            Stack <string>       stackString = new Stack <string>();

            string rootName = "root";

            if (RootDirectory != string.Empty)
            {
                rootName = new DirectoryInfo(RootDirectory).Name;
            }

            stack.Push(tree.AppendNode(new object[] { rootName }, null));
            stack.Peek().Tag             = string.Empty;
            stack.Peek().StateImageIndex = 0;

            for (int f = 0; f < files.Count; f++)
            {
                VPK.File file = files[f];

                string[] fileSplit = file.path.Substring(RootDirectory.Length).Split('/');

                while (stackString.Count >= fileSplit.Length)
                {
                    stackString.Pop();
                    stack.Pop();
                }

                for (int i = stackString.Count - 1; i >= 0; i--)
                {
                    if (stackString.Peek() != fileSplit[i])
                    {
                        stackString.Pop();
                        stack.Pop();
                    }
                    else
                    {
                        break;
                    }
                }

                for (int i = stack.Count - 1; i < fileSplit.Length - 1; i++)
                {
                    string tag = fileSplit[i] + "/";
                    if (stackString.Count > 0)
                    {
                        tag = stack.Peek().Tag.ToString() + tag;
                    }

                    stack.Push(tree.AppendNode(new object[] { fileSplit[i] }, stack.Peek()));
                    stack.Peek().Tag             = tag;
                    stack.Peek().StateImageIndex = 0;
                    stackString.Push(fileSplit[i]);
                }
            }

            tree.ExpandToLevel(0);

            tree.EndUnboundLoad();
        }
Beispiel #4
0
        private void TraverseDirectoryFiltered(string directory)
        {
            buttonUp.Enabled      = (CurrentDirectory != string.Empty);
            buttonBack.Enabled    = (previousDirectories.Count > 0);
            buttonForward.Enabled = (nextDirectories.Count > 0);

            textDirectory.EditValue = "Search results for " + keywords;

            list.BeginUnboundLoad();
            list.Nodes.Clear();

            List <VPK.File> filtered = files.Where(x => x.path.Contains(keywords)).ToList();

            List <string> usedFiles = new List <string>();

            for (int f = 0; f < filtered.Count; f++)
            {
                VPK.File file = filtered[f];
                string   path = file.path;

                if (!path.StartsWith(directory))
                {
                    continue;
                }

                string[] fileSplit = path.Split('/');

                string dir = string.Empty;
                for (int j = 0; j < fileSplit.Length; j++)
                {
                    dir = dir + fileSplit[j] + "/";

                    if (!fileSplit[j].Contains(keywords))
                    {
                        continue;
                    }

                    if (j < fileSplit.Length - 1)
                    {
                        // It's a directory
                        if (usedFiles.Contains(dir))
                        {
                            continue;
                        }

                        TreeListNode node = list.AppendNode(new object[] { path, "Folder" }, null);
                        node.Tag             = dir;
                        node.StateImageIndex = 0;
                        usedFiles.Add(dir);
                    }
                    else
                    {
                        // It's a file
                        TreeListNode node = list.AppendNode(new object[] { path, file.type, file.pack }, null);
                        node.Tag             = file;
                        node.StateImageIndex = 1;
                        usedFiles.Add(path);
                    }
                }
            }

            list.EndUnboundLoad();
        }
Beispiel #5
0
        private void TraverseDirectory(string directory)
        {
            CurrentDirectory      = directory;
            buttonUp.Enabled      = (CurrentDirectory != string.Empty);
            buttonBack.Enabled    = (previousDirectories.Count > 0);
            buttonForward.Enabled = (nextDirectories.Count > 0);

            keywords             = string.Empty;
            textSearch.EditValue = string.Empty;

            if (directory.Contains("/"))
            {
                repositoryTextSearch.NullValuePrompt = "Search in " +
                                                       directory.Substring(0, directory.Length - 1).Split('/').Last();
            }
            else
            {
                repositoryTextSearch.NullValuePrompt = "Search";
            }

            textDirectory.EditValue = directory;

            list.BeginUnboundLoad();
            list.Nodes.Clear();

            List <string> usedFiles = new List <string>();

            for (int f = 0; f < files.Count; f++)
            {
                VPK.File file = files[f];
                string   path = file.path;

                if (!path.StartsWith(directory))
                {
                    continue;
                }

                path = path.Substring(directory.Length);

                string[] fileSplit = path.Split('/');

                if (fileSplit.Length > 1)
                {
                    // It's a directory
                    if (usedFiles.Contains(fileSplit[0]))
                    {
                        continue;
                    }

                    TreeListNode node = list.AppendNode(new object[] { fileSplit[0], "Folder" }, null);
                    node.Tag             = directory + fileSplit[0] + "/";
                    node.StateImageIndex = 0;
                    usedFiles.Add(fileSplit[0]);
                }
                else
                {
                    // It's a file
                    TreeListNode node = list.AppendNode(new object[] { fileSplit[0], file.type, file.pack }, null);
                    //node.Tag = directory + path;
                    node.Tag             = file;
                    node.StateImageIndex = 1;
                    usedFiles.Add(path);
                }
            }

            list.EndUnboundLoad();
        }