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); } } }
private void ClearSelected(ToolBoxListItem item) { foreach (ToolBoxGroupPanel p in group_panels.Values) { foreach (ToolBoxListItem i in p.Items) { if (i != item) { i.Selected = false; } } } }
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); }
private void ItemPanel_ControlAdded(object sender, ControlEventArgs e) { // Sort incoming items ToolBoxListItem new_tbi = (ToolBoxListItem)e.Control; foreach (Control c in ItemPanel.Controls) { ToolBoxListItem tbi = c as ToolBoxListItem; if (tbi == null) { continue; } if (string.Compare(new_tbi.Text, tbi.Text) > 0) { ItemPanel.Controls.SetChildIndex(new_tbi, ItemPanel.Controls.GetChildIndex(tbi)); break; } } e.Control.Dock = DockStyle.Top; PerformLayout(); }
private void ClearSelected(ToolBoxListItem item) { foreach (ToolBoxGroupPanel p in group_panels.Values) foreach (ToolBoxListItem i in p.Items) if (i != item) i.Selected = false; }
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); }