diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs index 154811945d..c764765da6 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs @@ -181,21 +181,15 @@ namespace WorkflowDesigner public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { - string[] methodNames = null; + ICollection compatibleMethods = null;; if (context != null) { IEventBindingService eventBindingService = context.GetService(typeof(IEventBindingService)) as IEventBindingService; - - ICollection compatibleMethods = eventBindingService.GetCompatibleMethods(eventPropertyDescriptor.eventDescriptor); - methodNames = new string[compatibleMethods.Count]; - int i =0; - foreach (string methodName in compatibleMethods) { - methodNames[i++] = methodName; - } - + if (eventBindingService != null) + compatibleMethods = eventBindingService.GetCompatibleMethods(eventPropertyDescriptor.eventDescriptor); } - return new StandardValuesCollection(methodNames); + return new StandardValuesCollection(compatibleMethods); } diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs index 8003456550..ff786ba939 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs @@ -34,18 +34,22 @@ namespace WorkflowDesigner LoggingService.Debug("ShowContextMenu"); - if (menuID == WorkflowMenuCommands.DesignerActionsMenu) - { + if (menuID == WorkflowMenuCommands.DesignerActionsMenu) { ContextMenuStrip contextMenu = new ContextMenuStrip(); + Guid DesignerActionGuid = new Guid("3bd4a275-fccd-49f0-b617-765ce63b4340"); + ICollection collection = this.GetCommandList(menuID.Guid); - foreach (System.ComponentModel.Design.MenuCommand menuCommand in collection) - { + foreach (System.ComponentModel.Design.MenuCommand menuCommand in collection) { // Only interested in the errors. - if (menuCommand.CommandID.ID == 8342) - { + if (menuCommand.CommandID.ID == 8342) { + foreach (object o in menuCommand.Properties.Keys) + LoggingService.DebugFormatted("{0} {1}", o.GetType(), o.ToString()); + foreach (object o in menuCommand.Properties.Values) + LoggingService.DebugFormatted("{0} {1}", o.GetType(), o.ToString()); ToolStripMenuItem menuItem = new ToolStripMenuItem(menuCommand.Properties["Text"].ToString()); - menuItem.Click += ClickHandler; + menuItem.Click += new EventHandler(ClickHandler); + menuItem.Tag = menuCommand.Properties[DesignerActionGuid]; contextMenu.Items.Add(menuItem); } } @@ -58,8 +62,42 @@ namespace WorkflowDesigner void ClickHandler(object sender, EventArgs e) { - // TODO: Move focus to the property in the property pad. - throw new NotImplementedException(); + DesignerAction designerAction = ((ToolStripMenuItem)sender).Tag as DesignerAction; + if (designerAction == null) + return; + + designerAction.Invoke(); // Will change the selectedObject in the designer + + if (!string.IsNullOrEmpty( designerAction.PropertyName)) + { + // No easy way to search for a grid item so + // find the root item in the grid, and search for items for the property. + GridItem item = PropertyPad.Grid.SelectedGridItem; + while (item.Parent != null) { + item = item.Parent; + } + GridItem item2 = FindGridItem(item, designerAction.PropertyName); + + if (item2 != null) { + PropertyPad.Grid.SelectedGridItem = item2; + PropertyPad.Grid.Focus(); + } + } + + } + + static GridItem FindGridItem(GridItem gridItem, string name) + { + foreach (GridItem item in gridItem.GridItems){ + if (item.Label == name) + return item; + + GridItem item2 = FindGridItem(item, name); + if (item2 != null) + return item2; + } + + return null; } }