private void grid_hover(object sender, EventArgs e)
        {
            GridButton btn = (GridButton)sender;

            if (pieceBeingPlaced && is_possible_piece(currentPiece.pieceID, btn.x, btn.y))
            {
                btn.BackColor = hoverColor;
                this.grid[btn.x + pieceLegs(currentPiece.pieceID)[0], btn.y].BackColor = hoverColor;
                this.grid[btn.x, btn.y + pieceLegs(currentPiece.pieceID)[1]].BackColor = hoverColor;
            }
        }
 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();
 }
        private void grid_clicked(object sender, EventArgs e)
        {
            GridButton btn = (GridButton)sender;

            if (pieceBeingPlaced && is_possible_piece(currentPiece.pieceID, btn.x, btn.y))
            {
                btn.BackColor = filledColor;
                this.grid[btn.x + pieceLegs(currentPiece.pieceID)[0], btn.y].BackColor = filledColor;
                this.grid[btn.x, btn.y + pieceLegs(currentPiece.pieceID)[1]].BackColor = filledColor;
                this.gridFlags[btn.x, btn.y] = true;
                this.gridFlags[btn.x + pieceLegs(currentPiece.pieceID)[0], btn.y] = true;
                this.gridFlags[btn.x, btn.y + pieceLegs(currentPiece.pieceID)[1]] = true;
                pieceBeingPlaced = false;
                this.pieceFlags[currentPiece.playerID, currentPiece.pieceID] = true;
                currentPiece.BackColor = hoverColor;
                reset_pieces(currentPiece.playerID);
                update_score();
                this.turn = (this.turn * -1) + 1;
                reset_board();
            }
        }