コード例 #1
0
 public XFolderNode(XProjectNode root, string directoryPath, ProjectElement element, bool isNonMemberItem)
     : base(root, directoryPath, element)
 {
     this.isNonMemberItem = isNonMemberItem;
     // Folders do not participate in SCC.
     base.ExcludeNodeFromScc = true;
 }
コード例 #2
0
ファイル: XFileNode.cs プロジェクト: orangesocks/XSharpPublic
        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);
        }
コード例 #3
0
        private static void AddNonMemberFileItems(XProjectNode project, IList <string> fileList)
        {
            Utilities.ArgumentNotNull("fileList", fileList);

            foreach (string fileKey in fileList)
            {
                HierarchyNode parentNode = project;
                string[]      pathItems  = fileKey.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });

                if (String.Equals(fileKey, project.ProjectFile, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                XFolderNode topFolderNode = null;
                foreach (string fileOrDir in pathItems)
                {
                    string   childNodeId   = Path.Combine(parentNode.VirtualNodeName, fileOrDir);
                    FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        break;
                    }

                    //HierarchyNode childNode = project.FindURL(fileOrDirInfo.FullName);
                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as XFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                            {
                                topFolderNode = null;
                            }
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        element.Rename(childNodeId);
                        element.SetMetadata(ProjectFileConstants.Name, childNodeId);
                        childNode = project.CreateFileNode(element);
                        parentNode.AddChild(childNode);
                        break;
                    }

                    parentNode = childNode;
                }
                ThreadHelper.ThrowIfNotOnUIThread();

                if (topFolderNode != null)
                {
                    topFolderNode.CollapseFolder();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Reloads all nodes which are not part of the project,
        /// ensuring that they match the current file structure on disk
        /// </summary>
        /// <param name="node">The selected hierarchy node</param>
        internal static void RefreshProject(HierarchyNode node)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            XProjectNode projectNode = node.ProjectMgr as XProjectNode;

            if (projectNode.ShowAllFilesEnabled)
            {
                projectNode.ToggleShowAllFiles();
                projectNode.ToggleShowAllFiles();
            }
        }
コード例 #5
0
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Creates a new project property object.
        /// </summary>
        /// <param name="project">Project that owns the property.</param>
        /// <param name="propertyName">Name of the property.</param>
        public ProjectProperty(XProjectNode project, string propertyName, bool perConfig)
        {
            XHelperMethods.VerifyNonNullArgument(project, "project");
            XHelperMethods.VerifyNonNullArgument(propertyName, "propertyName");

            this.project      = project;
            this.propertyName = propertyName;

            this.perUser          = ProjectProperty.PerUserProperties.Contains(propertyName);
            this.perConfig        = perConfig;
            this.allowVariables   = ProjectProperty.AllowVariablesProperties.Contains(propertyName);
            this.list             = ProjectProperty.ListProperties.Contains(propertyName);
            this.endOfProjectFile = ProjectProperty.EndOfProjectFileProperties.Contains(propertyName);
        }
コード例 #6
0
        internal static void RemoveNonMemberItems(XProjectNode project)
        {
            IList <HierarchyNode> nodeList = new List <HierarchyNode>();

            XHelperMethods.FindNodes(nodeList, project, XProjectMembers.IsNodeNonMemberItem, null);
            ThreadHelper.ThrowIfNotOnUIThread();
            for (int index = nodeList.Count - 1; index >= 0; index--)
            {
                HierarchyNode node   = nodeList[index];
                HierarchyNode parent = node.Parent;

                node.OnItemDeleted();
                parent.RemoveChild(node);
            }
        }
コード例 #7
0
        internal static void AddNonMemberItems(XProjectNode project)
        {
            IList <string> files   = new List <string>();
            IList <string> folders = new List <string>();

            // obtain the list of files and folders under the project folder.
            XProjectMembers.GetRelativeFileSystemEntries(project.ProjectFolder, null, files, folders);

            // exclude the items which are the part of the build.
            XProjectMembers.ExcludeProjectBuildItems(project, files, folders);
            ThreadHelper.ThrowIfNotOnUIThread();

            XProjectMembers.AddNonMemberFolderItems(project, folders);
            XProjectMembers.AddNonMemberFileItems(project, files);
        }
