public static int WrapQueryStatus( IOleCommandTarget receiver, IOleCommandTarget implementer, ref System.Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, System.IntPtr pCmdText) { Debug.Assert(receiver != null); var commandId = new CommandID(pguidCmdGroup, (int)prgCmds[0].cmdID); if (LogCommand(commandId)) { Logger.LogInfo("WrapQueryStatus: => recv={0}, impl={1}, parent={2}", receiver, GetImplementerString(implementer), GetParentTargetString(implementer)); } var hr = (implementer == null) ? (int)Constants.OLECMDERR_E_NOTSUPPORTED : implementer.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); if (LogCommand(commandId)) { Logger.LogInfo("WrapQueryStatus: <= recv={0}, impl={1}, parent={2}, hr={3}, cmdf={4}", receiver, GetImplementerString(implementer), GetParentTargetString(implementer), HrToString(hr), CmdFlagsToString(prgCmds)); } return hr; }
///<summary>Attempts to figure out whether the JSLS language service has been installed yet.</summary> static bool IsJSLSInstalled(IOleCommandTarget next) { Guid cmdGroup = VSConstants.VSStd2K; var cmds = new[] { new OLECMD { cmdID = (uint)VSConstants.VSStd2KCmdID.AUTOCOMPLETE } }; ErrorHandler.ThrowOnFailure(next.QueryStatus(ref cmdGroup, 1, cmds, IntPtr.Zero)); return cmds[0].cmdf == 3; }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup != _commandGroup) { return(_nextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } for (int i = 0; i < cCmds; i++) { if (_commandId == prgCmds[i].cmdID) { prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); } } return(_nextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
int IOleCommandTarget.QueryStatus(ref Guid cmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (cmdGroup == Guids.DebugEngineCmdSetGuid) { return(packageCommandHandler.Query(cCmds, prgCmds, pCmdText)); } return(packageCommandTarget.QueryStatus(ref cmdGroup, cCmds, prgCmds, pCmdText)); }
private int PreLanguageCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { var nextTarget = firstLanguageServiceCommandFilter ?? _editorServicesCommandFilter; if (pguidCmdGroup == Guids.InteractiveCommandSetId) { switch ((CommandIds)prgCmds[0].cmdID) { case CommandIds.HistoryNext: case CommandIds.HistoryPrevious: case CommandIds.SearchHistoryNext: case CommandIds.SearchHistoryPrevious: case CommandIds.SmartExecute: // TODO: Submit? prgCmds[0].cmdf = _window.CurrentLanguageBuffer != null ? CommandEnabled : CommandDisabled; prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU; return VSConstants.S_OK; case CommandIds.AbortExecution: prgCmds[0].cmdf = _window.IsRunning ? CommandEnabled : CommandDisabled; prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU; return VSConstants.S_OK; case CommandIds.Reset: prgCmds[0].cmdf = !_window.IsResetting ? CommandEnabled : CommandDisabled; prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU; return VSConstants.S_OK; default: prgCmds[0].cmdf = CommandEnabled; break; } prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU; } else if (currentBufferCommandHandler != null && pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { // undo/redo support: switch ((VSConstants.VSStd97CmdID)prgCmds[0].cmdID) { case VSConstants.VSStd97CmdID.Undo: case VSConstants.VSStd97CmdID.MultiLevelUndo: case VSConstants.VSStd97CmdID.MultiLevelUndoList: case VSConstants.VSStd97CmdID.Redo: case VSConstants.VSStd97CmdID.MultiLevelRedo: case VSConstants.VSStd97CmdID.MultiLevelRedoList: return currentBufferCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } } if (nextTarget != null) { var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); #if DUMP_COMMANDS //DumpCmd("QS", result, ref pguidCmdGroup, prgCmds[0].cmdID, prgCmds[0].cmdf); #endif return result; } return VSConstants.E_FAIL; }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { EditCommand editCommand; if (1 == cCmds && TryConvert(pguidCmdGroup, prgCmds[0].cmdID, pCmdText, out editCommand)) { VimTrace.TraceInfo("VsCommandTarget::QueryStatus {0}", editCommand); _bufferCoordinator.DiscardedKeyInput = FSharpOption <KeyInput> .None; var action = CommandStatus.PassOn; if (editCommand.IsUndo || editCommand.IsRedo) { action = CommandStatus.Enable; } else if (editCommand.HasKeyInput && _vimBuffer.CanProcess(editCommand.KeyInput)) { action = CommandStatus.Enable; if (_resharperUtil.IsInstalled) { action = QueryStatusInResharper(editCommand.KeyInput) ?? CommandStatus.Enable; } } switch (action) { case CommandStatus.Enable: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(NativeMethods.S_OK); case CommandStatus.Disable: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED; return(NativeMethods.S_OK); case CommandStatus.PassOn: return(_nextTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); } VimTrace.TraceInfo("VsCommandTarget::QueryStatus ", action); } return(_nextTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup != typeof(VSConstants.VSStd97CmdID).GUID || cCmds != 1) { return(Next.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } switch (prgCmds[0].cmdID) { case ReplaceTacticF10: case PeekTacticF9: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED; prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_ENABLED; return(VSConstants.S_OK); default: return(Next.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { // TODO: This is temporarily needed to hide the Create Appx Package menu which isn't supported yet if (pguidCmdGroup == new Guid("ac8bcc47-f5f3-4afa-8cc2-f0d697e04bb7") && prgCmds[0].cmdID == 0x0016) { prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE); return(VSConstants.S_OK); } return(_menuService.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public void SectionController_IOleCommandTargetQueryStatus() { // Arrange var testSubject = this.CreateTestSubject(); IOleCommandTarget testSubjectCommandTarget = testSubject; testSubject.CommandTargets.Clear(); var command1 = new TestCommandTarget(); var command2 = new TestCommandTarget(); var command3 = new TestCommandTarget(); testSubject.CommandTargets.Add(command1); testSubject.CommandTargets.Add(command2); testSubject.CommandTargets.Add(command3); Guid group = Guid.Empty; uint cCmds = 0; OLECMD[] prgCmds = new OLECMD[0]; IntPtr pCmdText = IntPtr.Zero; // Case 1 : no commands handling the request // Act+Verify testSubjectCommandTarget.QueryStatus(ref group, cCmds, prgCmds, pCmdText).Should().Be(SectionController.CommandNotHandled); command1.QueryStatusNumberOfCalls.Should().Be(1); command2.QueryStatusNumberOfCalls.Should().Be(1); command3.QueryStatusNumberOfCalls.Should().Be(1); // Case 2 : the last command is handling the request command3.QueryStatusReturnsResult = (int)OleConstants.OLECMDERR_E_CANCELED; // Act+Verify testSubjectCommandTarget.QueryStatus(ref group, cCmds, prgCmds, pCmdText).Should().Be((int)OleConstants.OLECMDERR_E_CANCELED); command1.QueryStatusNumberOfCalls.Should().Be(2); command2.QueryStatusNumberOfCalls.Should().Be(2); command3.QueryStatusNumberOfCalls.Should().Be(2); // Case 3 : the first command is handling the request command1.QueryStatusReturnsResult = (int)OleConstants.OLECMDERR_E_DISABLED; // Act+Verify testSubjectCommandTarget.QueryStatus(ref group, cCmds, prgCmds, pCmdText).Should().Be((int)OleConstants.OLECMDERR_E_DISABLED); command1.QueryStatusNumberOfCalls.Should().Be(3); command2.QueryStatusNumberOfCalls.Should().Be(2); command3.QueryStatusNumberOfCalls.Should().Be(2); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (VsShellUtilities.IsInAutomationFunction(_mProvider.ServiceProvider)) { return(_mNextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } if (pguidCmdGroup != VSConstants.VSStd2K || cCmds <= 0) { return(_mNextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } if (prgCmds[0].cmdID != (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET && (prgCmds[0].cmdID != (uint)VSConstants.VSStd2KCmdID.SURROUNDWITH || _textView.Selection.IsEmpty)) { return(_mNextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } prgCmds[0].cmdf = (int)Constants.MSOCMDF_ENABLED | (int)Constants.MSOCMDF_SUPPORTED; return(VSConstants.S_OK); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup != CommandGroup) return _nextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); for (int i = 0; i < cCmds; i++) { if (CommandIds.Contains(prgCmds[i].cmdID)) { if (IsEnabled()) { prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return VSConstants.S_OK; } prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED; } } return _nextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { int hr = (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED; IOleCommandTarget cmdTarget = (IOleCommandTarget)ActiveCommandTarget; if (cmdTarget != null) { hr = cmdTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText); } return(hr); }
private bool RunQueryStatus(KeyInput keyInput) { var data = ToVsInforamtion(keyInput); var guid = data.Item1; var cmds = new OLECMD[1]; cmds[0] = new OLECMD { cmdID = data.Item2 }; return (ErrorHandler.Succeeded(_target.QueryStatus(ref guid, 1, cmds, data.Item3)) && cmds[0].cmdf == (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED)); }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (1 == cCmds && TryConvert(pguidCmdGroup, prgCmds[0].cmdID, pCmdText, out EditCommand editCommand)) { var action = QueryStatus(editCommand); switch (action) { case CommandStatus.Enable: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(NativeMethods.S_OK); case CommandStatus.Disable: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED; return(NativeMethods.S_OK); case CommandStatus.PassOn: return(_nextCommandTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); } } return(_nextCommandTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (_translationAdornmentManager != null && _translationAdornmentManager.m_adorned) { if (pguidCmdGroup == typeof(VSConstants.VSStd2KCmdID).GUID) { for (int i = 0; i < cCmds; i++) { switch (prgCmds[i].cmdID) { case ((uint)VSConstants.VSStd2KCmdID.RETURN): case ((uint)VSConstants.VSStd2KCmdID.TYPECHAR): case ((uint)VSConstants.VSStd2KCmdID.CANCEL): prgCmds[i].cmdf = VSConstants.S_OK; break; } } } } /*if (pguidCmdGroup == typeof(VSConstants.VSStd2KCmdID).GUID) * { * for (int i = 0; i < cCmds; i++) * { * switch (prgCmds[i].cmdID) * { * case ((uint)VSConstants.VSStd2KCmdID.TYPECHAR): * case ((uint)VSConstants.VSStd2KCmdID.BACKSPACE): * case ((uint)VSConstants.VSStd2KCmdID.TAB): * case ((uint)VSConstants.VSStd2KCmdID.LEFT): * case ((uint)VSConstants.VSStd2KCmdID.RIGHT): * case ((uint)VSConstants.VSStd2KCmdID.UP): * case ((uint)VSConstants.VSStd2KCmdID.DOWN): * case ((uint)VSConstants.VSStd2KCmdID.END): * case ((uint)VSConstants.VSStd2KCmdID.HOME): * case ((uint)VSConstants.VSStd2KCmdID.PAGEDN): * case ((uint)VSConstants.VSStd2KCmdID.PAGEUP): * case ((uint)VSConstants.VSStd2KCmdID.PASTE): * case ((uint)VSConstants.VSStd2KCmdID.PASTEASHTML): * case ((uint)VSConstants.VSStd2KCmdID.BOL): * case ((uint)VSConstants.VSStd2KCmdID.EOL): * case ((uint)VSConstants.VSStd2KCmdID.RETURN): * case ((uint)VSConstants.VSStd2KCmdID.BACKTAB): * prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); * return VSConstants.S_OK; * } * } * }*/ return(m_nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { //if (pguidCmdGroup == VSConstants.VSStd2K) //{ // switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) // { // case VSConstants.VSStd2KCmdID.AUTOCOMPLETE: // case VSConstants.VSStd2KCmdID.COMPLETEWORD: // prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED; // return VSConstants.S_OK; // } //} return(nextCommandHandler.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { int hr = (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED; // if a core editor object has the focus defer call to it's // IOleCommandTarget.QueryStatus implementation. if (this.viewAdapter != null) { IOleCommandTarget cmdTarget = (IOleCommandTarget)viewAdapter; hr = cmdTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } return(hr); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == VSConstants.VSStd2K) { switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) { case VSConstants.VSStd2KCmdID.AUTOCOMPLETE: case VSConstants.VSStd2KCmdID.COMPLETEWORD: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED; return(VSConstants.S_OK); } } return(Next.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { for (int i = 0; i < cCmds; i++) { switch ((VSConstants.VSStd97CmdID)prgCmds[i].cmdID) { case VSConstants.VSStd97CmdID.GotoDefn: prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return VSConstants.S_OK; case VSConstants.VSStd97CmdID.FindReferences: prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return VSConstants.S_OK; } } } else if (pguidCmdGroup == VSConstants.VSStd2K) { JavaScriptOutliningTaggerProvider.OutliningTagger tagger; for (int i = 0; i < cCmds; i++) { switch ((VSConstants.VSStd2KCmdID)prgCmds[i].cmdID) { case VSConstants.VSStd2KCmdID.FORMATDOCUMENT: case VSConstants.VSStd2KCmdID.FORMATSELECTION: string path = GetFilePath(); if (path != null) { prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED); return VSConstants.S_OK; } break; case VSConstants.VSStd2KCmdID.COMMENT_BLOCK: case VSConstants.VSStd2KCmdID.COMMENTBLOCK: case VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK: case VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK: prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.OUTLN_STOP_HIDING_ALL: tagger = _textView.GetOutliningTagger(); if (tagger != null && tagger.Enabled) { prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); } return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.OUTLN_START_AUTOHIDING: tagger = _textView.GetOutliningTagger(); if (tagger != null && !tagger.Enabled) { prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); } return VSConstants.S_OK; } } } return _next.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { EditCommand editCommand; if (1 == cCmds && TryConvert(pguidCmdGroup, prgCmds[0].cmdID, pCmdText, out editCommand)) { var action = CommandAction.PassOn; if (editCommand.IsUndo || editCommand.IsRedo) { action = CommandAction.Enable; } else if (editCommand.HasKeyInput && _buffer.CanProcess(editCommand.KeyInput)) { action = CommandAction.Enable; if (_externalEditManager.IsResharperLoaded) { action = QueryStatusInResharper(editCommand.KeyInput) ?? CommandAction.Enable; } } switch (action) { case CommandAction.Enable: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(NativeMethods.S_OK); case CommandAction.Disable: prgCmds[0].cmdf = 0; return(NativeMethods.S_OK); case CommandAction.PassOn: return(_nextTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); } } return(_nextTarget.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
/// <summary> /// Override to forward to editor or handle accordingly if supported by this tool window. /// </summary> int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { // examine buttons within our toolbar if (pguidCmdGroup == GuidList.guidNuGetCmdSet) { bool isEnabled = IsToolbarEnabled; if (isEnabled) { bool isStopButton = (prgCmds[0].cmdID == 0x0600); // 0x0600 is the Command ID of the Stop button, defined in .vsct // when command is executing: enable stop button and disable the rest // when command is not executing: disable the stop button and enable the rest isEnabled = !isStopButton ^ WpfConsole.Dispatcher.IsExecutingCommand; } if (isEnabled) { prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED); } else { prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED); } return(VSConstants.S_OK); } int hr = OleCommandFilter.OLECMDERR_E_NOTSUPPORTED; if (VsTextView != null) { IOleCommandTarget cmdTarget = (IOleCommandTarget)VsTextView; hr = cmdTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } if (hr == OleCommandFilter.OLECMDERR_E_NOTSUPPORTED || hr == OleCommandFilter.OLECMDERR_E_UNKNOWNGROUP) { IOleCommandTarget target = GetService(typeof(IOleCommandTarget)) as IOleCommandTarget; if (target != null) { hr = target.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } } return(hr); }
private int PreEditorCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == Guids.InteractiveCommandSetId) { switch ((CommandIds)prgCmds[0].cmdID) { case CommandIds.BreakLine: prgCmds[0].cmdf = _window.CurrentLanguageBuffer != null ? CommandEnabled : CommandDisabled; prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU; return(VSConstants.S_OK); } } return(_editorCommandFilter.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == VSConstants.VSStd2K) { switch ((VSCommand)prgCmds[0].cmdID) { case VSCommand.FORMATDOCUMENT: case VSCommand.FORMATSELECTION: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED; return VSConstants.S_OK; } } return nextCommandHandler.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText); }
/// <summary> /// Actually run the QueryStatus command and report the result /// </summary> private bool RunQueryStatusCore(OleCommandData oleCommandData) { var hr = _commandTarget.QueryStatus(oleCommandData, out OLECMD command); if (!ErrorHandler.Succeeded(hr)) { return(false); } // TODO: Visual Studio has slightly different behavior here IIRC. I believe it will // only cache if it's at least supported. Need to check on that var result = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(result == (result & command.cmdf)); }
public virtual int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == CommandGroupId) { for (int i = 0; i < cCmds; i++) { if (CommandIds.Contains(prgCmds[i].cmdID)) { prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED | (uint)OLECMDF.OLECMDF_ENABLED; return(VSConstants.S_OK); } } } return(nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
static bool IsJSLSInstalled(IOleCommandTarget next) { Guid cmdGroup = VSConstants.VSStd2K; var cmds = new[] { new OLECMD { cmdID = (uint)VSConstants.VSStd2KCmdID.AUTOCOMPLETE } }; try { next.QueryStatus(ref cmdGroup, 1, cmds, IntPtr.Zero); return cmds[0].cmdf == 3; } catch { return false; } }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == menuGroup) { for (int i = 0; i < cCmds; i++) { if (prgCmds[i].cmdID == cmdID && queryEvent()) { prgCmds[i].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); } } } return(nextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { for (int i = 0; i < cCmds; i++) { var status = QueryStatusImpl(pguidCmdGroup, prgCmds[i]); if (status == VSConstants.E_FAIL) { return(m_nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } else { prgCmds[i].cmdf = (uint)status; } } return(VSConstants.S_OK); }
/// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.IOleCommandTarget.QueryStatus"]/*' /> /// <internalonly/> /// <devdoc> /// This is called by Visual Studio when it needs the status of our menu commands. There /// is no need to override this method. If you need access to menu commands use /// IMenuCommandService. /// </devdoc> int IOleCommandTarget.QueryStatus(ref Guid guidGroup, uint nCmdId, OLECMD[] oleCmd, IntPtr oleText) { // Always redirect through GetService for this. That way outside users can replace // it. // IOleCommandTarget cmdTarget = GetService(typeof(IOleCommandTarget)) as IOleCommandTarget; if (cmdTarget != null) { return(cmdTarget.QueryStatus(ref guidGroup, nCmdId, oleCmd, oleText)); } else { return(NativeMethods.OLECMDERR_E_NOTSUPPORTED); } }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == commandGroup) { if (prgCmds != null && cCmds == 1) { if (prgCmds[0].cmdID == commandId) { prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED | (uint)OLECMDF.OLECMDF_ENABLED; return(VSConstants.S_OK); } } } return(next?.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText) ?? 0); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == VSStd2K) { switch ((VSStd2KCmdID)prgCmds[0].cmdID) { case VSStd2KCmdID.AUTOCOMPLETE: case VSStd2KCmdID.SHOWMEMBERLIST: case VSStd2KCmdID.COMPLETEWORD: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(S_OK); } } return(_nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == VSConstants.VSStd2K) { switch ((VSCommand)prgCmds[0].cmdID) { case VSCommand.AUTOCOMPLETE: case VSCommand.COMPLETEWORD: case VSCommand.SHOWMEMBERLIST: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED; return(VSConstants.S_OK); } } return(nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { ThreadHelper.ThrowIfNotOnUIThread(); if (pguidCmdGroup == VSConstants.VSStd2K) { switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) { case VSConstants.VSStd2KCmdID.AUTOCOMPLETE: case VSConstants.VSStd2KCmdID.COMPLETEWORD: prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED; return(VSConstants.S_OK); } } return(_nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }