private void Checker(object sender, EventArgs e)//+6 { if (isAllow) { MyGlass temp = sender as MyGlass;//+7 if (temp.IsHasBall && temp.Image == temp.WithBallImg && go1 == false && go2 == false && go3 == false) { Counter++; //+8 } isAllow = false; } }
public MainForm() { InitializeComponent(); glass1 = new MyGlass(1); glass2 = new MyGlass(2); glass3 = new MyGlass(3); // добавила текст glass1.Size = new Size(150, 180); glass2.Size = new Size(150, 180); glass3.Size = new Size(150, 180); glass1.SizeMode = PictureBoxSizeMode.StretchImage; glass2.SizeMode = PictureBoxSizeMode.StretchImage; glass3.SizeMode = PictureBoxSizeMode.StretchImage; glass1.Location = new Point(90, 50); glass2.Location = new Point(190, 50); glass3.Location = new Point(290, 50); glass1.BackColor = Color.Transparent; glass2.BackColor = Color.Transparent; glass3.BackColor = Color.Transparent; Random rnd = new Random(); // изменила название переменной int num = rnd.Next(1, 4); if (glass1.Id == num) { glass1.IsHasBall = true; } if (glass2.Id == num) { glass2.IsHasBall = true; } if (glass3.Id == num) { glass3.IsHasBall = true; } glass1.OpenGlass(); glass2.OpenGlass(); glass3.OpenGlass(); Controls.Add(glass1); Controls.Add(glass2); Controls.Add(glass3); glass1.Click += Checker; //+3 glass2.Click += Checker; //+4 glass3.Click += Checker; //+5 }