Ejemplo n.º 1
0
        //method that fires when a cell is clicked
        private void CellClick(object sender, MouseEventArgs e)
        {
            Square clicked = sender as Square;

            //changes the action taken depending on left click or right click
            if (e.Button == MouseButtons.Left)
            {
                minesweeperGame.CellVisit(clicked.col, clicked.row);
                //ends the game, displays the time and the appropriate response if the player won or lost
                if (minesweeperGame.gameover == true)
                {
                    if (minesweeperGame.win == true)
                    {
                        this.Enabled = false;
                        int       totaltime = sec + (min * 60) + (hour * 3600);
                        EnterName enterName = new EnterName(totaltime, level);
                        enterName.FormClosed += (s, args) => this.Close();
                        enterName.Show();
                    }
                    else
                    {
                        this.Enabled = false;
                        HighScores highScores = new HighScores(level);
                        highScores.FormClosed += (s, args) => this.Close();
                        highScores.Show();
                    }
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                clicked.flagged = true;
                minesweeperGame.RefreshGame();
            }
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.TextLength > 3)
     {
         MessageBox.Show("Enter 3 characters or less");
     }
     else
     {
         initials = textBox1.Text;
         HighScores highScores = new HighScores(initials, difficulty, totaltime);
         highScores.FormClosed += (s, args) => this.Close();
         this.Hide();
         highScores.Show();
     }
 }