Ejemplo n.º 1
0
 protected override ImageMoniker GetIconMoniker(bool open)
 {
     if (ItemNode.IsExcluded)
     {
         return(KnownMonikers.HiddenFile);
     }
     else if (!File.Exists(Url))
     {
         return(KnownMonikers.DocumentWarning);
     }
     else if (IsFormSubType)
     {
         return(FormFileIconMoniker);
     }
     else if (this._project.IsCodeFile(FileName))
     {
         if (CommonUtils.IsSamePath(this.Url, _project.GetStartupFile()))
         {
             return(StartupCodeFileIconMoniker);
         }
         else
         {
             return(CodeFileIconMoniker);
         }
     }
     return(default(ImageMoniker));
 }
Ejemplo n.º 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);
        }