示例#1
0
 private void HighScoreScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
     if (e.KeyCode == Keys.Space)
     {
         // Create an instance of the SecondScreen
         InstructionScreen cs = new InstructionScreen();
         cs.Location = new Point(this.Left, this.Top);
         // Add the User Control to the Form
         Form f = this.FindForm();
         f.Controls.Remove(this);
         f.Controls.Add(cs);
         cs.Focus();
     }
     if (e.KeyCode == Keys.Escape)
     {
         // Create an instance of the SecondScreen
         CharacterSelect cs = new CharacterSelect();
         cs.Location = new Point(this.Left, this.Top);
         // Add the User Control to the Form
         Form f = this.FindForm();
         f.Controls.Remove(this);
         f.Controls.Add(cs);
         cs.Focus();
     }
 }
示例#2
0
        private void CharacterSelect_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Right)
            {
                if (index < characters.Count - 1)
                {
                    index++;
                }
                else
                {
                    index = 0;
                }
            }
            if (e.KeyCode == Keys.Left)
            {
                if (index > 0)
                {
                    index--;
                }
                else
                {
                    index = 2;
                }
            }
            if (e.KeyCode == Keys.Space)
            {
                // Create an instance of the SecondScreen
                InstructionScreen cs = new InstructionScreen();
                cs.Location = new Point(this.Left, this.Top);
                // Add the User Control to the Form
                Form f = this.FindForm();
                f.Controls.Remove(this);
                f.Controls.Add(cs);
                cs.Focus();
            }

            if (e.KeyCode == Keys.Escape)
            {
                // Create an instance of the SecondScreen
                MainScreen ms = new MainScreen();
                ms.Location = new Point(this.Left, this.Top);
                // Add the User Control to the Form
                Form f = this.FindForm();
                f.Controls.Remove(this);
                f.Controls.Add(ms);
                ms.Focus();
            }
            if (e.KeyCode == Keys.M)
            {
                HighScoreScreen ms = new HighScoreScreen();
                ms.Location = new Point(this.Left, this.Top);
                // Add the User Control to the Form
                Form f = this.FindForm();
                f.Controls.Remove(this);
                f.Controls.Add(ms);
                ms.Focus();
            }
            Refresh();
        }