C#实现简单打字游戏

2020-05-07 10:01:29王冬梅

另,页面代码(全靠拖拉)如下:

namespace WindowsFormsApplication3
{
  partial class Form1
  {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;
 
    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
      if (disposing && (components != null))
      {
        components.Dispose();
      }
      base.Dispose(disposing);
    }
 
    #region Windows 窗体设计器生成的代码
 
    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
      this.components = new System.ComponentModel.Container();
      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
      this.btnStart = new System.Windows.Forms.Button();
      this.btnStop = new System.Windows.Forms.Button();
      this.btnQuit = new System.Windows.Forms.Button();
      this.menuStrip1 = new System.Windows.Forms.MenuStrip();
      this.设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      this.tsmiStart = new System.Windows.Forms.ToolStripMenuItem();
      this.tsmiStop = new System.Windows.Forms.ToolStripMenuItem();
      this.tsmiQuit = new System.Windows.Forms.ToolStripMenuItem();
      this.查看ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      this.tsmiRate = new System.Windows.Forms.ToolStripMenuItem();
      this.tsmiTime = new System.Windows.Forms.ToolStripMenuItem();
      this.timer1 = new System.Windows.Forms.Timer(this.components);
      this.timer2 = new System.Windows.Forms.Timer(this.components);
      this.label1 = new System.Windows.Forms.Label();
      this.label2 = new System.Windows.Forms.Label();
      this.label3 = new System.Windows.Forms.Label();
      this.label4 = new System.Windows.Forms.Label();
      this.label5 = new System.Windows.Forms.Label();
      this.label6 = new System.Windows.Forms.Label();
      this.label7 = new System.Windows.Forms.Label();
      this.label8 = new System.Windows.Forms.Label();
      this.textBox1 = new System.Windows.Forms.TextBox();
      this.pictureBox1 = new System.Windows.Forms.PictureBox();
      this.pictureBox2 = new System.Windows.Forms.PictureBox();
      this.menuStrip1.SuspendLayout();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
      this.SuspendLayout();
      // 
      // btnStart
      // 
      this.btnStart.Location = new System.Drawing.Point(414, 86);
      this.btnStart.Name = "btnStart";
      this.btnStart.Size = new System.Drawing.Size(92, 41);
      this.btnStart.TabIndex = 0;
      this.btnStart.Text = "开始";
      this.btnStart.UseVisualStyleBackColor = true;
      this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
      this.btnStart.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btnStart_KeyDown);
      // 
      // btnStop
      // 
      this.btnStop.Location = new System.Drawing.Point(414, 188);
      this.btnStop.Name = "btnStop";
      this.btnStop.Size = new System.Drawing.Size(92, 41);
      this.btnStop.TabIndex = 1;
      this.btnStop.Text = "结束";
      this.btnStop.UseVisualStyleBackColor = true;
      this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
      // 
      // btnQuit
      // 
      this.btnQuit.Location = new System.Drawing.Point(414, 292);
      this.btnQuit.Name = "btnQuit";
      this.btnQuit.Size = new System.Drawing.Size(92, 41);
      this.btnQuit.TabIndex = 2;
      this.btnQuit.Text = "退出";
      this.btnQuit.UseVisualStyleBackColor = true;
      this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
      // 
      // menuStrip1
      // 
      this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
      this.设置ToolStripMenuItem,
      this.查看ToolStripMenuItem});
      this.menuStrip1.Location = new System.Drawing.Point(0, 0);
      this.menuStrip1.Name = "menuStrip1";
      this.menuStrip1.Size = new System.Drawing.Size(539, 25);
      this.menuStrip1.TabIndex = 3;
      this.menuStrip1.Text = "menuStrip1";
      // 
      // 设置ToolStripMenuItem
      // 
      this.设置ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
      this.tsmiStart,
      this.tsmiStop,
      this.tsmiQuit});
      this.设置ToolStripMenuItem.Name = "设置ToolStripMenuItem";
      this.设置ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
      this.设置ToolStripMenuItem.Text = "设置";
      // 
      // tsmiStart
      // 
      this.tsmiStart.Name = "tsmiStart";
      this.tsmiStart.Size = new System.Drawing.Size(124, 22);
      this.tsmiStart.Text = "开始游戏";
      this.tsmiStart.Click += new System.EventHandler(this.tsmiStart_Click);
      // 
      // tsmiStop
      // 
      this.tsmiStop.Name = "tsmiStop";
      this.tsmiStop.Size = new System.Drawing.Size(124, 22);
      this.tsmiStop.Text = "结束游戏";
      this.tsmiStop.Click += new System.EventHandler(this.tsmiStop_Click);
      // 
      // tsmiQuit
      // 
      this.tsmiQuit.Name = "tsmiQuit";
      this.tsmiQuit.Size = new System.Drawing.Size(124, 22);
      this.tsmiQuit.Text = "退出游戏";
      this.tsmiQuit.Click += new System.EventHandler(this.tsmiQuit_Click);
      // 
      // 查看ToolStripMenuItem
      // 
      this.查看ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
      this.tsmiRate,
      this.tsmiTime});
      this.查看ToolStripMenuItem.Name = "查看ToolStripMenuItem";
      this.查看ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
      this.查看ToolStripMenuItem.Text = "查看";
      // 
      // tsmiRate
      // 
      this.tsmiRate.Name = "tsmiRate";
      this.tsmiRate.Size = new System.Drawing.Size(124, 22);
      this.tsmiRate.Text = "正确率";
      this.tsmiRate.Click += new System.EventHandler(this.tsmiRate_Click);
      // 
      // tsmiTime
      // 
      this.tsmiTime.Name = "tsmiTime";
      this.tsmiTime.Size = new System.Drawing.Size(124, 22);
      this.tsmiTime.Text = "所用时间";
      this.tsmiTime.Click += new System.EventHandler(this.tsmiTime_Click);
      // 
      // timer1
      // 
      this.timer1.Interval = 5;
      this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
      // 
      // timer2
      // 
      this.timer2.Interval = 1000;
      this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
      // 
      // label1
      // 
      this.label1.AutoSize = true;
      this.label1.Location = new System.Drawing.Point(25, 252);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(53, 12);
      this.label1.TabIndex = 4;
      this.label1.Text = "所用时间";
      // 
      // label2
      // 
      this.label2.AutoSize = true;
      this.label2.Location = new System.Drawing.Point(114, 252);
      this.label2.Name = "label2";
      this.label2.Size = new System.Drawing.Size(11, 12);
      this.label2.TabIndex = 5;
      this.label2.Text = "0";
      // 
      // label3
      // 
      this.label3.AutoSize = true;
      this.label3.Location = new System.Drawing.Point(25, 282);
      this.label3.Name = "label3";
      this.label3.Size = new System.Drawing.Size(41, 12);
      this.label3.TabIndex = 6;
      this.label3.Text = "正确数";
      // 
      // label4
      // 
      this.label4.AutoSize = true;
      this.label4.Location = new System.Drawing.Point(27, 321);
      this.label4.Name = "label4";
      this.label4.Size = new System.Drawing.Size(41, 12);
      this.label4.TabIndex = 7;
      this.label4.Text = "错误数";
      // 
      // label5
      // 
      this.label5.AutoSize = true;
      this.label5.Location = new System.Drawing.Point(27, 354);
      this.label5.Name = "label5";
      this.label5.Size = new System.Drawing.Size(41, 12);
      this.label5.TabIndex = 8;
      this.label5.Text = "正确率";
      // 
      // label6
      // 
      this.label6.AutoSize = true;
      this.label6.Location = new System.Drawing.Point(116, 282);
      this.label6.Name = "label6";
      this.label6.Size = new System.Drawing.Size(11, 12);
      this.label6.TabIndex = 9;
      this.label6.Text = "0";
      // 
      // label7
      // 
      this.label7.AutoSize = true;
      this.label7.Location = new System.Drawing.Point(116, 320);
      this.label7.Name = "label7";
      this.label7.Size = new System.Drawing.Size(11, 12);
      this.label7.TabIndex = 10;
      this.label7.Text = "0";
      // 
      // label8
      // 
      this.label8.AutoSize = true;
      this.label8.Location = new System.Drawing.Point(116, 354);
      this.label8.Name = "label8";
      this.label8.Size = new System.Drawing.Size(41, 12);
      this.label8.TabIndex = 11;
      this.label8.Text = "label8";
      this.label8.Visible = false;
      // 
      // textBox1
      // 
      this.textBox1.BackColor = System.Drawing.SystemColors.Info;
      this.textBox1.Location = new System.Drawing.Point(60, 106);
      this.textBox1.Name = "textBox1";
      this.textBox1.Size = new System.Drawing.Size(100, 21);
      this.textBox1.TabIndex = 12;
      this.textBox1.Visible = false;
      // 
      // pictureBox1
      // 
      this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
      this.pictureBox1.InitialImage = null;
      this.pictureBox1.Location = new System.Drawing.Point(0, 28);
      this.pictureBox1.Name = "pictureBox1";
      this.pictureBox1.Size = new System.Drawing.Size(539, 400);
      this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
      this.pictureBox1.TabIndex = 13;
      this.pictureBox1.TabStop = false;
      // 
      // pictureBox2
      // 
      this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
      this.pictureBox2.Location = new System.Drawing.Point(0, 28);
      this.pictureBox2.Name = "pictureBox2";
      this.pictureBox2.Size = new System.Drawing.Size(539, 400);
      this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
      this.pictureBox2.TabIndex = 14;
      this.pictureBox2.TabStop = false;
      // 
      // Form1
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(539, 429);
      this.Controls.Add(this.textBox1);
      this.Controls.Add(this.label8);
      this.Controls.Add(this.label7);
      this.Controls.Add(this.label6);
      this.Controls.Add(this.label5);
      this.Controls.Add(this.label4);
      this.Controls.Add(this.label3);
      this.Controls.Add(this.label2);
      this.Controls.Add(this.label1);
      this.Controls.Add(this.btnQuit);
      this.Controls.Add(this.btnStop);
      this.Controls.Add(this.btnStart);
      this.Controls.Add(this.menuStrip1);
      this.Controls.Add(this.pictureBox1);
      this.Controls.Add(this.pictureBox2);
      this.MainMenuStrip = this.menuStrip1;
      this.Name = "Form1";
      this.Text = "Form1";
      this.menuStrip1.ResumeLayout(false);
      this.menuStrip1.PerformLayout();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();
 
    }
 
    #endregion
 
    private System.Windows.Forms.Button btnStart;
    private System.Windows.Forms.Button btnStop;
    private System.Windows.Forms.Button btnQuit;
    private System.Windows.Forms.MenuStrip menuStrip1;
    private System.Windows.Forms.ToolStripMenuItem 设置ToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem 查看ToolStripMenuItem;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.Timer timer2;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.Label label7;
    private System.Windows.Forms.Label label8;
    private System.Windows.Forms.ToolStripMenuItem tsmiRate;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.ToolStripMenuItem tsmiTime;
    private System.Windows.Forms.ToolStripMenuItem tsmiStart;
    private System.Windows.Forms.ToolStripMenuItem tsmiStop;
    private System.Windows.Forms.ToolStripMenuItem tsmiQuit;
    private System.Windows.Forms.PictureBox pictureBox2;
  }
}