Ejemplo n.º 1
0
        private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewFolderDialog nfd = new NewFolderDialog();

            if (nfd.Show() == DialogResult.OK)
            {
                string newFolderPath = ((Folder)this.projectView.SelectedNode.Tag).Directory.FullName + @"\" + nfd.NewFolderName;
                Directory.CreateDirectory(newFolderPath);

                Folder newFolder = new Folder(newFolderPath);
                newFolder.Persona = ((Folder)this.projectView.SelectedNode.Tag)?.Persona; //if persona is set in parent folder set it to the new folder too

                this.projectView.SelectedNode.Nodes.Add(Folder.getNode(newFolder));
            }
        }
Ejemplo n.º 2
0
        public static TreeNode getNode(Folder folder)
        {
            List<TreeNode> children = new List<TreeNode>();

            foreach(string subFolder in folder.Folders.Keys)
            {
                children.Add(getNode(folder.Folders[subFolder]));
            }
            foreach(string file in folder.Files.Keys)
            {
                TreeNode[] empty = new TreeNode[0];
                TreeNode child = new TreeNode(folder.Files[file].File.Name, 1, 1, empty);
                child.Tag = folder.Files[file];
                child.Name = folder.Files[file].File.Name;
                children.Add(child);
            }
            TreeNode node = new TreeNode(folder.Directory.Name, 0, 0, children.ToArray());
            node.Tag = folder;
            node.Name = folder.Directory.Name;

            return node;
        }
Ejemplo n.º 3
0
        private void updateFolderChildrenPath(Folder folder)
        {
            foreach (PersonaFile file in folder.Files.Values)
            {
                string newFullName = folder.Directory.FullName + file.File.Name;

                int index = DataManager.settings.openedTabs.IndexOf(file.File.FullName);
                if (index >= 0)
                {
                    DataManager.settings.openedTabs[index] = newFullName;
                }

                file.File = new FileInfo(newFullName);
            }
            foreach (Folder childFolder in folder.Folders.Values)
            {
                string newFullName = folder.Directory.FullName + childFolder.Directory.Name;
                childFolder.Directory = new DirectoryInfo(newFullName);
                updateFolderChildrenPath(childFolder);
            }
        }