示例#1
0
    private ToolStripMenuItem getRightClickItem_Add_NewFolder()
    {
        return(new ToolStripMenuItem("New folder", Icons.GetBitmap("menu.newfolder", 16), delegate(object s, EventArgs e) {
            //get the currently selected folder
            ProjectEntity folder = GetSelectedProjectEntity();
            if (folder == null)
            {
                folder = GetSelectedProject().Root;
            }
            ProjectDirectory dir = (ProjectDirectory)folder;

            //define what the new folder name would be
            //(use a counter for every time we hit one that already
            //is called newfolderx
            int folderCounter = 1;
            string folderName = "New folder";
            while (dir.DirectoryExists(folderName))
            {
                folderName = "New folder (" + folderCounter + ")";
                folderCounter++;
            }

            //create the directory
            ProjectDirectory newDir = dir.CreateDirectory(folderName);

            //update the tree
            TreeNode node = findNodeByTag(dir.IsRoot ? (object)dir.Project : (object)dir);
            object st = PushTreeState();
            IndexDirectory(dir, node);
            PopTreeState(st);
            node.Expand();
        }));
    }
示例#2
0
    private void copyFileEntry(string path, ProjectDirectory dir)
    {
        //is the path a file?
        if (File.Exists(path))
        {
            //create the file entry in the directory
            FileInfo    f    = new FileInfo(path);
            ProjectFile file = dir.CreateFile(f.Name);

            //copy over the contents of the file
            //over to the one in the project.
            File.Copy(f.FullName, file.PhysicalLocation, true);
            return;
        }

        //must be a directory, otherwise the path is invalid
        if (!Directory.Exists(path))
        {
            return;
        }

        //create the directory instance in the project
        dir = dir.CreateDirectory(new DirectoryInfo(path).Name);

        //enumerate over all the child directories in the directory
        foreach (DirectoryInfo d in new DirectoryInfo(path).GetDirectories())
        {
            //copy all of the sub-files in this directory
            //by recursively invoking this function
            copyFileEntry(d.FullName, dir);
        }

        //copy all files in the directory
        foreach (FileInfo f in new DirectoryInfo(path).GetFiles())
        {
            //create the file entry in the directory
            ProjectFile file = dir.CreateFile(f.Name);

            //copy over the contents of the file
            //over to the one in the project.
            File.Copy(f.FullName, file.PhysicalLocation, true);
        }
    }
示例#3
0
    private void importProjectFromDirectory(ProjectDirectory vDir, DirectoryInfo pDir)
    {
        //add the directories
        foreach (DirectoryInfo d in pDir.GetDirectories()) {
            importProjectFromDirectory(
                vDir.CreateDirectory(d.Name),
                d);
        }

        //add the files
        foreach (FileInfo f in pDir.GetFiles()) {
            ProjectFile vFile = vDir.CreateFile(f.Name);
            File.Copy(f.FullName, vFile.PhysicalLocation, true);
        }
    }
示例#4
0
    private void copyFileEntry(string path, ProjectDirectory dir)
    {
        //is the path a file?
        if (File.Exists(path)) {
            //create the file entry in the directory
            FileInfo f = new FileInfo(path);
            ProjectFile file = dir.CreateFile(f.Name);

            //copy over the contents of the file
            //over to the one in the project.
            File.Copy(f.FullName, file.PhysicalLocation, true);
            return;
        }

        //must be a directory, otherwise the path is invalid
        if (!Directory.Exists(path)) { return; }

        //create the directory instance in the project
        dir = dir.CreateDirectory(new DirectoryInfo(path).Name);

        //enumerate over all the child directories in the directory
        foreach (DirectoryInfo d in new DirectoryInfo(path).GetDirectories()) {
            //copy all of the sub-files in this directory
            //by recursively invoking this function
            copyFileEntry(d.FullName, dir);
        }

        //copy all files in the directory
        foreach (FileInfo f in new DirectoryInfo(path).GetFiles())  {
            //create the file entry in the directory
            ProjectFile file = dir.CreateFile(f.Name);

            //copy over the contents of the file
            //over to the one in the project.
            File.Copy(f.FullName, file.PhysicalLocation, true);
        }
    }