Ejemplo n.º 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.
            }
            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);
        }
Ejemplo n.º 2
0
        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);
        }