internal override int IncludeInProject(bool includeChildren)
        {
            if (Parent.ItemNode != null && Parent.ItemNode.IsExcluded)
            {
                // if our parent is excluded it needs to first be included
                int hr = Parent.IncludeInProject(false);
                if (ErrorHandler.Failed(hr))
                {
                    return(hr);
                }
            }

            if (!ProjectMgr.QueryEditProjectFile(false) ||
                !ProjectMgr.Tracker.CanAddItems(new[] { Url }, new[] { VSQUERYADDFILEFLAGS.VSQUERYADDFILEFLAGS_NoFlags }))
            {
                return(VSConstants.E_FAIL);
            }

            ResetNodeProperties();
            ItemNode = ProjectMgr.CreateMsBuildFileItem(
                CommonUtils.GetRelativeFilePath(ProjectMgr.ProjectHome, Url),
                ProjectFileConstants.Compile
                );
            IsVisible = true;
            ProjectMgr.OnInvalidateItems(Parent);
            ProjectMgr.ReDrawNode(this, UIHierarchyElement.Icon);
            ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, 0);
            return(VSConstants.S_OK);
        }
Exemple #2
0
        internal override int IncludeInProject(bool includeChildren)
        {
            if (Parent.ItemNode != null && Parent.ItemNode.IsExcluded)
            {
                // if our parent is excluded it needs to first be included
                int hr = Parent.IncludeInProject(false);
                if (ErrorHandler.Failed(hr))
                {
                    return(hr);
                }
            }

            if (!ProjectMgr.QueryEditProjectFile(false) ||
                !ProjectMgr.Tracker.CanAddItems(new[] { Url }, new[] { VSQUERYADDFILEFLAGS.VSQUERYADDFILEFLAGS_NoFlags }))
            {
                return(VSConstants.E_FAIL);
            }

            ResetNodeProperties();
            ItemNode = ProjectMgr.CreateMsBuildFileItem(
                CommonUtils.GetRelativeFilePath(ProjectMgr.ProjectHome, Url),
                ProjectMgr.IsCodeFile(Url) ? ProjectFileConstants.Compile : ProjectFileConstants.Content
                );
            IsVisible = true;
            ProjectMgr.ReDrawNode(this, UIHierarchyElement.Icon);
            ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, 0);

            // https://nodejstools.codeplex.com/workitem/273, refresh the property browser...
            ((IVsUIShell)GetService(typeof(SVsUIShell))).RefreshPropertyBrowser(0);

            if (CommonUtils.IsSamePath(ProjectMgr.GetStartupFile(), Url))
            {
                ProjectMgr.BoldItem(this, true);
            }

            return(VSConstants.S_OK);
        }