private void PaintGroup(Graphics graphics, ToolboxGroup group, SolidBrush backgroundBrush, ref int offset) { group.Top = offset; offset += 19; SolidBrush groupBrush = new SolidBrush(groupColor); Rectangle groupRect = new Rectangle(1, group.Top, this.Width - 1, 18); graphics.FillRectangle(groupBrush, groupRect); groupBrush.Dispose(); Pen backgroundPen = new Pen(backgroundBrush); int lineLocation = group.Top + 16; graphics.DrawLine(backgroundPen, 1, lineLocation, this.Width - 1, lineLocation); backgroundPen.Dispose(); graphics.DrawString(group.Caption, this.Font, Brushes.Black, new RectangleF(20, group.Top + 2, this.Width - 30, group.Top + 13)); if (group.Expanded) { graphics.DrawImage(Properties.Resources.minus, new Point(6, group.Top + 4)); foreach (ToolboxItem item in group.Items) { PaintItem(graphics, item, backgroundBrush, ref offset); } } else { graphics.DrawImage(Properties.Resources.plus, new Point(6, group.Top + 4)); foreach (ToolboxItem item in group.Items) { item.Top = -1; } } }
private void GroupMouseDown(ToolboxGroup group) { if (group == null) { return; } group.Expanded = !group.Expanded; if (group.Expanded) { this.AutoScrollMinSize = new Size(this.Width - 30, this.AutoScrollMinSize.Height + group.ItemHeight); } else { this.AutoScrollMinSize = new Size(this.Width - 30, this.AutoScrollMinSize.Height - group.ItemHeight); } Invalidate(this.ClientRectangle); }