コード例 #8
0
        private static void AddNonMemberFolderItems(XProjectNode project, IList <string> folderList)
        {
            if (folderList == null)
            {
                throw new ArgumentNullException("folderList");
            }

            foreach (string folderKey in folderList)
            {
                HierarchyNode parentNode    = project;
                string[]      folders       = folderKey.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                XFolderNode   topFolderNode = null;
                foreach (string folder in folders)
                {
                    string   childNodeId = Path.Combine(parentNode.VirtualNodeName, folder);
                    FileInfo folderInfo  = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((folderInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        break;
                    }

                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as XFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                            {
                                topFolderNode = null;
                            }
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        childNode = project.CreateFolderNode(childNodeId, element);
                        parentNode.AddChild(childNode);
                    }

                    parentNode = childNode;
                }
                ThreadHelper.ThrowIfNotOnUIThread();

                if (topFolderNode != null)
                {
                    topFolderNode.CollapseFolder();
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Adds the this node to the build system.
        /// </summary>
        /// <param name="recursive">Flag to indicate if the addition should be recursive.</param>
        protected virtual void AddToMSBuild(bool recursive)
        {
            XProjectNode projectNode = this.ProjectMgr as XProjectNode;

            if (projectNode == null || projectNode.IsClosed)
            {
                return; // do nothing
            }
            ThreadHelper.ThrowIfNotOnUIThread();

            this.ItemNode = projectNode.CreateMsBuildFolderProjectElement(this.Url);
            this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, false);
            if (recursive)
            {
                for (HierarchyNode node = this.FirstChild; node != null; node = node.NextSibling)
                {
                    IProjectSourceNode sourceNode = node as IProjectSourceNode;
                    if (sourceNode != null)
                    {
                        sourceNode.IncludeInProject(recursive);
                    }
                }
            }
        }
コード例 #10
0
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XFolderNode"/> class.
        /// </summary>
        /// <param name="root">The root <see cref="XProjectNode"/> that contains this node.</param>
        /// <param name="directoryPath">Root of the hierarchy.</param>
        /// <param name="element">The element that contains MSBuild properties.</param>
        public XFolderNode(XProjectNode root, string directoryPath, ProjectElement element)
            : this(root, directoryPath, element, false)
        {
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: XFileNode.cs プロジェクト: orangesocks/XSharpPublic
 public XFileNode(XProjectNode root, ProjectElement element, bool isNonMemberItem)
     : base(root, element)
 {
     this.isNonMemberItem = isNonMemberItem;
 }
コード例 #13
0
        /// <summary>
        /// Excludes the file and folder items from their corresponding maps if they are part of the build.
        /// </summary>
        /// <param name="project">The project to modify.</param>
        /// <param name="fileList">List containing relative files paths.</param>
        /// <param name="folderList">List containing relative folder paths.</param>
        private static void ExcludeProjectBuildItems(XProjectNode project, IList <string> fileList, IList <string> folderList)
        {
            var projectItems = project.BuildProject.Items;

            if (projectItems == null)
            {
                return; // do nothing, just ignore it.
            }
            else if (fileList == null && folderList == null)
            {
                throw new ArgumentNullException("folderList");
            }

            // we need these maps because we need to have both lowercase and actual case path information.
            // we use lower case paths for case-insesitive search of file entries and actual paths for
            // creating hierarchy node. if we don't do that, we will end up with duplicate nodes when the
            // case of path in .vnproj file doesn't match with the actual file path on the disk.
            IDictionary <string, string> folderMap = null;
            IDictionary <string, string> fileMap   = null;

            if (folderList != null)
            {
                folderMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                foreach (string folder in folderList)
                {
                    folderMap.Add(folder, folder);
                }
            }

            if (fileList != null)
            {
                fileMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                foreach (string file in fileList)
                {
                    fileMap.Add(file, file);
                }
            }
            foreach (var buildItem in projectItems)
            {
                if (folderMap != null &&
                    folderMap.Count > 0 &&
                    String.Equals(buildItem.ItemType, ProjectFileConstants.Folder, StringComparison.OrdinalIgnoreCase))
                {
                    string relativePath = buildItem.EvaluatedInclude;
                    if (Path.IsPathRooted(relativePath)) // if not the relative path, make it relative
                    {
                        relativePath = XHelperMethods.GetRelativePath(project.ProjectFolder, relativePath);
                    }


                    if (folderMap.ContainsKey(relativePath))
                    {
                        folderList.Remove(folderMap[relativePath]); // remove it from the actual list.
                        folderMap.Remove(relativePath);
                    }
                }
                else if (fileMap != null &&
                         fileMap.Count > 0 &&
                         XSharpFileType.IsProjectItemType(buildItem))
                {
                    string relativePath = buildItem.EvaluatedInclude;
                    if (Path.IsPathRooted(relativePath)) // if not the relative path, make it relative
                    {
                        relativePath = XHelperMethods.GetRelativePath(project.ProjectFolder, relativePath);
                    }

                    if (fileMap.ContainsKey(relativePath))
                    {
                        fileList.Remove(fileMap[relativePath]); // remove it from the actual list.
                        fileMap.Remove(relativePath);
                    }
                }
            }
        }
コード例 #14
0
ファイル: XFileNode.cs プロジェクト: orangesocks/XSharpPublic
        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);
        }
コード例 #15
0
        /// <summary>
        /// The environment calls this to set the currently selected objects that the property page should show.
        /// </summary>
        /// <param name="count">The count of elements in <paramref name="punk"/>.</param>
        /// <param name="punk">An array of <b>IUnknown</b> objects to show in the property page.</param>
        /// <remarks>
        /// We are supposed to cache these objects until we get another call with <paramref name="count"/> = 0.
        /// Also, the environment is supposed to call this before calling <see cref="IPropertyPage2.Activate"/>,
        /// but like all things when interacting with Visual Studio, don't trust that and code defensively.
        /// </remarks>
        void IPropertyPage.SetObjects(uint count, object[] punk)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (count == 0)
            {
                if (this.project != null)
                {
                    //this.project.OutputTypeChanged -= this.HandleOutputTypeChanged;
                    this.project.OnProjectPropertyChanged -= Project_OnProjectPropertyChanged;
                    this.project = null;
                }

                return;
            }

            if (punk[0] is ProjectConfig)
            {
                List <XProjectConfig> configs = new List <XProjectConfig>();

                for (int i = 0; i < count; i++)
                {
                    XProjectConfig config = (XProjectConfig)punk[i];

                    if (this.project == null)
                    {
                        this.project = config.ProjectMgr as XProjectNode;
                        this.project.OnProjectPropertyChanged += Project_OnProjectPropertyChanged;
                    }

                    configs.Add(config);
                }

                this.projectConfigs = configs.ToArray();
            }
            else if (punk[0] is NodeProperties)
            {
                if (this.project == null)
                {
                    this.project = (punk[0] as NodeProperties).Node.ProjectMgr as XProjectNode;
                    this.project.OnProjectPropertyChanged += Project_OnProjectPropertyChanged;
                }

                Dictionary <string, XProjectConfig> configsMap = new Dictionary <string, XProjectConfig>();

                for (int i = 0; i < count; i++)
                {
                    NodeProperties property = (NodeProperties)punk[i];
                    IVsCfgProvider provider;
                    ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider));
                    uint[] expected = new uint[1];
                    ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null));
                    if (expected[0] > 0)
                    {
                        XProjectConfig[] configs = new XProjectConfig[expected[0]];
                        uint[]           actual  = new uint[1];
                        int hr = provider.GetCfgs(expected[0], configs, actual, null);
                        if (hr != 0)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }

                        foreach (XProjectConfig config in configs)
                        {
                            if (!configsMap.ContainsKey(config.ConfigName))
                            {
                                configsMap.Add(config.ConfigName, config);
                            }
                        }
                    }
                }

                if (configsMap.Count > 0)
                {
                    if (this.projectConfigs == null)
                    {
                        this.projectConfigs = new XProjectConfig[configsMap.Keys.Count];
                    }

                    configsMap.Values.CopyTo(this.projectConfigs, 0);
                }
            }

            if (this.active && this.project != null)
            {
                this.PropertyPagePanel.BindProperties();
                this.IsDirty = false;
            }
        }
