Exemple #1
0
        }          //窗口加载前的操作

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Up:
                if (e.Modifiers == Keys.Shift)
                {
                    this.Opacity -= 0.1;
                }
                else
                {
                    c.Up();
                    if (c.change)
                    {
                        c.Add();
                    }
                }
                break;

            case Keys.Down:
                if (e.Modifiers == Keys.Shift)
                {
                    this.Opacity += 0.1;
                }
                else
                {
                    c.Down();
                    if (c.change)
                    {
                        c.Add();
                    }
                }
                break;

            case Keys.Left:
                c.Left();
                if (c.change)
                {
                    c.Add();
                }
                break;

            case Keys.Right:
                c.Right();
                if (c.change)
                {
                    c.Add();
                }
                break;

            case Keys.F1:
                mes.ShowDialog();
                break;

            case Keys.F2:
                this.TopMost = !this.TopMost;
                break;

            case Keys.F3:
                if (this.FormBorderStyle == FormBorderStyle.FixedToolWindow)
                {
                    this.FormBorderStyle = FormBorderStyle.None;
                }
                else
                {
                    this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                }
                break;

            case Keys.F4:
                this.ShowInTaskbar = !this.ShowInTaskbar;
                break;

            case Keys.F5:
                c = new Class1();
                c.Reset();
                Num_pictureBox.Refresh();
                break;

            case Keys.F6:
                _2048Screen();
                _2048messageBox mes2 = new _2048messageBox();
                mes2.a = "保存成功";
                mes2.b = "保存在" + Directory.GetCurrentDirectory() + "\\成绩截图.bmp";
                mes2.ShowDialog();
                break;

            case Keys.Escape:
                this.Close();
                break;
            }
            drow();
            Num_pictureBox.Refresh();
            grade.Text = c.grade.ToString();
            if (c.die)
            {
                gameOver();
            }
        }    //捕捉键盘按下的键,做出相应操作