private void MakeMove_Click(object sender, EventArgs e) { singleButton = (GameButton)sender; _gameBoard.MakeMove(singleButton.squareCoord); RefreshButtons(); //check for win }
private void FormatTableLayout() { minX = _gameBoard.BoardState.Select(s => s.Key.XCoordinate).Min(); maxX = _gameBoard.BoardState.Select(s => s.Key.XCoordinate).Max(); minY = _gameBoard.BoardState.Select(s => s.Key.YCoordinate).Min(); maxY = _gameBoard.BoardState.Select(s => s.Key.YCoordinate).Max(); xRowCount = Math.Abs(minX - maxX) + 1; yColCount = Math.Abs(minY - maxY) + 1; gameTable.ColumnStyles.Clear(); gameTable.RowStyles.Clear(); gameTable.ColumnCount = yColCount; gameTable.RowCount = xRowCount; for (int count = 0; count < yColCount; count++) { gameTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, yColCount / 100f)); } for (int count = 0; count < xRowCount; count++) { gameTable.RowStyles.Add(new RowStyle(SizeType.Percent, xRowCount / 100f)); } gameButtons = new List <GameButton>(); foreach (var coord in _gameBoard.BoardState) { singleButton = new GameButton() { Dock = DockStyle.Fill, Margin = new Padding(0), FlatStyle = FlatStyle.Flat, squareCoord = coord.Key }; singleButton.Click += new System.EventHandler(this.MakeMove_Click); gameButtons.Add(singleButton); gameTable.Controls.Add( singleButton, coord.Key.YCoordinate, coord.Key.XCoordinate); } }