private void InitilzeGameOfLife(int rows, int columns) { for (var i = 0; i < rows; i++) { GameOfLifeGrid.RowDefinitions.Add(new RowDefinition()); } for (var i = 0; i < columns; i++) { GameOfLifeGrid.ColumnDefinitions.Add(new ColumnDefinition()); } GolGrid = Core.Grid.Initialize(rows, columns); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { GolGrid.GetCell(i, j).IsAlive = i * j % 3 == 0; var ellipse = new Ellipse { DataContext = GolGrid.GetCell(i, j), Style = Resources["lifeStyle"] as Style }; Grid.SetColumn(ellipse, j); Grid.SetRow(ellipse, i); GameOfLifeGrid.Children.Add(ellipse); } } }
void Timer_Elapsed(object sender, ElapsedEventArgs e) { GolGrid.AdvanceToNextGeneration(); }