コード例 #16
0
        /// Handles command status on source a node. Should be overridden by descendant nodes.
        /// </summary>
        /// <param name="node">A HierarchyNode that implements the IProjectSourceNode interface.</param>
        /// <param name="guidCmdGroup">A unique identifier of the command group. The pguidCmdGroup parameter can be NULL to specify the standard group.</param>
        /// <param name="cmd">The command to query status for.</param>
        /// <param name="result">An out parameter specifying the QueryStatusResult of the command.</param>
        /// <param name="returnCode">If the method succeeds, it returns S_OK. If it fails, it returns an error code.</param>
        /// <returns>Returns true if the status request is handled, false otherwise.</returns>
        public static bool QueryStatusOnProjectSourceNode(HierarchyNode node, Guid guidCmdGroup, uint cmd, ref QueryStatusResult result, out int returnCode)
        {
            if (guidCmdGroup == VsMenus.guidStandardCommandSet2K)
            {
                IProjectSourceNode sourceNode = node as IProjectSourceNode;
                FileNode           fnode      = node as FileNode;
                switch ((VsCommands2K)cmd)
                {
                case VsCommands2K.SHOWALLFILES:
                {
                    XProjectNode projectNode = node.ProjectMgr as XProjectNode;
                    result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
                    if (projectNode != null && projectNode.ShowAllFilesEnabled)
                    {
                        result |= QueryStatusResult.LATCHED; // it should be displayed as pressed
                    }

                    returnCode = VSConstants.S_OK;
                    return(true); // handled.
                }

                case VsCommands2K.INCLUDEINPROJECT:
                    // if it is a non member item node, the we support "Include In Project" command
                    if (fnode != null && fnode.IsDependent)
                    {
                        returnCode = (int)OleConstants.MSOCMDERR_E_NOTSUPPORTED;
                        return(true); // handled.
                    }
                    if (sourceNode != null && sourceNode.IsNonMemberItem)
                    {
                        result    |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
                        returnCode = VSConstants.S_OK;
                        return(true); // handled.
                    }

                    break;

                case VsCommands2K.EXCLUDEFROMPROJECT:
                    // if it is a non member item node, then we don't support "Exclude From Project" command
                    if (sourceNode != null && sourceNode.IsNonMemberItem)
                    {
                        returnCode = (int)OleConstants.MSOCMDERR_E_NOTSUPPORTED;
                        return(true);  // handled.
                    }
                    if (fnode != null && fnode.IsDependent)
                    {
                        returnCode = (int)OleConstants.MSOCMDERR_E_NOTSUPPORTED;
                        return(true); // handled.
                    }


                    break;
                }
            }

            if (VsMenus.guidStandardCommandSet97 == guidCmdGroup)
            {
                switch ((VsCommands)cmd)
                {
                case VsCommands.AddNewItem:
                case VsCommands.AddExistingItem:
                    result     = QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
                    returnCode = VSConstants.S_OK;
                    return(true);
                }
            }

            // just an arbitrary value, it doesn't matter if method hasn't handled the request
            returnCode = VSConstants.S_FALSE;

            // not handled
            return(false);
        }
