Exemple #1
0
        public static DialogResult Show()
        {
            pauseForm = new PauseForm();

            pauseForm.ShowDialog();
            return(buttonResult);
        }
Exemple #2
0
        private void GameScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            // opens a pause screen is escape is pressed. Depending on what is pressed
            // on pause screen the program will either continue or exit to main menu
            if (e.KeyCode == Keys.Escape && gameTimer.Enabled)
            {
                gameTimer.Enabled = false;

                DialogResult result = PauseForm.Show();

                if (result == DialogResult.Cancel)
                {
                    gameTimer.Enabled = true;
                }
                else if (result == DialogResult.Abort)
                {
                    MainForm.ChangeScreen(this, "MenuScreen");
                }
            }

            directionLast = direction; //store the previous direction to determine if new move is ok

            switch (e.KeyCode)
            {
            case Keys.Left:
                direction = "left";
                break;

            case Keys.Down:
                direction = "down";
                break;

            case Keys.Right:
                direction = "right";
                break;

            case Keys.Up:
                direction = "up";
                break;
            }
        }