Пример #1
0
        public static DialogResult Show()
        {
            pauseForm = new PauseForm();

            pauseForm.ShowDialog();
            return(buttonResult);
        }
        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;
                rightPressed      = leftPressed = upPressed = downPressed = false;

                DialogResult result = PauseForm.Show();

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

            //player 1 button presses
            switch (e.KeyCode)
            {
            case Keys.Left:
                leftPressed = true;
                break;

            case Keys.Down:
                downPressed = true;
                break;

            case Keys.Right:
                rightPressed = true;
                break;

            case Keys.Up:
                upPressed = true;
                break;
            }
        }