コード例 #17
0
ファイル: XFileNode.cs プロジェクト: orangesocks/XSharpPublic
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XSharpFileNode"/> class.
        /// </summary>
        /// <param name="root">The project node.</param>
        /// <param name="e">The project element node.</param>
        internal XFileNode(XProjectNode root, ProjectElement element)
            : this(root, element, false)
        {
        }
コード例 #18
0
        /// <summary>
        /// When building a project in VS, the configuration of referenced projects cannot be determined
        /// by MSBuild or from within an MSBuild task. So we'll get them from the VS project system here.
        /// </summary>
        /// <param name="project">The project where the properties are being defined; also the project
        /// whose references are being examined.</param>
        internal static void DefineProjectReferenceConfigurations(XProjectNode project)
        {
            StringBuilder configList = new StringBuilder();

            IVsSolutionBuildManager solutionBuildManager =
                XHelperMethods.GetService <IVsSolutionBuildManager, SVsSolutionBuildManager>(project.Site);

            List <ProjectReferenceNode> referenceNodes = new List <ProjectReferenceNode>();

            project.FindNodesOfType(referenceNodes);

            foreach (ProjectReferenceNode referenceNode in referenceNodes)
            {
                try
                {
                    IVsHierarchy hierarchy = VsShellUtilities.GetHierarchy(referenceNode.ProjectMgr.Site, referenceNode.ReferencedProjectGuid);

                    string          configuration   = null;
                    IVsProjectCfg2  projectCfg2     = null;
                    IVsProjectCfg[] projectCfgArray = new IVsProjectCfg[1];
                    ThreadHelper.ThrowIfNotOnUIThread();

                    // this can fail for some reason... this code was copied from Wix and probably isn't stable yet.
                    // this routine is called from InvokeMSBuild and we don't want that to fix because of
                    // some bug here, so this code is surrounded by try/catch until we figure this out
                    int hr = solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, projectCfgArray);
                    ErrorHandler.ThrowOnFailure(hr);

                    projectCfg2 = projectCfgArray[0] as IVsProjectCfg2;

                    if (projectCfg2 != null)
                    {
                        hr = projectCfg2.get_DisplayName(out configuration);
                        if (hr != 0)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }
                    }

                    if (configuration != null)
                    {
                        if (configList.Length > 0)
                        {
                            configList.Append(';');
                        }

                        configList.Append(referenceNode.ReferencedProjectName);
                        configList.Append('=');
                        configList.Append(configuration);
                    }
                }
                catch (Exception)
                {
                    ;
                }
            }

            if (configList.Length > 0)
            {
                project.BuildProject.SetGlobalProperty("VSProjectConfigurations", configList.ToString());
            }
        }
コード例 #19
0
 public void Initialize(XProjectNode project, XBuildEventEditorForm editorForm)
 {
     this.project    = project;
     this.editorForm = editorForm;
 }