Exemple #1
0
        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");
            }
        }
Exemple #2
0
 private void DoAutomaticWork(object state)
 {
     while (!exit)
     {
         Generation generation = new Generation(board);
         board = generation.GenerateNextGeneration();
         Thread.Sleep(350);
         BoardGenerator.Board_Update();
     }
 }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
        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;
        }