private bool HandleMenuCommand(FormsDesignerViewContent formDesigner, IComponent activeComponent, Keys keyPressed) { System.Type serviceType = typeof(WindowsFormsDesignerOptionService).Assembly.GetType("System.Windows.Forms.Design.ToolStripKeyboardHandlingService"); object service = formDesigner.Host.GetService(serviceType); if (service == null) { //LoggingService.Debug("no ToolStripKeyboardHandlingService found"); return(false); } if (activeComponent is ToolStripItem) { if (keyPressed == Keys.Up) { serviceType.InvokeMember("ProcessUpDown", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, service, new object[] { false }); return(true); } if (keyPressed == Keys.Down) { serviceType.InvokeMember("ProcessUpDown", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, service, new object[] { true }); return(true); } } return((bool)serviceType.InvokeMember("TemplateNodeActive", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance, null, service, null)); }
public bool PreFilterMessage(ref Message m) { if (m.Msg == 0x100) { if (WorkbenchSingleton.Workbench.ActiveContent == null) { return(false); } if (!WorkbenchSingleton.Workbench.IsActiveWindow) { return(false); } FormsDesignerViewContent activeContent = WorkbenchSingleton.Workbench.ActiveContent as FormsDesignerViewContent; if (activeContent == null) { return(false); } Keys keyPressed = ((Keys)m.WParam.ToInt32()) | Control.ModifierKeys; if ((keyPressed == Keys.Escape) && activeContent.IsTabOrderMode) { activeContent.HideTabOrder(); return(true); } CommandWrapper wrapper = (CommandWrapper)this.keyTable[keyPressed]; if (wrapper != null) { if ((wrapper.CommandID == StandardCommands.Delete) && !activeContent.EnableDelete) { return(false); } //LoggingService.Debug("Run menu command: " + wrapper.CommandID); Control activeControl = WorkbenchSingleton.ActiveControl; IMenuCommandService service = (IMenuCommandService)activeContent.Host.GetService(typeof(IMenuCommandService)); ISelectionService service2 = (ISelectionService)activeContent.Host.GetService(typeof(ISelectionService)); ICollection selectedComponents = service2.GetSelectedComponents(); if (selectedComponents.Count == 1) { foreach (IComponent component in selectedComponents) { if (this.HandleMenuCommand(activeContent, component, keyPressed)) { return(false); } } } service.GlobalInvoke(wrapper.CommandID); if (wrapper.RestoreSelection) { service2.SetSelectedComponents(selectedComponents); } return(true); } } return(false); }