Esempio n. 1
0
        private void CreateField()
        {
            field = new PictureBox()
            {
                Width = 240, Height = 240, Location = new Point(100, 150), BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage
            };
            background.Controls.Add(field);
            pictureField = new MyPictureBox[3, 3];

            int X = 0;
            int Y = 0;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    pictureField[i, j]          = new MyPictureBox(i, j);
                    pictureField[i, j].Size     = new Size(70, 70);
                    pictureField[i, j].Location = new Point(X, Y);
                    pictureField[i, j].Click   += MyPictureBox_Click;
                    pictureField[i, j].SizeMode = PictureBoxSizeMode.StretchImage;
                    field.Controls.Add(pictureField[i, j]);
                    X += 85;
                }
                X  = 0;
                Y += 85;
            }
        }
Esempio n. 2
0
        private async void ManDrawAsync(object obj, Turn first)
        {
            MyPictureBox clickedPic = obj as MyPictureBox;

            if (first == Turn.Human)
            {
                for (int i = 0; i < 12; i++)
                {
                    clickedPic.Image = imageCross[i];
                    await Task.Delay(50);
                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    clickedPic.Image = imageCircle[i];
                    await Task.Delay(50);
                }
            }
        }
Esempio n. 3
0
        private async void CompDrawAsync(object obj, Turn first)
        {
            MyPictureBox compClicked = obj as MyPictureBox;

            await Task.Delay(1000);

            if (first == Turn.Human)
            {
                for (int i = 0; i < 12; i++)
                {
                    Invoke(new Action(() => compClicked.Image = imageCircle[i]));
                    await Task.Delay(50);
                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    Invoke(new Action(() => compClicked.Image = imageCross[i]));
                    await Task.Delay(50);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Клик по полю
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MyPictureBox_Click(object sender, EventArgs e)
        {
            MyPictureBox btn = sender as MyPictureBox;

            ClickEvent(btn.X, btn.Y);
        }