Exemple #1
0
        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.
            }

            using (WixHelperMethods.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
                WixHelperMethods.EnsureParentFolderIncluded(this);

                // now add this node to the project.
                this.AddToMSBuild(recursive);
                this.ReDraw(UIHierarchyElement.Icon);

                // refresh property browser...
                WixHelperMethods.RefreshPropertyBrowser();
            }

            return(VSConstants.S_OK);
        }
Exemple #2
0
        int IProjectSourceNode.IncludeInProject()
        {
            WixProjectNode projectNode = this.ProjectMgr as WixProjectNode;

            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 (WixHelperMethods.NewWaitCursor())
            {
                // Check out the project file.
                if (!projectNode.QueryEditProjectFile(false))
                {
                    throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
                }

                // make sure that all parent folders are included in the project
                WixHelperMethods.EnsureParentFolderIncluded(this);

                // 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();

                // refresh property browser...
                WixHelperMethods.RefreshPropertyBrowser();
            }

            return(VSConstants.S_OK);
        }
        /// <summary>
        /// Toggles the state of Show all files
        /// </summary>
        /// <returns>S_OK if it's possible to toggle the state, OLECMDERR_E_NOTSUPPORTED if not</returns>
        protected internal int ToggleShowAllFiles()
        {
            if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }

            using (WixHelperMethods.NewWaitCursor())
            {
                this.showAllFilesEnabled = !this.showAllFilesEnabled; // toggle the flag

                if (this.showAllFilesEnabled)
                {
                    WixProjectMembers.AddNonMemberItems(this);
                }
                else
                {
                    WixProjectMembers.RemoveNonMemberItems(this);
                }
            }

            return(NativeMethods.S_OK);
        }
Exemple #4
0
        int IProjectSourceNode.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 (WixHelperMethods.NewWaitCursor())
            {
                // 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);

                WixProjectNode projectNode = this.ProjectMgr as WixProjectNode;

                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();
                }

                this.ResetProperties();

                // refresh property browser...
                WixHelperMethods.RefreshPropertyBrowser();
            }

            return(VSConstants.S_OK);
        }
Exemple #5
0
        int IProjectSourceNode.ExcludeFromProject()
        {
            WixProjectNode projectNode = this.ProjectMgr as WixProjectNode;

            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 (WixHelperMethods.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);
                        }
                    }
                }

                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...
                WixHelperMethods.RefreshPropertyBrowser();
            }

            return(VSConstants.S_OK);
        }