private void newTextEx() { //choiceBtn1.BackColor = choiceBtn2.BackColor = choiceBtn3.BackColor = choiceBtn4.BackColor = Color.LightGray; nextBtn.Hide(); hourPic.Hide(); BtnchoicesPanel.Hide(); labelPanel.Show(); imgChoicesPanel.Show(); PictureBox[] btn = { choice1Pbox, choice2Pbox, choice3Pbox, choice4Pbox }; foreach (PictureBox b in btn) { b.Click -= wrong_click; b.Click -= b_click; b.Enabled = true; } soundPicBox.Click -= sound_click; int x = r.Next(0, 12), k, j; hourLabel.Text = s[x].Replace('-', ':').Substring(0, 5); //btn[l].Click -= b_click; // soundPicBox.Tag = (@"../../../media/") + s[x].Substring(0, 5).Trim() + ".wav"; soundPicBox.Tag = s[x].Substring(0, 5).Trim(); soundPicBox.Click += sound_click; l = r.Next(0, 4); btn[l].ImageLocation = (@"../../../media/") + s[x].Trim(); btn[l].Click += b_click; int[] rand = new int[3]; do { for (j = 0; j < 3; j++) { do { k = r.Next(0, 12); } while (k == x); rand[j] = k; } } while (rand[0] == rand[1] || rand[1] == rand[2] || rand[0] == rand[2]); j = 0; k = 0; while (j < 4) { if (j == l) { j++; } else { btn[j].ImageLocation = (@"../../../media/") + s[rand[k]].Trim(); btn[j].Click += wrong_click; j++; k++; } } y = r.Next(2); }
private void newImgEx() { nextBtn.Hide(); //choiceBtn1.BackColor = choiceBtn2.BackColor = choiceBtn3.BackColor = choiceBtn4.BackColor = Color.LightGray; labelPanel.Hide(); imgChoicesPanel.Hide(); hourPic.Show(); BtnchoicesPanel.Show(); Button[] btn = { choiceBtn1, choiceBtn2, choiceBtn3, choiceBtn4 }; PictureBox[] soundPicbox = { soundPicBox1, soundPicBox2, soundPicBox3, soundPicBox4 }; foreach (Button b in btn) { b.Click -= wrong_click; b.Click -= b_click; b.Enabled = true; b.BackColor = Color.LightBlue; } foreach (PictureBox pbox in soundPicbox) { pbox.Click -= sound_click; } int x = r.Next(0, 12), k, j; hourPic.ImageLocation = (@"../../../media/") + s[x].Trim(); //btn[i].Click -= b_click; i = r.Next(0, 4); btn[i].Text = s[x].Substring(0, 5).Replace('-', ':'); btn[i].Click += b_click; trueBtn = btn[i]; //soundPicbox[i].Tag = (@"../../../media/") + s[x].Substring(0, 5).Trim() + ".wav"; soundPicbox[i].Tag = s[x].Substring(0, 5).Trim(); soundPicbox[i].Click += sound_click; int[] rand = new int[3]; do { for (j = 0; j < 3; j++) { do { k = r.Next(0, 12); } while (k == x); rand[j] = k; } } while (rand[0] == rand[1] || rand[1] == rand[2] || rand[0] == rand[2]); j = 0; k = 0; while (j < 4) { if (j == i) { j++; } else { btn[j].Text = s[rand[k]].Substring(0, 5).Replace('-', ':'); btn[j].Click += wrong_click; //soundPicbox[j].Tag = (@"../../../media/") + s[rand[k]].Substring(0, 5).Trim() + ".wav"; soundPicbox[j].Tag = s[rand[k]].Substring(0, 5).Trim(); soundPicbox[j].Click += sound_click; j++; k++; } } y = r.Next(2); }