private void paintGrid1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var point = new GameOfLife.Core.Models.Point { X = paintGrid1.CurrentCell.RowIndex, Y = paintGrid1.CurrentCell.ColumnIndex }; var state = _gameOfLife.ToggleState(point); _animation.repaint(); }
public void SetCellColor(GameOfLife.Core.Models.Point point, CellState state) { if (state == CellState.ALIVE || state == CellState.SPAWNING) { _grid.Rows[point.X].Cells[point.Y].Style.BackColor = Color.Red; } else { _grid.Rows[point.X].Cells[point.Y].Style.BackColor = Color.White; } }
public void repaint() { for (int x = 0; x < _gameOfLife.GridSize.X; x++) { for (int y = 0; y < _gameOfLife.GridSize.Y; y++) { var point = new GameOfLife.Core.Models.Point { X = x, Y = y }; var state = _gameOfLife.GetState(point); SetCellColor(point, state); } } }