/// <summary> /// Convert an instance of <see cref="IPackageCommandHandler"/> to an <see /// cref="OleMenuCommand"/>. Note: When using the <see /// cref="OleMenuCommand"/> with an implementation of <see /// cref="OleMenuCommandService"/>, make sure to override <see /// cref="Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget "/> and forward calls to <see /// cref="OleCommandTargetSpy"/>. /// </summary> public static OleMenuCommand ToOleMenuCommand(this IPackageCommandHandler handler) { var command = new OleMenuCommand(handler.Execute, handler.CommandId); command.BeforeQueryStatus += (sender, args) => OleCommandTargetSpy.WrapBeforeQueryStatus(command, handler); return(command); }
int IOleCommandTarget.Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { var impl = this.GetService(typeof(IMenuCommandService)) as IOleCommandTarget; return(OleCommandTargetSpy.WrapExec(this, impl, ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut)); }
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { var impl = this.GetService(typeof(IMenuCommandService)) as IOleCommandTarget; return(OleCommandTargetSpy.WrapQueryStatus(this, impl, ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }