Exemple #1
0
        public static IList <NexonArchiveFileEntry> GetFilesRecursive(TreeNode node, IList <NexonArchiveFileEntry> files)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (files == null)
            {
                throw new ArgumentNullException("files");
            }
            IList <NexonArchiveFileEntry> directoryFiles = node.Tag as IList <NexonArchiveFileEntry>;

            if (directoryFiles != null)
            {
                foreach (NexonArchiveFileEntry file in directoryFiles)
                {
                    files.Add(file);
                }
            }
            foreach (object obj in node.Nodes)
            {
                TreeNode childNode = (TreeNode)obj;
                FolderTreeView.GetFilesRecursive(childNode, files);
            }
            return(files);
        }
Exemple #2
0
 private void verifyAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.archive != null && this.treeView.TopNode != null)
     {
         List <NexonArchiveFileEntry> files = new List <NexonArchiveFileEntry>();
         FolderTreeView.GetFilesRecursive(this.treeView.TopNode, files);
         this.VerifyFiles(this, new FilesEventArgs(FolderTreeView.GetFullPath(this.treeView.TopNode), files));
     }
 }
Exemple #3
0
 private void verifyToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (base.SelectedNode != null)
     {
         List <NexonArchiveFileEntry> files = new List <NexonArchiveFileEntry>();
         FolderTreeView.GetFilesRecursive(base.SelectedNode, files);
         this.OnVerifyFolder(new FilesEventArgs(FolderTreeView.GetFullPath(base.SelectedNode), files));
     }
 }
Exemple #4
0
 public static string GetFullPath(TreeNode node)
 {
     if (node == null || node.Parent == null)
     {
         return(string.Empty);
     }
     if (node.Parent != null && node.Parent.Parent != null)
     {
         return(FolderTreeView.GetFullPath(node.Parent) + "/" + node.Text);
     }
     return(node.Text);
 }
Exemple #5
0
        private static TreeNode FindOrCreateNodePath(TreeNode rootNode, string path)
        {
            if (path.Length == 0)
            {
                return(rootNode);
            }
            int startIndex = 0;

            while (path[startIndex] == '/' || path[startIndex] == '\\')
            {
                startIndex++;
            }
            int separatorIndex = path.IndexOfAny(new char[]
            {
                '/',
                '\\'
            }, startIndex);
            string name;

            if (separatorIndex >= 0)
            {
                name = path.Substring(startIndex, separatorIndex - startIndex);
            }
            else
            {
                name = path.Substring(startIndex);
            }
            TreeNode finalNode = null;

            foreach (object obj in rootNode.Nodes)
            {
                TreeNode node = (TreeNode)obj;
                if (string.Compare(node.Name, name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    finalNode = node;
                    break;
                }
            }
            if (finalNode == null)
            {
                finalNode      = new TreeNode(name);
                finalNode.Name = name;
                rootNode.Nodes.Add(finalNode);
            }
            if (separatorIndex >= 0)
            {
                return(FolderTreeView.FindOrCreateNodePath(finalNode, path.Substring(separatorIndex + 1)));
            }
            return(finalNode);
        }
Exemple #6
0
        public void LoadArchive(NexonArchive archive)
        {
            base.Nodes.Clear();
            if (archive == null)
            {
                return;
            }
            TreeNode rootNode = new TreeNode("(root)");

            foreach (NexonArchiveFileEntry entry in archive.FileEntries)
            {
                TreeNode node = FolderTreeView.FindOrCreateNodePath(rootNode, Path.GetDirectoryName(entry.Path));
                IList <NexonArchiveFileEntry> nodeList = node.Tag as IList <NexonArchiveFileEntry>;
                if (nodeList == null)
                {
                    nodeList = new List <NexonArchiveFileEntry>();
                    node.Tag = nodeList;
                }
                nodeList.Add(entry);
            }
            rootNode.Expand();
            base.Nodes.Add(rootNode);
            base.SelectedNode = rootNode;
        }
Exemple #7
0
 public TreeSort(FolderTreeView treeView)
 {
     this.treeView = treeView;
 }
Exemple #8
0
 private void FolderTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     this.OnShowFolder(new FilesEventArgs(FolderTreeView.GetFullPath(e.Node), e.Node.Tag as List <NexonArchiveFileEntry>));
 }