ARKBreedingStats.MyColorPicker.SetColors C# (CSharp) Метод

SetColors() публичный Метод

public SetColors ( int creatureColors, int regionId, string name, List naturalIds = null ) : void
creatureColors int
regionId int
name string
naturalIds List
Результат void
        public void SetColors(int[] creatureColors, int regionId, string name, List<int> naturalIds = null)
        {
            label1.Text = name;
            this.regionId = regionId;
            this.colorIds = new int[42];
            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 % 6) * 45, 25 + (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);
                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;
        }

Usage Example

Пример #1
0
 private void chooseColor(int region, Button sender)
 {
     if (c != null && !cp.isShown)
     {
         cp.SetColors(c.colors, region, "Region " + region.ToString());
         if (cp.ShowDialog() == DialogResult.OK)
         {
             // color was chosen
             setColorButton(sender, Utils.creatureColor(c.colors[region]));
             pictureBox1.Image = CreatureColored.getColoredCreature(c.colors, (uniqueSpecies ? c.species : ""), new bool[] { true, true, true, true, true, true });
         }
     }
 }
All Usage Examples Of ARKBreedingStats.MyColorPicker::SetColors