private void OnListBoxDoubleClick(object sener, EventArgs e) { IToolboxUser docDes = null; SelfHostToolboxItem selectedItem = listBox.SelectedItem as SelfHostToolboxItem; if (selectedItem == null) { return; } this.currentSelection = selectedItem.ComponentType; IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); //des.ActiveDesigner; if (host != null && this.currentSelection != null) { IDesigner designer = host.GetDesigner(host.RootComponent); if (designer is IToolboxUser) { docDes = (IToolboxUser)designer; } if (docDes != null) { ToolboxItem c = ToolboxService.GetToolboxItem(this.currentSelection); Debug.Assert(c != null, "Class " + this.currentSelection.FullName + " does not exist"); if (c != null && docDes.GetToolSupported(c)) { try { docDes.ToolPicked(c); } catch (Exception ex) { IUIService uis = (IUIService)provider.GetService(typeof(IUIService)); if (uis != null) { uis.ShowError(ex); } else { MessageBox.Show("Error: " + ex.ToString()); } } } } else { object o = Activator.CreateInstance(this.currentSelection); SequentialWorkflowActivity service = host.RootComponent as SequentialWorkflowActivity; service.Activities.Add(o as Activity); host.RootComponent.Site.Container.Add(o as IComponent); } } }
public ToolboxItem GetSelectedToolboxItem(System.ComponentModel.Design.IDesignerHost host) { IToolboxUser toolboxUser = (IToolboxUser)host.GetDesigner(host.RootComponent); if (toolboxUser.GetToolSupported(selectedItem)) { return(selectedItem); } else { return(null); } }
public ToolboxItemCollection GetToolboxItems(System.ComponentModel.Design.IDesignerHost host) { ArrayList tools = new ArrayList(); IToolboxUser toolboxUser = (IToolboxUser)host.GetDesigner(host.RootComponent); foreach (ArrayList arr in categories.Values) { foreach (ToolboxItem tool in arr) { if (toolboxUser.GetToolSupported(tool)) { tools.Add(tool); } } } return(new ToolboxItemCollection((ToolboxItem[])tools.ToArray(typeof(ToolboxItem)))); }
protected override bool EvaluateCustomFilter(IToolboxUser user) { return(user.GetToolSupported(item)); }
protected override bool EvaluateCustomFilter(IToolboxUser user) { return user.GetToolSupported (item); }