public void RemoveToolboxItem(System.Drawing.Design.ToolboxItem item, string category) { ToolBoxGroupPanel group = null; if (category != null && group_panels.TryGetValue(category, out group)) { int toRemove = -1; for (int i = 0; i < group.Items.Count; i++) { ToolBoxListItem listItem = (ToolBoxListItem)group.Items[i]; if (listItem.ToolBoxItem == item) { listItem.Click -= new EventHandler(item_Click); toRemove = i; break; } } if (toRemove != -1) { group.Items.RemoveAt(toRemove); } if (group.Items.Count == 0) { Controls.Remove(group); } } }
protected override void OnControlRemoved(ControlEventArgs e) { base.OnControlRemoved(e); if (e.Control is ToolBoxGroupPanel) { ToolBoxGroupPanel gp = (ToolBoxGroupPanel)e.Control; group_panels.Remove(gp.Text); } base.PerformLayout(); }
protected override void OnControlAdded(ControlEventArgs e) { base.OnControlAdded(e); if (e.Control is ToolBoxGroupPanel) { ToolBoxGroupPanel gp = (ToolBoxGroupPanel)e.Control; gp.Visible = true; group_panels.Add(gp.Text, gp); } base.PerformLayout(); }
public System.Drawing.Design.ToolboxItemCollection GetToolboxItems(string category) { List <ToolboxItem> items = new List <ToolboxItem> (); ToolBoxGroupPanel p = group_panels[category]; foreach (ToolBoxListItem i in p.Items) { items.Add(i.ToolBoxItem); } return(new ToolboxItemCollection(items.ToArray())); }
public void AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category) { ToolBoxListItem item = new ToolBoxListItem(toolboxItem); if (!group_panels.ContainsKey(category)) { ToolBoxGroupPanel gp = new ToolBoxGroupPanel(); gp.Text = category; Controls.Add(gp); } item.Click += new EventHandler(item_Click); group_panels[category].Items.Add(item); }