private void openButton_Click(object sender, EventArgs e) { exit = true; try { openFileDialog1.ShowDialog(); if (openFileDialog1.FileName != "") { string path = openFileDialog1.FileName; StartPosition startPosition = new StartPosition(board, path); board = startPosition.OpenPositionFromFile(); BoardGenerator.DrawBoard(board, this.mainPanel); saveButton.Enabled = true; } generationButton.Enabled = true; } catch { MessageBox.Show("Invalid File! Choose correct one"); } }
private void DoAutomaticWork(object state) { while (!exit) { Generation generation = new Generation(board); board = generation.GenerateNextGeneration(); Thread.Sleep(350); BoardGenerator.Board_Update(); } }
private void generationButton_Click(object sender, EventArgs e) { Generation generation = new Generation(board); board = generation.GenerateNextGeneration(); if (!AutomaticChBox.Checked) { BoardGenerator.Board_Update(); } else { exit = false; ThreadPool.QueueUserWorkItem(DoAutomaticWork); generationButton.Enabled = false; } }
private void boardButton_Click(object sender, EventArgs e) { exit = true; if (minRb.Checked == true) { board = new Board(10, 10); } else if (midRb.Checked == true) { board = new Board(10, 15); } else { board = new Board(15, 15); } BoardGenerator.DrawBoard(board, this.mainPanel); saveButton.Enabled = true; generationButton.Enabled = true; }