コード例 #1
0
            public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
            {
                var commandId = new CommandID(pguidCmdGroup, (int)nCmdID);

                bool isSupported = _owner._commandTarget.HandlesCommand(commandId);

                if (!isSupported)
                {
                    if (_owner.NextCommandTarget == null)
                    {
                        return((int)Constants.OLECMDERR_E_NOTSUPPORTED);
                    }
                    else
                    {
                        return(OleCommandTargetSpy.WrapExec(_owner, _owner.NextCommandTarget, ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
                    }
                }

                try {
                    _owner._commandTarget.Execute(commandId);
                    return(VSConstants.S_OK);
                }
                catch (Exception e) {
                    Logger.LogError(e, "Error executing editor command.");
                    return(Marshal.GetHRForException(e));
                }
            }
コード例 #2
0
            public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
            {
                var commandId = new CommandID(pguidCmdGroup, (int)prgCmds[0].cmdID);

                bool isSupported = false;

                try {
                    isSupported = _owner._commandTarget.HandlesCommand(commandId);
                }
                catch (Exception e) {
                    Logger.LogError(e, "Error in {0}.HandlesCommand.", _owner._commandTarget.GetType().FullName);
                }
                if (!isSupported)
                {
                    if (_owner.NextCommandTarget == null)
                    {
                        return((int)Constants.OLECMDERR_E_NOTSUPPORTED);
                    }
                    else
                    {
                        return(OleCommandTargetSpy.WrapQueryStatus(_owner, _owner.NextCommandTarget, ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
                    }
                }

                bool isEnabled = _owner._commandTarget.IsEnabled(commandId);

                prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED);
                if (isEnabled)
                {
                    prgCmds[0].cmdf |= (uint)(OLECMDF.OLECMDF_ENABLED);
                }
                return(VSConstants.S_OK);
            }
コード例 #3
0
 public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
 {
     return(OleCommandTargetSpy.WrapExec(this, _impl, ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
 }
コード例 #4
0
 public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
 {
     return(OleCommandTargetSpy.WrapQueryStatus(this, _impl, ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
 }