// ToolPicked is called when the user double-clicks on a toolbox item. // The document designer should create a component for the specified tool. // Only tools that are enabled in the toolbox will be passed to this method. // // I create the component in the parent container of the primary selection. // If not available I create it in the rootcomponent (this essentially :-) ) // protected virtual void ToolPicked(ToolboxItem tool) { ISelectionService selectionSvc = GetService(typeof(ISelectionService)) as ISelectionService; IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (selectionSvc != null && host != null) { IDesigner designer = host.GetDesigner((IComponent)selectionSvc.PrimarySelection); if (designer is ParentControlDesigner) { ParentControlDesigner.InvokeCreateTool((ParentControlDesigner)designer, tool); } else { this.CreateTool(tool); } } else { this.CreateTool(tool); } IToolboxService tbServ = this.GetService(typeof(IToolboxService)) as IToolboxService; tbServ.SelectedToolboxItemUsed(); }
protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) { if (tool != null) { System.Type c = tool.GetType(this.designerHost); if (!typeof(ToolStrip).IsAssignableFrom(c)) { ToolStripContainer parent = this.panel.Parent as ToolStripContainer; if (parent != null) { ToolStripContentPanel contentPanel = parent.ContentPanel; if (contentPanel != null) { PanelDesigner toInvoke = this.designerHost.GetDesigner(contentPanel) as PanelDesigner; if (toInvoke != null) { ParentControlDesigner.InvokeCreateTool(toInvoke, tool); } } } } else { base.CreateToolCore(tool, x, y, width, height, hasLocation, hasSize); } } return(null); }
protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) { if (this.Selected == null) { this.Selected = this.splitterPanel1; } SplitterPanelDesigner toInvoke = (SplitterPanelDesigner)this.designerHost.GetDesigner(this.Selected); ParentControlDesigner.InvokeCreateTool(toInvoke, tool); return(null); }
protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) { TabControl control = (TabControl)this.Control; if (control.SelectedTab == null) { throw new ArgumentException(System.Design.SR.GetString("TabControlInvalidTabPageType", new object[] { tool.DisplayName })); } IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { TabPageDesigner toInvoke = (TabPageDesigner)service.GetDesigner(control.SelectedTab); ParentControlDesigner.InvokeCreateTool(toInvoke, tool); } return(null); }
protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) { if (tool != null) { System.Type c = tool.GetType(this.designerHost); if (typeof(StatusStrip).IsAssignableFrom(c)) { ParentControlDesigner.InvokeCreateTool(this.GetDesigner(this.bottomToolStripPanel), tool); } else if (typeof(ToolStrip).IsAssignableFrom(c)) { ParentControlDesigner.InvokeCreateTool(this.GetDesigner(this.topToolStripPanel), tool); } else { ParentControlDesigner.InvokeCreateTool(this.GetDesigner(this.contentToolStripPanel), tool); } } return(null); }