public EnvDTE.vsCommandStatus GetCommandStatus() { EnvDTE.vsCommandStatus cs = Kit.GetCommandStatusForModel(); EnvDTE.Project pjt = Kit.GetProjectComponent(); if (pjt != null) { switch (Kit.GetProjectLangType(pjt)) { case cfLangType.CSharp: case cfLangType.VBDotNet: // break; default: case cfLangType.CPP: case cfLangType.IronPython: case cfLangType.FSharp: cs = EnvDTE.vsCommandStatus.vsCommandStatusInvisible; break; } } else { cs = EnvDTE.vsCommandStatus.vsCommandStatusInvisible; } return(cs); }
/// <summary> /// Handles common command status checking for the various node types /// </summary> /// <param name="cmdGroup">A unique identifier of the command group</param> /// <param name="cmd">The command for which to query the status</param> /// <param name="result">An out parameter specifying the QueryStatusResult of the command.</param> /// <returns>Returns true if handled, false if not.</returns> private static bool QueryStatusOnCommonCommands(Guid cmdGroup, uint cmd, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet97) { switch ((VsCommands)cmd) { case VsCommands.ClearBreakpoints: case VsCommands.DebugProcesses: case VsCommands.Start: case VsCommands.StartNoDebug: case VsCommands.StepInto: case VsCommands.StepOut: case VsCommands.StepOver: case VsCommands.ToolboxAddItem: case VsCommands.ToolsDebugProcesses: case VsCommands.ToggleBreakpoint: result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return(true); } } if (cmdGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)cmd) { case VsCommands2K.PROJSTARTDEBUG: case VsCommands2K.PROJSTEPINTO: result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return(true); } } return(false); }
/// <inheritdoc /> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.ViewCode) { result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return(VSConstants.S_OK); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
/// <inheritdoc /> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return VSConstants.S_OK; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
/// <inheritdoc /> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return(VSConstants.S_OK); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
/// <inheritdoc /> protected override vsCommandStatus QueryStatusCommandFromOleCommandTarget(Guid cmdGroup, uint cmd, out bool handled) { vsCommandStatus result = vsCommandStatus.vsCommandStatusUnsupported; if (QueryStatusOnCommonCommands(cmdGroup, cmd, ref result)) { handled = true; return(result); } return(base.QueryStatusCommandFromOleCommandTarget(cmdGroup, cmd, out handled)); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)cmd) { case VsCommands2K.INCLUDEINPROJECT: case VsCommands2K.EXCLUDEFROMPROJECT: result = vsCommandStatus.vsCommandStatusUnsupported; return VSConstants.S_OK; default: break; } } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
/// <inheritdoc /> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && (cmd == PkgCmdIDList.OpenInStandaloneGUI || cmd == PkgCmdIDList.ViewBuildLog)) { result |= vsCommandStatus.vsCommandStatusSupported; if (!base.BuildInProgress) { result |= vsCommandStatus.vsCommandStatusEnabled; } return(VSConstants.S_OK); } if (QueryStatusOnCommonCommands(cmdGroup, cmd, ref result)) { return(VSConstants.S_OK); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
/// <summary> /// This command is available if both the file type is valid and if the document /// contains a selection of non-zero size. /// </summary> public void QueryStatus(ref EnvDTE.vsCommandStatus status) { // If there is no supported extension, remove it. If it's supported, but there's no // document selection currently, then disable it (gray-out). CommentPair comments = GetCurrentComments(); if (comments == null) { status = EnvDTE.vsCommandStatus.vsCommandStatusInvisible | EnvDTE.vsCommandStatus.vsCommandStatusUnsupported; } else { EnvDTE.TextDocument textDocument = m_applicationObject.ActiveDocument.Object("TextDocument") as EnvDTE.TextDocument; if (m_applicationObject.ActiveWindow.Document == m_applicationObject.ActiveDocument) { if (textDocument == null) { // Never can happen because of GetCurrentComments' implementation throw new Exception(); } if (textDocument.Selection.TopPoint.AbsoluteCharOffset == textDocument.Selection.BottomPoint.AbsoluteCharOffset) { status = EnvDTE.vsCommandStatus.vsCommandStatusUnsupported; } else { status = EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported; } } else { status = EnvDTE.vsCommandStatus.vsCommandStatusUnsupported; } } }
/// <summary> /// Handles common command status checking for the various node types /// </summary> /// <param name="cmdGroup">A unique identifier of the command group</param> /// <param name="cmd">The command for which to query the status</param> /// <param name="result">An out parameter specifying the QueryStatusResult of the command.</param> /// <returns>Returns true if handled, false if not.</returns> private static bool QueryStatusOnCommonCommands(Guid cmdGroup, uint cmd, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97) { switch((VsCommands)cmd) { case VsCommands.ClearBreakpoints: case VsCommands.DebugProcesses: case VsCommands.Start: case VsCommands.StartNoDebug: case VsCommands.StepInto: case VsCommands.StepOut: case VsCommands.StepOver: case VsCommands.ToolboxAddItem: case VsCommands.ToolsDebugProcesses: case VsCommands.ToggleBreakpoint: result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return true; } } if(cmdGroup == VsMenus.guidStandardCommandSet2K) { switch((VsCommands2K)cmd) { case VsCommands2K.PROJSTARTDEBUG: case VsCommands2K.PROJSTEPINTO: result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return true; } } return false; }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97) { switch((VsCommands)cmd) { case VsCommands.Copy: case VsCommands.Paste: case VsCommands.Cut: case VsCommands.Rename: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; case VsCommands.NewFolder: case VsCommands.AddNewItem: case VsCommands.AddExistingItem: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else if(cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.INCLUDEINPROJECT) { // if it is a non member item node, the we support "Include In Project" command if (IsNonmemberItem) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; } else { result = vsCommandStatus.vsCommandStatusUnsupported; } return VSConstants.S_OK; } else if ((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT) { // if it is a non member item node, then we don't support "Exclude From Project" command if (IsNonmemberItem) { result = vsCommandStatus.vsCommandStatusUnsupported; } else { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; } return VSConstants.S_OK; } } else { return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.QUICKOBJECTSEARCH) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return(VSConstants.S_OK); } } else { return((int)OleConstants.OLECMDERR_E_UNKNOWNGROUP); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
public void QueryStatus(ref EnvDTE.vsCommandStatus status) { // This command is always supported. status = EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported; }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)cmd) { case VsCommands2K.INCLUDEINPROJECT: case VsCommands2K.EXCLUDEFROMPROJECT: result = vsCommandStatus.vsCommandStatusUnsupported; return(VSConstants.S_OK); default: break; } } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
/// <inheritdoc /> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.ViewCode) { result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return VSConstants.S_OK; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97) { switch((VsCommands)cmd) { case VsCommands.AddNewItem: case VsCommands.AddExistingItem: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else if(cmdGroup == VsMenus.guidStandardCommandSet2K) { if((VsCommands2K)cmd == VsCommands2K.ADDREFERENCE) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else { return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
/// <summary> /// Disable certain commands for dependent file nodes /// </summary> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet97) { switch ((VsCommands)cmd) { case VsCommands.Copy: case VsCommands.Paste: case VsCommands.Cut: case VsCommands.Rename: result = vsCommandStatus.vsCommandStatusUnsupported; return(VSConstants.S_OK); case VsCommands.ViewCode: case VsCommands.Open: case VsCommands.OpenWith: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return(VSConstants.S_OK); } } else if (cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT) { result = vsCommandStatus.vsCommandStatusUnsupported; return(VSConstants.S_OK); } } else { return((int)OleConstants.OLECMDERR_E_UNKNOWNGROUP); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
/// <inheritdoc /> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && (cmd == PkgCmdIDList.OpenInStandaloneGUI || cmd == PkgCmdIDList.ViewBuildLog)) { result |= vsCommandStatus.vsCommandStatusSupported; if(!base.BuildInProgress) result |= vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } if(QueryStatusOnCommonCommands(cmdGroup, cmd, ref result)) return VSConstants.S_OK; return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97) { switch((VsCommands)cmd) { case VsCommands.Copy: case VsCommands.Paste: case VsCommands.Cut: case VsCommands.Rename: string linkPath = this.ItemNode.GetMetadata(ProjectFileConstants.Link); if (string.IsNullOrEmpty(linkPath)) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } else { // disable these commands on linked items result = vsCommandStatus.vsCommandStatusUnsupported; return VSConstants.S_OK; } case VsCommands.ViewCode: if (this.IsNonmemberItem) result = vsCommandStatus.vsCommandStatusUnsupported; else result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; //case VsCommands.Delete: goto case VsCommands.OpenWith; case VsCommands.Open: case VsCommands.OpenWith: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else if(cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.INCLUDEINPROJECT) { // if it is a non member item node, the we support "Include In Project" command if (IsNonmemberItem) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else if((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT) { // if it is a non member item node, then we don't support "Exclude From Project" command if (IsNonmemberItem) { result = vsCommandStatus.vsCommandStatusUnsupported; return VSConstants.S_OK; } string linkPath = this.ItemNode.GetMetadata(ProjectFileConstants.Link); if (string.IsNullOrEmpty(linkPath)) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } else { result = vsCommandStatus.vsCommandStatusUnsupported; return VSConstants.S_OK; } } if((VsCommands2K)cmd == VsCommands2K.RUNCUSTOMTOOL) { if(string.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon))) { IEnumerable<string> extenderNames = this.NodeProperties.ExtenderNames() as IEnumerable<string>; if (extenderNames != null && extenderNames.Contains(SingleFileGeneratorNodeExtenderProvider.Name) && this.NodeProperties.Extender(SingleFileGeneratorNodeExtenderProvider.Name) != null) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } } } else { return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
/// <summary> /// Disable certain commands for dependent file nodes /// </summary> protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97) { switch((VsCommands)cmd) { case VsCommands.Copy: case VsCommands.Paste: case VsCommands.Cut: case VsCommands.Rename: result = vsCommandStatus.vsCommandStatusUnsupported; return VSConstants.S_OK; case VsCommands.ViewCode: case VsCommands.Open: case VsCommands.OpenWith: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else if(cmdGroup == VsMenus.guidStandardCommandSet2K) { if((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT) { result = vsCommandStatus.vsCommandStatusUnsupported; return VSConstants.S_OK; } } else { return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet97) { switch ((VsCommands)cmd) { case VsCommands.Copy: case VsCommands.Paste: case VsCommands.Cut: case VsCommands.Rename: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return(VSConstants.S_OK); case VsCommands.NewFolder: case VsCommands.AddNewItem: case VsCommands.AddExistingItem: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return(VSConstants.S_OK); } } else if (cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.INCLUDEINPROJECT) { // if it is a non member item node, the we support "Include In Project" command if (IsNonmemberItem) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; } else { result = vsCommandStatus.vsCommandStatusUnsupported; } return(VSConstants.S_OK); } else if ((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT) { // if it is a non member item node, then we don't support "Exclude From Project" command if (IsNonmemberItem) { result = vsCommandStatus.vsCommandStatusUnsupported; } else { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; } return(VSConstants.S_OK); } } else { return((int)OleConstants.OLECMDERR_E_UNKNOWNGROUP); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if (cmdGroup == VsMenus.guidStandardCommandSet97) { switch ((VsCommands)cmd) { case VsCommands.AddNewItem: case VsCommands.AddExistingItem: result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return(VSConstants.S_OK); } } else if (cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.ADDREFERENCE) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return(VSConstants.S_OK); } } else { return((int)OleConstants.OLECMDERR_E_UNKNOWNGROUP); } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet2K) { if((VsCommands2K)cmd == VsCommands2K.QUICKOBJECTSEARCH) { result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } } else { return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; } return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); }