コード例 #1
0
ファイル: Hierarchy.cs プロジェクト: hesam/SketchSharp
        /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.AddNewFolder"]/*' />
        /// <summary>
        /// Get's called to a add a new Folder to the project hierarchy. Opens the dialog to do so and
        /// creates the physical representation
        /// </summary>
        /// <returns></returns>
        public int AddNewFolder(){
            // first generate a new folder name...
            try{
                string relFolder;
                object dummy = null;
                IVsProject3 project = (IVsProject3)this.projectMgr;
                IVsUIHierarchyWindow uiWindow = this.projectMgr.GetIVsUIHierarchyWindow(VsConstants.Guid_SolutionExplorer);

                project.GenerateUniqueItemName(this.hierarchyId, "", "", out relFolder);

                if (this != this.projectMgr){
                    // add this guys relpath to it...
                    relFolder = this.xmlNode.GetAttribute("RelPath") + relFolder;
                }
                // create the project part of it, the xml in the xsproj file
                XmlElement e = this.projectMgr.AddFolderNodeToProject(relFolder);
                HierarchyNode child = new HierarchyNode(this.projectMgr, HierarchyNodeType.Folder, e);
                this.AddChild(child);

                child.CreateDirectory();
                // we need to get into label edit mode now...
                // so first select the new guy...
                uiWindow.ExpandItem(this.projectMgr, child.hierarchyId, EXPANDFLAGS.EXPF_SelectItem);
                // them post the rename command to the shell. Folder verification and creation will
                // happen in the setlabel code...
                this.projectMgr.UIShell.PostExecCommand(ref VsConstants.guidStandardCommandSet97, (uint)VsCommands.Rename, 0, ref dummy);
            } catch{
            }

            return 0;
        }
コード例 #2
0
ファイル: Hierarchy.cs プロジェクト: hesam/SketchSharp
        /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.AddNewFolder"]/*' />
        /// <summary>
        /// Get's called to a add a new Folder to the project hierarchy. Opens the dialog to do so and
        /// creates the physical representation
        /// </summary>
        /// <returns></returns>
        public int AddNewFolder()
		{
            CCITracing.TraceCall();
            // first generate a new folder name...
            try
			{
                string relFolder;
                object dummy = null;
                IVsProject3 project = (IVsProject3)this.projectMgr;
                IVsUIHierarchyWindow uiWindow = this.projectMgr.GetIVsUIHierarchyWindow(HierarchyNode.Guid_SolutionExplorer);

                NativeMethods.ThrowOnFailure(project.GenerateUniqueItemName(this.hierarchyId, "", "", out relFolder));

                // create the project part of it, the project file
                HierarchyNode child = new HierarchyNode(this.projectMgr, HierarchyNodeType.Folder, relFolder);
                this.AddChild(child);

                child.CreateDirectory();
                // we need to get into label edit mode now...
                // so first select the new guy...
                NativeMethods.ThrowOnFailure(uiWindow.ExpandItem(this.projectMgr, child.hierarchyId, EXPANDFLAGS.EXPF_SelectItem));
                // them post the rename command to the shell. Folder verification and creation will
                // happen in the setlabel code...
                NativeMethods.ThrowOnFailure(this.projectMgr.UIShell.PostExecCommand(ref VsMenus.guidStandardCommandSet97, (uint)VsCommands.Rename, 0, ref dummy));
            }
			catch (Exception e)
			{
                CCITracing.Trace(e);
            }

            return 0;
        }