protected override void AssignImages() { TableLayoutControlCollection controls = tableLayoutPanel1.Controls; int offset = 0; int columnCount = textLabels.Length * 2 - 1; foreach (Label control in controls.OfType <Label>()) { if (offset == 0) { control.Image = (Progress > 0) ? images[1] : images[0]; } else if (offset == columnCount) { control.Image = (Progress >= offset) ? images[7] : images[6]; } else { control.Image = (offset % 2 == 1) ? ((Progress > offset) ? images[3] : images[2]) : ((Progress > offset) ? images[5] : images[4]); } offset++; if (offset > columnCount) { break; } } }
private void Iskoci(TableLayoutControlCollection Controls, Bitmap slika) { Random rGen = new Random(); Button[] btns = Controls.OfType <Button>().ToArray(); foreach (Button btn in btns) { btn.Image = null; } //U Bjelicinoj f-ji je (0,10) pa moze dat i 10 i doce do greske jer je 9 dugmadi. btns[rGen.Next(0, 9)].Image = slika; }