public bool ProcessKey(string controlType, ICommandTarget ct, Keys keyData) { Dictionary <int, CommandID> bindings; if (this.KeyBindings.TryGetValue(controlType, out bindings)) { if (ct != null) { if (KeyBindings.TryGetValue(ct.GetType().FullName, out bindings)) { CommandID cmdID; if (bindings.TryGetValue((int)keyData, out cmdID)) { return(ct.Execute(cmdID)); } } return(false); } } if (KeyBindings.TryGetValue("", out bindings)) { CommandID cmdID; if (bindings.TryGetValue((int)keyData, out cmdID)) { if (this.target.Execute(cmdID)) { return(true); } } } return(false); }
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 = _commandTarget.HandlesCommand(commandId); } catch (Exception e) { Logger.LogException(e, "Error in {0}.HandlesCommand.", _commandTarget.GetType().FullName); } if (!isSupported) { return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); } bool isEnabled = _commandTarget.IsEnabled(commandId); prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED); if (isEnabled) { prgCmds[0].cmdf |= (uint)(OLECMDF.OLECMDF_ENABLED); } return(VSConstants.S_OK); }
private void Invoke(string method) { try { target.GetType().InvokeMember(method, BindingFlags.InvokeMethod, null, target, null); } catch (Exception e) { Console.WriteLine("Exception " + e.StackTrace); throw new XEditNetCommandException("Failed to invoke command: " + method, e); } }