private void SelectPalette(ColorPalettePanel panel) { for (int i = 0; i < this.listPanel.Controls.Count; i++) { var p = this.listPanel.Controls[i] as Panel; var c = p.Controls[0] as ColorPalettePanel; if (c == panel) { c.Selected = true; } else { c.Selected = false; } c.Refresh(); } }
private void RemoveColorPalettePanel(ColorPalettePanel target) { var index = -1; for (int i = 0; i < this.listPanel.Controls.Count; i++) { var p = this.listPanel.Controls[i] as Panel; var c = p.Controls[0] as ColorPalettePanel; if (c == target) { c.Click -= Palette_Click; index = i; } } if (index >= 0) { this.listPanel.Controls.RemoveAt(index); } }
private ColorPalettePanel AddColorPalettePanel(List <Color> colors, bool canRemove) { var item = new Panel(); item.Dock = DockStyle.Top; item.Height = 68; item.Padding = new Padding(10); var palette = new ColorPalettePanel(); palette.Dock = DockStyle.Fill; palette.Colors = colors.ToArray(); palette.Click += Palette_Click; palette.CanRemove = canRemove; item.Controls.Add(palette); item.Controls.SetChildIndex(palette, 0); this.listPanel.Controls.Add(item); return(palette); }