Ejemplo n.º 1
0
        private void quitButton_Click(object sender, EventArgs e)
        {
            Form f = this.FindForm();

            f.Controls.Remove(this);
            // Create an instance of the SecondScreen
            MainScreen ms = new MainScreen();

            // Add the User Control to the Form
            f.Controls.Add(ms);
            ms.Focus();
        }
Ejemplo n.º 2
0
        private void GameScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Left:
                leftArrowDown = true;
                break;

            case Keys.Right:
                rightArrowDown = true;
                break;

            case Keys.Up:
                upArrowDown = true;
                break;

            case Keys.Down:
                downArrowDown = true;
                break;

            case Keys.Space:
                if (newgame)
                {
                    Form f = this.FindForm();
                    f.Controls.Remove(this);

                    MainScreen ms = new MainScreen();
                    f.Controls.Add(ms);
                    ms.Focus();
                }
                break;

            case Keys.Escape:
                //end program
                Application.Exit();
                break;
            }
        }