コード例 #1
0
        private void RestartGame() // The user selected to start a new game form the dropbox
        {
            this.gameTimer.Stop();
            bool             openingFormClosed1;
            GameSizeAndBombs newGame = new GameSizeAndBombs();

            using (OpeningForm openingForm = new OpeningForm()) // Get the size and number of bombs of the game from the opening form
            {
                openingForm.Location = this.Location;
                if (openingForm.ShowDialog() == DialogResult.OK)
                {
                    newGame.Size          = openingForm.SelectedMode.Size;
                    newGame.NumberOfBombs = openingForm.SelectedMode.NumberOfBombs;
                    openingFormClosed1    = false;
                }
                else // The use didn not submit the opening form
                {
                    openingFormClosed1 = true;
                    this.gameTimer.Start();
                }
            }

            if (openingFormClosed1)
            {
                return;
            }
            else
            {
                Form1 newForm = new Form1(newGame);
                newForm.Location = this.Location;
                newForm.Show();
                this.Dispose();
            }
        }
コード例 #2
0
        public Form1(GameSizeAndBombs newGame) // Create a new game (used for second+ games)
        {
            this.size          = newGame.Size;
            this.numberOfBombs = newGame.NumberOfBombs;

            InitializeForm();
        }
コード例 #3
0
        private void RestartGame(GameSizeAndBombs previousGame) // Start a new game in a new form with the size and number of bombs specified
        {
            Form1 newForm = new Form1(previousGame);

            newForm.Location = this.Location;
            newForm.Show();
            this.Dispose();
            return;
        }
コード例 #4
0
 public OpeningForm()
 {
     InitializeComponent();
     this.Icon        = Properties.Resources.icon_ih7_icon;
     selectedMode     = new GameSizeAndBombs();
     this.Size        = new Size(300, 250);
     this.font        = new Font("Cambria", 12);
     this.MinimumSize = this.Size;
     this.MaximumSize = this.Size;
     SetButtons();
 }