public void SetColors(int[] creatureColors, int regionId, string name, List <int> naturalIds = null) { label1.Text = name; this.regionId = regionId; this.colorIds = new int[57]; for (int c = 0; c < colorIds.Length; c++) { colorIds[c] = c; } this.creatureColors = creatureColors; this.naturalIds = naturalIds; SuspendLayout(); // clear unused panels if (panels.Count - colorIds.Length > 0) { List <Panel> rm = panels.Skip(colorIds.Length).ToList(); foreach (Panel p in rm) { p.Dispose(); } panels.RemoveRange(colorIds.Length, panels.Count - colorIds.Length); } for (int c = 0; c < colorIds.Length; c++) { if (panels.Count <= c) { Panel p = new Panel(); p.Width = 40; p.Height = 20; p.Location = new Point(5 + (c % 8) * 45, 25 + (c / 8) * 25); p.Click += new System.EventHandler(this.ColorChoosen); panel1.Controls.Add(p); panels.Add(p); } panels[c].BackColor = Utils.creatureColor(colorIds[c]); panels[c].BorderStyle = (creatureColors[regionId] == colorIds[c] ? BorderStyle.Fixed3D : BorderStyle.None); panels[c].Visible = (!checkBoxOnlyNatural.Checked || naturalIds == null || naturalIds.Count == 0 || naturalIds.IndexOf(c) >= 0); tt.SetToolTip(panels[c], c.ToString() + ": " + Utils.creatureColorName(colorIds[c])); } ResumeLayout(); isShown = true; }
public void SetColors(int[] creatureColors, int regionId) { this.regionId = regionId; this.colorIds = new int[42]; for (int c = 0; c < colorIds.Length; c++) { colorIds[c] = c; } this.creatureColors = creatureColors; SuspendLayout(); // clear unused panels if (panels.Count - colorIds.Length > 0) { List <Panel> rm = panels.Skip(colorIds.Length).ToList(); foreach (Panel p in rm) { p.Dispose(); } panels.RemoveRange(colorIds.Length, panels.Count - colorIds.Length); } for (int c = 0; c < colorIds.Length; c++) { if (panels.Count <= c) { Panel p = new Panel(); p.Width = 40; p.Height = 20; p.Location = new Point(5 + (c % 6) * 45, 5 + (c / 6) * 25); p.Click += new System.EventHandler(this.ColorChoosen); panel1.Controls.Add(p); panels.Add(p); } panels[c].BackColor = Utils.creatureColor(colorIds[c]); panels[c].BorderStyle = (creatureColors[regionId] == colorIds[c] ? BorderStyle.Fixed3D : BorderStyle.None); tt.SetToolTip(panels[c], c.ToString() + ": " + Utils.creatureColorName(colorIds[c])); } ResumeLayout(); isShown = true; }