int IProjectSourceNode.IncludeInProject(bool recursive) { if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } else if (!this.IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } ThreadHelper.ThrowIfNotOnUIThread(); using (XHelperMethods.NewWaitCursor()) { // Check out the project file. if (!this.ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } // make sure that all parent folders are included in the project XHelperMethods.EnsureParentFolderIncluded(this); // now add this node to the project. this.AddToMSBuild(recursive); this.ReDraw(UIHierarchyElement.Icon); // refresh property browser... XHelperMethods.RefreshPropertyBrowser(); } return(VSConstants.S_OK); }
protected virtual int IncludeInProject() { XProjectNode projectNode = this.ProjectMgr as XProjectNode; if (projectNode == null || projectNode.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } else if (!this.IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } using (XHelperMethods.NewWaitCursor()) { // Check out the project file. if (!projectNode.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) { IProjectSourceNode node = child as IProjectSourceNode; if (node != null) { int result = node.IncludeInProject(); if (result != VSConstants.S_OK) { return(result); } } } // make sure that all parent folders are included in the project XHelperMethods.EnsureParentFolderIncluded(this); ThreadHelper.ThrowIfNotOnUIThread(); // now add this node to the project. this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, false); this.ItemNode = projectNode.CreateMsBuildFileProjectElement(this.Url); this.ProjectMgr.Tracker.OnItemAdded(this.Url, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags); // notify others ////projectNode.OnItemAdded(this.Parent, this); this.ReDraw(UIHierarchyElement.Icon); // We have to redraw the icon of the node as it is now a member of the project and should be drawn using a different icon. this.ReDraw(UIHierarchyElement.SccState); // update the SCC state icon. this.ResetProperties(); this.SetSpecialProperties(); // allows to set generators etc. // refresh property browser... XHelperMethods.RefreshPropertyBrowser(); } return(VSConstants.S_OK); }
protected internal int ToggleShowAllFiles() { if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } using (XHelperMethods.NewWaitCursor()) { ThreadHelper.ThrowIfNotOnUIThread(); this.showAllFilesEnabled = !this.showAllFilesEnabled; // toggle the flag if (this.showAllFilesEnabled) { XProjectMembers.AddNonMemberItems(this); } else { XProjectMembers.RemoveNonMemberItems(this); } } return(VSConstants.S_OK); }
int IProjectSourceNode.ExcludeFromProject() { XProjectNode projectNode = this.ProjectMgr as XProjectNode; if (projectNode == null || projectNode.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } else if (this.IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } using (XHelperMethods.NewWaitCursor()) { // Check out the project file. if (!projectNode.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } // remove children, if any, before removing from the hierarchy for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) { IProjectSourceNode node = child as IProjectSourceNode; if (node != null) { int result = node.ExcludeFromProject(); if (result != VSConstants.S_OK) { return(result); } } } ThreadHelper.ThrowIfNotOnUIThread(); if (projectNode != null && projectNode.ShowAllFilesEnabled && Directory.Exists(this.Url)) { string url = this.Url; this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); this.ItemNode.RemoveFromProjectFile(); this.ItemNode = new ProjectElement(this.ProjectMgr, null, true); // now we have to create a new ItemNode to indicate that this is virtual node. this.ItemNode.Rename(url); this.ItemNode.SetMetadata(ProjectFileConstants.Name, this.Url); this.ReDraw(UIHierarchyElement.Icon); // we have to redraw the icon of the node as it is now not a member of the project and shoul be drawn using a different icon. } else if (this.Parent != null) // the project node has no parentNode { // this is important to make it non member item. otherwise, the multi-selection scenario would // not work if it has any parent child relation. this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // remove from the hierarchy this.OnItemDeleted(); this.Parent.RemoveChild(this); this.ItemNode.RemoveFromProjectFile(); } // refresh property browser... XHelperMethods.RefreshPropertyBrowser(); } return(VSConstants.S_OK); }
protected override int ExcludeFromProject() { if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } else if (this.IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } using (XHelperMethods.NewWaitCursor()) { for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) { IProjectSourceNode node = child as IProjectSourceNode; if (node != null) { int result = node.ExcludeFromProject(); if (result != VSConstants.S_OK) { return(result); } } } // Ask Document tracker listeners if we can remove the item. { // just to limit the scope. string documentToRemove = this.GetMkDocument(); string[] filesToBeDeleted = new string[1] { documentToRemove }; VSQUERYREMOVEFILEFLAGS[] queryRemoveFlags = this.GetQueryRemoveFileFlags(filesToBeDeleted); if (!this.ProjectMgr.Tracker.CanRemoveItems(filesToBeDeleted, queryRemoveFlags)) { return((int)OleConstants.OLECMDERR_E_CANCELED); } // Close the document if it has a manager. DocumentManager manager = this.GetDocumentManager(); if (manager != null) { if (manager.Close(__FRAMECLOSE.FRAMECLOSE_PromptSave) == VSConstants.E_ABORT) { // User cancelled operation in message box. return(VSConstants.OLE_E_PROMPTSAVECANCELLED); } } // Check out the project file. if (!this.ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } } // close the document window if open. this.CloseDocumentWindow(this); XProjectNode projectNode = this.ProjectMgr as XProjectNode; var name = this.Url; ThreadHelper.ThrowIfNotOnUIThread(); if (projectNode != null && projectNode.ShowAllFilesEnabled && File.Exists(this.Url)) { // need to store before removing the node. string url = this.Url; string include = this.ItemNode.GetMetadata(ProjectFileConstants.Include); this.ItemNode.RemoveFromProjectFile(); this.ProjectMgr.Tracker.OnItemRemoved(url, VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags); this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // Set it as non member item this.ItemNode = new ProjectElement(this.ProjectMgr, null, true); // now we have to set a new ItemNode to indicate that this is virtual node. this.ItemNode.Rename(include); this.ItemNode.SetMetadata(ProjectFileConstants.Name, url); ////this.ProjectMgr.OnItemAdded(this.Parent, this); this.ReDraw(UIHierarchyElement.Icon); // We have to redraw the icon of the node as it is now not a member of the project and should be drawn using a different icon. this.ReDraw(UIHierarchyElement.SccState); // update the SCC state icon. } else if (this.Parent != null) // the project node has no parentNode { // Remove from the Hierarchy this.OnItemDeleted(); this.Parent.RemoveChild(this); this.ItemNode.RemoveFromProjectFile(); } projectNode.RemoveURL(name); this.ResetProperties(); // refresh property browser... XHelperMethods.RefreshPropertyBrowser(); } return(VSConstants.S_OK); }