private void AddColor(NamedColor nc, ChangeTileForm type, NamedColor ncolor, NamedColor[ , ] indexTable, int w, int h) { int cnt = 0; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { if (indexTable[i, j].color == nc.color) { cnt++; } } } string[] ss = { "", nc.name, cnt.ToString() }; ListViewItem lvi = new ListViewItem(ss); lvi.UseItemStyleForSubItems = false; lvi.BackColor = nc.color; lvi.Tag = nc; if (type == ChangeTileForm.ChangeTile) { if (nc.color == ncolor.color) { lvi.Selected = true; } } listView.Items.Add(lvi); }
public TileForm(Point p, ChangeTileForm type, NamedColor ncolor, MosaicForm mosaicForm) { InitializeComponent(); this.mosaicForm = mosaicForm; this.type = type; this.ncolor = ncolor; /* if ( type == ChangeTileForm.ChangeTile ) * { * this.Text = "Заменить цвет"; * this.buttonChange.Text = "Заменить"; * } * else * { * this.Text = "Используемые цвета"; * this.buttonChange.Text = "Выделить"; * } */ if (mosaicForm.colorSelected) { btnChange.FlatStyle = FlatStyle.Flat; } foreach (NamedColor nc in mosaicForm.palette.colors) { AddColor(nc, type, ncolor, mosaicForm.indexTable, mosaicForm.w, mosaicForm.h); } }