C#打字練習小程序

          本程序寫于剛剛學習C#線程時,游戲者可以選擇四個不同級別的速度進行打字練習,在規定的時間內,用鍵盤敲擊屏幕中出現的相應字母后,該字母便會消失,分數也隨即加2,由于時間原因并沒有實現太多其他功能,如級別的自動增加,點擊相應字母后在該字母上出現相應效果,只是簡單的對C#中的線程練習了一把,希望對初學線程的朋友能夠有所幫助。

          以下為運行效果圖:


          以下為程序源代碼:
          Game.cs文件:

          using System;
          using System.Drawing;
          using System.Collections;
          using System.ComponentModel;
          using System.Windows.Forms;
          using System.Data;
          using System.Threading;

          namespace P195
          {
              
          public class frmGame : System.Windows.Forms.Form
              
          {
                  
          成員變量

                  
          構造

                  
          Windows 窗體設計器生成的代碼

                  
          程序入口

                  
          級別選擇菜單事件處理

                  
          判斷是否正在游戲,改變菜單按鈕的可用性

                  
          窗體加載事件

                  
          計時器(處理隨機產生字母及速度)

                  
          計時器(處理隨游戲時間)

                  
          隨機產生字母

                  
          隨機產生字母標簽的橫坐標

                  
          玩家鍵盤響應事件

                  
          退出事件處理

                  
          放棄本局游戲事件處理

                  
          關于
              }

          }


          MyThread.cs文件:
          using System;
          using System.Windows.Forms;
          using System.Threading;

          namespace P195
          {
              
          public class MyThread
              
          {
                  
          private int _speed = 0;
                  
          private Control _myControl;

                  
          public int Speed
                  
          {
                      
          set
                      
          {
                          
          this._speed = value;
                      }

                      
          get
                      
          {
                          
          return this._speed;
                      }

                  }


                  
          public Control MyControl
                  
          {
                      
          set
                      
          {
                          
          this._myControl = value;
                      }

                      
          get
                      
          {
                          
          return this._myControl;
                      }

                  }


                  
          public void LableMove()
                  
          {
                      
          while(true)
                      
          {
                          
          if(!this._myControl.Visible)
                          
          {
                              Thread.CurrentThread.Abort();
                              
          return;
                          }

                          
          if(this._myControl.Location.Y >= 300)
                          
          {
                              
          this._myControl.Visible = false;
                              Thread.CurrentThread.Abort();
                              
          return;
                          }

                          System.Drawing.Point lablePos 
          = this._myControl.Location;
                          lablePos.Offset(
          0,10);
                          
          this._myControl.Location = lablePos;
                          Thread.Sleep(
          1000);
                      }

                  }

              }

          }


          點擊下載源代碼:/Files/daizhenghenry/TypewriterPractise.rar

          posted on 2008-03-06 09:43 非凡DZ 閱讀(3237) 評論(1)  編輯  收藏 所屬分類: .NET

          評論

          # re: C#打字練習小程序 2012-06-05 21:15 賈秀文

          這個界面沒有啊,光有代碼,能弄個完整的發到我郵箱里,謝謝了,我們留的作業  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2008年3月>
          2425262728291
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類(19)

          隨筆檔案(19)

          友情鏈接

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 怀远县| 青龙| 铜山县| 宜章县| 扶风县| 邻水| 九龙城区| 嵩明县| 汤原县| 美姑县| 越西县| 陵川县| 万全县| 福海县| 安国市| 称多县| 五指山市| 常德市| 滕州市| 临安市| 乌审旗| 南江县| 玉环县| 安吉县| 察隅县| 海盐县| 汉阴县| 太康县| 察哈| 绥化市| 丹寨县| 新乐市| 乡城县| 花莲市| 宜章县| 定日县| 遵化市| 霍城县| 宜川县| 藁城市| 平谷区|