private void player_option_clicked(object sender, EventArgs e) { PieceButton btn = (PieceButton)sender; if (btn.playerID == turn && !pieceFlags[btn.playerID, btn.pieceID]) { pieceBeingPlaced = true; currentPiece = btn; } }
public Form1() { InitializeComponent(); for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { Button b = new GridButton(i, j); this.Controls.Add(b); b.SetBounds( (i * (buttonSize + padding)) + gridOffsetX, (j * (buttonSize + padding)) + gridOffsetY, buttonSize, buttonSize); b.BackColor = restColor; b.Click += new EventHandler(this.grid_clicked); b.MouseMove += new MouseEventHandler(this.grid_hover); b.MouseLeave += new EventHandler(this.grid_hover_end); grid[i, j] = b; } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) { PieceButton b = new PieceButton(j, i); this.Controls.Add(b); pieces[i, j] = b; b.SetBounds( (pieceOffsetX + (i * pieceButtonSeparation)), (j * (pieceButtonSize + pieceButtonPadding)) + pieceOffsetY, pieceButtonSize, pieceButtonSize); b.Click += new EventHandler(this.player_option_clicked); } } this.score1 = new TextBox(); this.Controls.Add(score1); score1.SetBounds(400, 100, 50, 50); score1.Text = this.score[0].ToString(); this.score2 = new TextBox(); this.Controls.Add(score2); score2.SetBounds(450, 100, 50, 50); score2.Text = this.score[1].ToString(); }