public override void PostprocessMouseUp(MouseButtonEventArgs e) { uint cmdId; switch (e.ChangedButton) { case MouseButton.XButton1: cmdId = (uint)VSConstants.VSStd97CmdID.ShellNavBackward; break; case MouseButton.XButton2: cmdId = (uint)VSConstants.VSStd97CmdID.ShellNavForward; break; default: return; } try { IVsUIShell shell = (IVsUIShell)ServiceProvider.GetService(typeof(SVsUIShell)); Guid cmdGroup = VSConstants.GUID_VSStandardCommandSet97; OLECMDEXECOPT cmdExecOpt = OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER; object obj = null; ErrorHandler.ThrowOnFailure(shell.PostExecCommand(cmdGroup, cmdId, (uint)cmdExecOpt, ref obj)); e.Handled = true; } catch (COMException) { } }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(VSConstants.VSStd2KCmdID).GUID) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.RETURN: return(HandleCompletion('\n')); case VSConstants.VSStd2KCmdID.TAB: return(HandleCompletion('\t')); case VSConstants.VSStd2KCmdID.TYPECHAR: char typedChar = Convert.ToChar(Marshal.GetObjectForNativeVariant(pvaIn)); switch (typedChar) { case '/': case '>': case ' ': return(HandleCompletion(typedChar)); default: return(false); } default: break; } } return(false); }
private int InnerExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (_next != null) { return(_next.Exec(ref commandGroup, commandId, (uint)executionOptions, pvaIn, pvaOut)); } return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); }
/// <summary> /// This is overridden to handle command execution for the node /// </summary> /// <param name="cmdGroup">Unique identifier of the command group</param> /// <param name="cmd">The command to be executed.</param> /// <param name="nCmdexecopt">Values describe how the object should /// execute the command.</param> /// <param name="pvaIn">Pointer to a <c>VARIANTARG</c> structure /// containing input arguments. Can be NULL</param> /// <param name="pvaOut"><c>VARIANTARG</c> structure to receive command /// output. It can be null.</param> /// <returns>If the method succeeds, it returns <c>S_OK</c>. If it /// fails, it returns an error code.</returns> protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && (int)cmd == PkgCmdIDList.AddDocSource) { this.AddDocumentationSources(); return(VSConstants.S_OK); } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { if ((VsCommands2K)cmd == VsCommands2K.QUICKOBJECTSEARCH) { return(this.ShowObjectBrowser()); } } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)cmd) { case VsCommands2K.ADDREFERENCE: return(this.ProjectManager.AddProjectReference()); case VsCommands2K.ADDWEBREFERENCE: return(this.ProjectManager.AddWebReference()); } } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
/// <summary> /// This method provides the primary implementation for <see cref="IOleCommandTarget.Exec"/> in all cases where /// <see cref="OLECMDEXECOPT.OLECMDEXECOPT_SHOWHELP"/> was not requested. /// </summary> /// <param name="guidCmdGroup">The command group.</param> /// <param name="nCmdID">The command ID.</param> /// <param name="nCmdexecopt">The OLE command execution options.</param> /// <param name="pvaIn">An optional pointer to the command argument(s). The semantics of this parameter are /// specific to a particular command.</param> /// <param name="pvaOut">An optional pointer to the command result(s). The semantics of this parameter are /// specific to a particular command.</param> /// <returns> /// <para>This method returns <see cref="VSConstants.S_OK"/> on success.</para> /// <para>-or-</para> /// <para><see cref="OleConstants.OLECMDERR_E_NOTSUPPORTED"/> if the command is not handled by this command /// filter, and no other command filters are available to process the request.</para> /// </returns> private int ExecCommand(ref Guid guidCmdGroup, uint nCmdID, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { int rc = VSConstants.S_OK; if (!HandlePreExec(ref guidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut)) { // Pass it along the chain. rc = this.InnerExec(ref guidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); if (!ErrorHandler.Succeeded(rc)) { return(rc); } HandlePostExec(ref guidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); } return(rc); }
/// <summary> /// This is overridden to handle command execution for the node /// </summary> /// <param name="cmdGroup">Unique identifier of the command group</param> /// <param name="cmd">The command to be executed.</param> /// <param name="nCmdexecopt">Values describe how the object should /// execute the command.</param> /// <param name="pvaIn">Pointer to a <c>VARIANTARG</c> structure /// containing input arguments. Can be NULL</param> /// <param name="pvaOut"><c>VARIANTARG</c> structure to receive command /// output. It can be null.</param> /// <returns>If the method succeeds, it returns <c>S_OK</c>. If it /// fails, it returns an error code.</returns> protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { // Open the Project Properties window when double-clicked or Properties is selected if ((cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.PropSheetOrProperties) || (cmdGroup == VsMenus.guidVSUISet && (WindowCommandIds)cmd == WindowCommandIds.UIHWCMDID_DoubleClick)) { IntPtr ip = (IntPtr)(-1); IVsWindowFrame frame = null; ((IVsProject2)this.ProjectManager).ReopenItem(VSConstants.VSITEMID_ROOT, VSConstants.GUID_ProjectDesignerEditor, null, Guid.Empty, ip, out frame); return(VSConstants.S_OK); } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
/// <inheritdoc/> /// <remarks> /// This method handles execution of the <see cref="VsCommands2K.COMMENT_BLOCK"/> /// and <see cref="VsCommands2K.UNCOMMENT_BLOCK"/> commands by calling /// <see cref="CommentSelection"/> and <see cref="UncommentSelection"/> (respectively) /// and returning <see langword="true"/>. /// </remarks> protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(VsCommands2K).GUID) { VsCommands2K cmd = (VsCommands2K)commandId; switch (cmd) { case VsCommands2K.COMMENT_BLOCK: this.CommentSelection(); return(true); case VsCommands2K.UNCOMMENT_BLOCK: this.UncommentSelection(); return(true); } } return(base.HandlePreExec(ref commandGroup, commandId, executionOptions, pvaIn, pvaOut)); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)cmd) { case VsCommands2K.INCLUDEINPROJECT: return(((IProjectSourceNode)this).IncludeInProject()); case VsCommands2K.EXCLUDEFROMPROJECT: return(((IProjectSourceNode)this).ExcludeFromProject()); case ProjectFileConstants.CommandExploreFolderInWindows: ProjectNode.ExploreFolderInWindows(GetMKDocument()); return(VSConstants.S_OK); } } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
/// <inheritdoc /> protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet) { switch (cmd) { case PkgCmdIDList.OpenInStandaloneGUI: this.OpenInStandaloneGui(); return(VSConstants.S_OK); case PkgCmdIDList.ViewBuildLog: this.OpenBuildLogToolWindow(true); return(VSConstants.S_OK); default: break; } } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(VSConstants.VSStd2KCmdID).GUID) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.RETURN: return HandleReturn(); case VSConstants.VSStd2KCmdID.TAB: return HandleTab(); case VSConstants.VSStd2KCmdID.TYPECHAR: char typedChar = Convert.ToChar(Marshal.GetObjectForNativeVariant(pvaIn)); return HandleTypeChar(typedChar); default: break; } } return false; }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(VSConstants.VSStd2KCmdID).GUID) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.OPENURL: if (pvaIn != IntPtr.Zero) { int line = (int)Marshal.GetObjectForNativeVariant(pvaIn); int column = (int)Marshal.GetObjectForNativeVariant(new IntPtr(pvaIn.ToInt32() + 16)); return TryOpenUrlAtPoint(line, column); } return TryOpenUrlAtCaret(); default: break; } } return base.HandlePreExec(ref commandGroup, commandId, executionOptions, pvaIn, pvaOut); }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(VSConstants.VSStd2KCmdID).GUID) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.OPENURL: if (pvaIn != IntPtr.Zero) { int line = (int)Marshal.GetObjectForNativeVariant(pvaIn); int column = (int)Marshal.GetObjectForNativeVariant(new IntPtr(pvaIn.ToInt32() + 16)); return(TryOpenUrlAtPoint(line, column)); } return(TryOpenUrlAtCaret()); default: break; } } return(base.HandlePreExec(ref commandGroup, commandId, executionOptions, pvaIn, pvaOut)); }
private int ExecCommand(ref Guid guidCmdGroup, uint nCmdID, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { int rc = VSConstants.S_OK; if (!HandlePreExec(ref guidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut) && _next != null) { // Pass it along the chain. rc = this.InnerExec(ref guidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); if (!ErrorHandler.Succeeded(rc)) return rc; HandlePostExec(ref guidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); } return rc; }
private int InnerExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (_next != null) return _next.Exec(ref commandGroup, commandId, (uint)executionOptions, pvaIn, pvaOut); return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; }
/// <summary> /// This method supports the implementation for commands which are directly implemented by this command filter. /// </summary> /// <remarks> /// The default implementation returns <see langword="false"/> for all commands. /// </remarks> /// <param name="commandGroup">The command group.</param> /// <param name="commandId">The command ID.</param> /// <param name="executionOptions">The OLE command execution options.</param> /// <param name="pvaIn">An optional pointer to the command argument(s). The semantics of this parameter are specific to a particular command.</param> /// <param name="pvaOut">An optional pointer to the command result(s). The semantics of this parameter are specific to a particular command.</param> /// <returns> /// <see langword="true"/> if this command filter handled the command; otherwise, <see langword="false"/> /// to call the next <see cref="IOleCommandTarget"/> in the chain. /// </returns> protected virtual bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { return false; }
protected virtual int QueryParameterList(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; }
public virtual bool PreprocessCommand(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { _isProcessingCommand = true; if (!IsCompletionActive) return false; if (commandGroup == VsMenus.guidStandardCommandSet97) { if (commandId == (uint)VsCommands.Delete) return false; } else if (commandGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)commandId) { case VsCommands2K.WORDPREV: case VsCommands2K.WORDPREV_EXT: case VsCommands2K.WORDNEXT: case VsCommands2K.WORDNEXT_EXT: case VsCommands2K.CANCEL: case VsCommands2K.BACKSPACE: case VsCommands2K.DELETE: case VsCommands2K.LEFT: case VsCommands2K.LEFT_EXT: case VsCommands2K.RIGHT: case VsCommands2K.RIGHT_EXT: case VsCommands2K.UP: case VsCommands2K.UP_EXT: case VsCommands2K.DOWN: case VsCommands2K.DOWN_EXT: case VsCommands2K.BOL: case VsCommands2K.BOL_EXT: case VsCommands2K.FIRSTCHAR: case VsCommands2K.FIRSTCHAR_EXT: case VsCommands2K.EOL: case VsCommands2K.EOL_EXT: case VsCommands2K.PAGEUP: case VsCommands2K.PAGEUP_EXT: case VsCommands2K.PAGEDN: case VsCommands2K.PAGEDN_EXT: case VsCommands2K.TOPLINE: case VsCommands2K.TOPLINE_EXT: case VsCommands2K.BOTTOMLINE: case VsCommands2K.BOTTOMLINE_EXT: case VsCommands2K.LEFT_EXT_COL: case VsCommands2K.RIGHT_EXT_COL: case IntellisenseCommandFilter.ECMD_INCREASEFILTER: case VsCommands2K.ECMD_DECREASEFILTER: case VsCommands2K.ECMD_LEFTCLICK: return false; case (VsCommands2K)95: case VsCommands2K.BACKTAB: case VsCommands2K.HOME: case VsCommands2K.HOME_EXT: case VsCommands2K.END: case VsCommands2K.END_EXT: case VsCommands2K.LASTCHAR: case VsCommands2K.LASTCHAR_EXT: break; case VsCommands2K.TYPECHAR: char c = Convert.ToChar(Marshal.GetObjectForNativeVariant(pvaIn)); if (IsCommitChar(c)) { if (CompletionSession.SelectedCompletionSet.SelectionStatus.Completion == null) { DismissCompletion(); } else { CompletionInfo.CommitChar = c; return CommitCompletion(); } } return false; case VsCommands2K.RETURN: CompletionInfo.CommitChar = '\n'; return CommitCompletion(); case VsCommands2K.TAB: case VsCommands2K.OPENLINEABOVE: var selectionStatus = CompletionSession.SelectedCompletionSet.SelectionStatus; CompletionSession.SelectedCompletionSet.SelectionStatus = new CompletionSelectionStatus(selectionStatus.Completion, true, selectionStatus.IsUnique); CompletionInfo.CommitChar = (VsCommands2K)commandId == VsCommands2K.TAB ? (char?)'\t' : null; return CommitCompletion(); case VsCommands2K.ToggleConsumeFirstCompletionMode: return false; } } return false; }
/// <summary> /// This method supports specialized handling in response to commands that are successfully handled by another command target. /// </summary> /// <remarks> /// This method is only called if <see cref="HandlePreExec"/> for the current instance returned <see langword="false"/> and /// the next command target in the chain returned a value indicating the command execution succeeded. /// /// <para> /// The default implementation is empty. /// </para> /// </remarks> /// <param name="commandGroup">The command group.</param> /// <param name="commandId">The command ID.</param> /// <param name="executionOptions">The OLE command execution options.</param> /// <param name="pvaIn">An optional pointer to the command argument(s). The semantics of this parameter are specific to a particular command.</param> /// <param name="pvaOut">An optional pointer to the command result(s). The semantics of this parameter are specific to a particular command.</param> protected virtual void HandlePostExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { }
/// <summary> /// This is overridden to handle command execution for the node /// </summary> /// <param name="cmdGroup">Unique identifier of the command group</param> /// <param name="cmd">The command to be executed.</param> /// <param name="nCmdexecopt">Values describe how the object should /// execute the command.</param> /// <param name="pvaIn">Pointer to a <c>VARIANTARG</c> structure /// containing input arguments. Can be NULL</param> /// <param name="pvaOut"><c>VARIANTARG</c> structure to receive command /// output. It can be null.</param> /// <returns>If the method succeeds, it returns <c>S_OK</c>. If it /// fails, it returns an error code.</returns> protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && (int)cmd == PkgCmdIDList.AddDocSource) { this.AddDocumentationSources(); return VSConstants.S_OK; } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(GitDiffMarginCommand).GUID) { EditorDiffMarginViewModel viewModel = null; EditorDiffViewModel diffViewModel = null; if (TryGetMarginViewModel(out viewModel)) { diffViewModel = viewModel.DiffViewModels.OfType <EditorDiffViewModel>().FirstOrDefault(i => i.ShowPopup); } switch ((GitDiffMarginCommand)commandId) { case GitDiffMarginCommand.ShowPopup: { diffViewModel = GetCurrentDiffViewModel(viewModel); if (diffViewModel != null) { diffViewModel.ShowPopup = true; return(true); } return(false); } case GitDiffMarginCommand.PreviousChange: case GitDiffMarginCommand.NextChange: { if (viewModel == null) { return(false); } RelayCommand <DiffViewModel> command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.NextChange ? viewModel.NextChangeCommand : viewModel.PreviousChangeCommand; // First look for a diff already showing a popup if (diffViewModel != null) { command.Execute(diffViewModel); return(true); } diffViewModel = GetDiffViewModelToMoveTo(commandId, viewModel); if (diffViewModel == null) { return(false); } viewModel.MoveToChange(diffViewModel, 0); return(true); } case GitDiffMarginCommand.RollbackChange: case GitDiffMarginCommand.CopyOldText: { if (diffViewModel == null) { return(false); } ICommand command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.RollbackChange ? diffViewModel.RollbackCommand : diffViewModel.CopyOldTextCommand; command.Execute(diffViewModel); return(true); } case GitDiffMarginCommand.ShowDiff: { if (diffViewModel == null) { return(false); } ICommand command = diffViewModel.ShowDifferenceCommand; command.Execute(diffViewModel); return(true); } case GitDiffMarginCommand.GitDiffToolbar: case GitDiffMarginCommand.GitDiffToolbarGroup: // these aren't actually commands, but IDs of the command bars and groups break; default: break; } } return(false); }
public override void Invoke(object inArg, System.IntPtr outArg, Microsoft.VisualStudio.OLE.Interop.OLECMDEXECOPT options) { this.Invoke(); }
bool ITvlIntellisenseController.PreprocessCommand(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { throw new NotImplementedException(); }
/// <summary> /// This is overridden to handle command execution for the node /// </summary> /// <param name="cmdGroup">Unique identifier of the command group</param> /// <param name="cmd">The command to be executed.</param> /// <param name="nCmdexecopt">Values describe how the object should /// execute the command.</param> /// <param name="pvaIn">Pointer to a <c>VARIANTARG</c> structure /// containing input arguments. Can be NULL</param> /// <param name="pvaOut"><c>VARIANTARG</c> structure to receive command /// output. It can be null.</param> /// <returns>If the method succeeds, it returns <c>S_OK</c>. If it /// fails, it returns an error code.</returns> protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { // Open the Project Properties window when double-clicked or Properties is selected if((cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.PropSheetOrProperties) || (cmdGroup == VsMenus.guidVSUISet && (WindowCommandIds)cmd == WindowCommandIds.UIHWCMDID_DoubleClick)) { IntPtr ip = (IntPtr)(-1); IVsWindowFrame frame = null; ((IVsProject2)this.ProjectManager).ReopenItem(VSConstants.VSITEMID_ROOT, VSConstants.GUID_ProjectDesignerEditor, null, Guid.Empty, ip, out frame); return VSConstants.S_OK; } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(this.ProjectManager == null || this.ProjectManager.IsClosed) { return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; } // Exec on special filenode commands if(cmdGroup == VsMenus.guidStandardCommandSet97) { IVsWindowFrame windowFrame = null; switch((VsCommands)cmd) { case VsCommands.ViewCode: return ((FileDocumentManager)this.GetDocumentManager()).Open(false, false, VSConstants.LOGVIEWID_Code, out windowFrame, WindowFrameShowAction.Show); case VsCommands.ViewForm: return ((FileDocumentManager)this.GetDocumentManager()).Open(false, false, VSConstants.LOGVIEWID_Designer, out windowFrame, WindowFrameShowAction.Show); case VsCommands.Open: return ((FileDocumentManager)this.GetDocumentManager()).Open(false, false, WindowFrameShowAction.Show); case VsCommands.OpenWith: return ((FileDocumentManager)this.GetDocumentManager()).Open(false, true, VSConstants.LOGVIEWID_UserChooseView, out windowFrame, WindowFrameShowAction.Show); } } // Exec on special filenode commands if(cmdGroup == VsMenus.guidStandardCommandSet2K) { switch((VsCommands2K)cmd) { case VsCommands2K.INCLUDEINPROJECT: return ((IProjectSourceNode)this).IncludeInProject(); case VsCommands2K.EXCLUDEFROMPROJECT: return ((IProjectSourceNode)this).ExcludeFromProject(); case VsCommands2K.RUNCUSTOMTOOL: { try { this.RunGenerator(); return VSConstants.S_OK; } catch(Exception e) { Trace.WriteLine("Running Custom Tool failed : " + e.Message); throw; } } } } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(GitDiffMarginCommand).GUID) { EditorDiffMarginViewModel viewModel = null; EditorDiffViewModel diffViewModel = null; if (TryGetMarginViewModel(out viewModel)) diffViewModel = viewModel.DiffViewModels.OfType<EditorDiffViewModel>().FirstOrDefault(i => i.ShowPopup); switch ((GitDiffMarginCommand)commandId) { case GitDiffMarginCommand.PreviousChange: case GitDiffMarginCommand.NextChange: { if (viewModel == null) return false; RelayCommand<DiffViewModel> command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.NextChange ? viewModel.NextChangeCommand : viewModel.PreviousChangeCommand; // First look for a diff already showing a popup if (diffViewModel != null) { command.Execute(diffViewModel); return true; } diffViewModel = GetDiffViewModelToMoveTo(commandId, viewModel); if (diffViewModel == null) return false; viewModel.MoveToChange(diffViewModel, 0); return true; } case GitDiffMarginCommand.RollbackChange: case GitDiffMarginCommand.CopyOldText: { if (diffViewModel == null) return false; //ICommand command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.RollbackChange ? diffViewModel.RollbackCommand : diffViewModel.CopyOldTextCommand; //command.Execute(diffViewModel); return true; } case GitDiffMarginCommand.ShowDiff: { if (diffViewModel == null) return false; ICommand command = diffViewModel.ShowDifferenceCommand; command.Execute(diffViewModel); return true; } case GitDiffMarginCommand.ToggleCompareToIndex: if (diffViewModel != null) { // The margin will not update if the pop-up is visible diffViewModel.ShowPopup = false; } ToggleCompareToIndex(); return true; case GitDiffMarginCommand.CompareToIndex: if (diffViewModel != null) { // The margin will not update if the pop-up is visible diffViewModel.ShowPopup = false; } CompareToIndex(); return true; case GitDiffMarginCommand.CompareToHead: if (diffViewModel != null) { // The margin will not update if the pop-up is visible diffViewModel.ShowPopup = false; } CompareToHead(); return true; case GitDiffMarginCommand.GitDiffToolbar: case GitDiffMarginCommand.GitDiffToolbarGroup: // these aren't actually commands, but IDs of the command bars and groups break; default: break; } } return false; }
/// <inheritdoc/> /// <remarks> /// This method handles execution of the <see cref="VsCommands2K.COMMENT_BLOCK"/> /// and <see cref="VsCommands2K.UNCOMMENT_BLOCK"/> commands by calling /// <see cref="CommentSelection"/> and <see cref="UncommentSelection"/> (respectively) /// and returning <see langword="true"/>. /// </remarks> protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == typeof(VsCommands2K).GUID) { VsCommands2K cmd = (VsCommands2K)commandId; switch (cmd) { case VsCommands2K.COMMENT_BLOCK: this.CommentSelection(); return true; case VsCommands2K.UNCOMMENT_BLOCK: this.UncommentSelection(); return true; } } return base.HandlePreExec(ref commandGroup, commandId, executionOptions, pvaIn, pvaOut); }
public virtual bool PreprocessCommand(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { _isProcessingCommand = true; if (!IsCompletionActive) { return(false); } if (commandGroup == VsMenus.guidStandardCommandSet97) { if (commandId == (uint)VsCommands.Delete) { return(false); } } else if (commandGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)commandId) { case VsCommands2K.WORDPREV: case VsCommands2K.WORDPREV_EXT: case VsCommands2K.WORDNEXT: case VsCommands2K.WORDNEXT_EXT: case VsCommands2K.CANCEL: case VsCommands2K.BACKSPACE: case VsCommands2K.DELETE: case VsCommands2K.LEFT: case VsCommands2K.LEFT_EXT: case VsCommands2K.RIGHT: case VsCommands2K.RIGHT_EXT: case VsCommands2K.UP: case VsCommands2K.UP_EXT: case VsCommands2K.DOWN: case VsCommands2K.DOWN_EXT: case VsCommands2K.BOL: case VsCommands2K.BOL_EXT: case VsCommands2K.FIRSTCHAR: case VsCommands2K.FIRSTCHAR_EXT: case VsCommands2K.EOL: case VsCommands2K.EOL_EXT: case VsCommands2K.PAGEUP: case VsCommands2K.PAGEUP_EXT: case VsCommands2K.PAGEDN: case VsCommands2K.PAGEDN_EXT: case VsCommands2K.TOPLINE: case VsCommands2K.TOPLINE_EXT: case VsCommands2K.BOTTOMLINE: case VsCommands2K.BOTTOMLINE_EXT: case VsCommands2K.LEFT_EXT_COL: case VsCommands2K.RIGHT_EXT_COL: case IntellisenseCommandFilter.ECMD_INCREASEFILTER: case VsCommands2K.ECMD_DECREASEFILTER: case VsCommands2K.ECMD_LEFTCLICK: return(false); case (VsCommands2K)95: case VsCommands2K.BACKTAB: case VsCommands2K.HOME: case VsCommands2K.HOME_EXT: case VsCommands2K.END: case VsCommands2K.END_EXT: case VsCommands2K.LASTCHAR: case VsCommands2K.LASTCHAR_EXT: break; case VsCommands2K.TYPECHAR: char c = Convert.ToChar(Marshal.GetObjectForNativeVariant(pvaIn)); if (IsCommitChar(c)) { if (CompletionSession.SelectedCompletionSet.SelectionStatus.Completion == null) { DismissCompletion(); } else { CompletionInfo.CommitChar = c; return(CommitCompletion()); } } return(false); case VsCommands2K.RETURN: CompletionInfo.CommitChar = '\n'; return(CommitCompletion()); case VsCommands2K.TAB: case VsCommands2K.OPENLINEABOVE: var selectionStatus = CompletionSession.SelectedCompletionSet.SelectionStatus; CompletionSession.SelectedCompletionSet.SelectionStatus = new CompletionSelectionStatus(selectionStatus.Completion, true, selectionStatus.IsUnique); CompletionInfo.CommitChar = (VsCommands2K)commandId == VsCommands2K.TAB ? (char?)'\t' : null; return(CommitCompletion()); case VsCommands2K.ToggleConsumeFirstCompletionMode: return(false); } } return(false); }
/// <summary> /// The expected behavior of this method is not clear. /// </summary> /// <remarks> /// <para>The default implementation returns <see cref="OleConstants.OLECMDERR_E_NOTSUPPORTED"/> for all /// commands.</para> /// </remarks> /// <param name="commandGroup">The command group.</param> /// <param name="commandId">The command ID.</param> /// <param name="executionOptions">The OLE command execution options.</param> /// <param name="pvaIn">An optional pointer to the command argument(s). The semantics of this parameter are /// specific to a particular command.</param> /// <param name="pvaOut">An optional pointer to the command result(s). The semantics of this parameter are /// specific to a particular command.</param> /// <returns>The expected behavior of this method is not clear.</returns> protected virtual int ShowHelp(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); }
/// <summary> /// This method supports the implementation for commands which are directly implemented by this command filter. /// </summary> /// <remarks> /// The default implementation returns <see langword="false"/> for all commands. /// </remarks> /// <param name="commandGroup">The command group.</param> /// <param name="commandId">The command ID.</param> /// <param name="executionOptions">The OLE command execution options.</param> /// <param name="pvaIn">An optional pointer to the command argument(s). The semantics of this parameter are specific to a particular command.</param> /// <param name="pvaOut">An optional pointer to the command result(s). The semantics of this parameter are specific to a particular command.</param> /// <returns> /// <see langword="true"/> if this command filter handled the command; otherwise, <see langword="false"/> /// to call the next <see cref="IOleCommandTarget"/> in the chain. /// </returns> protected virtual bool HandlePreExec(ref Guid commandGroup, uint commandId, OLECMDEXECOPT executionOptions, IntPtr pvaIn, IntPtr pvaOut) { return(false); }
/// <inheritdoc /> protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet) switch(cmd) { case PkgCmdIDList.OpenInStandaloneGUI: this.OpenInStandaloneGui(); return VSConstants.S_OK; case PkgCmdIDList.ViewBuildLog: this.OpenBuildLogToolWindow(true); return VSConstants.S_OK; default: break; } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(cmdGroup == VsMenus.guidStandardCommandSet2K) { switch((VsCommands2K)cmd) { case VsCommands2K.ADDREFERENCE: return this.ProjectManager.AddProjectReference(); case VsCommands2K.ADDWEBREFERENCE: return this.ProjectManager.AddWebReference(); } } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == VsMenus.guidStandardCommandSet2K) { switch ((VsCommands2K)cmd) { case VsCommands2K.INCLUDEINPROJECT: return ((IProjectSourceNode)this).IncludeInProject(); case VsCommands2K.EXCLUDEFROMPROJECT: return ((IProjectSourceNode)this).ExcludeFromProject(); case ProjectFileConstants.CommandExploreFolderInWindows: ProjectNode.ExploreFolderInWindows(GetMKDocument()); return VSConstants.S_OK; } } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }
protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(cmdGroup == VsMenus.guidStandardCommandSet2K) { if((VsCommands2K)cmd == VsCommands2K.QUICKOBJECTSEARCH) { return this.ShowObjectBrowser(); } } return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); }