C#编扫雷源码 08-5-02
C#编扫雷源码 一2008年03月23日 星期日 21:53
源代码:
[Form1.CS]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MineClearance
...{
/**//// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
...{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.ComponentModel.IContainer components;
private FaceControl faceControl1;
private MineCountControl mineCountControl1;
private TimerControl timerControl1;
private int [ , ] Mine;//==-2时,表示这个地雷已经爆炸;==-1时,代表这个位置是地雷;否则代表周围的地雷的数量
private int [ , ] Turn;//==-1 表示这个位置已经翻开;==0 表示这个位置没有翻开;==1 表示这个位置插上红旗;
private int BoardWidth;//宽度
private int BoardHeight;//高度
private uint MineCount;
private Point MP = new Point(0, 0);//用来记录鼠标点击的方格
private bool GameStartMark;//游戏开始标志
private uint Count
...{
get
...{
return MineCount;
}
set
...{
MineCount = value;
mineCountControl1.mineCount = (int)value;
}
}
public Form1()
...{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
mineCountControl1 = new MineCountControl();
faceControl1 = new FaceControl();
faceControl1.Click += new EventHandler(ClickFace);
timerControl1 = new TimerControl();
timerControl1.Rouse += new EventHandler(RouseTime);
timerControl1.rouseTime = 999;
Reset(9, 9, 10);
this.CenterToScreen();
this.Controls.Add(faceControl1);
this.Controls.Add(mineCountControl1);
this.Controls.Add(timerControl1);
}
/**//// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
...{
if( disposing )
...{
if (components != null)
...{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows Form Designer generated code#region Windows Form Designer generated code
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
...{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
//
// menuItem9
//
this.menuItem9.Index = 5;
this.menuItem9.Text = "-";
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.Text = "初级 (&B)";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "-";
//
// menuItem6
//
this.menuItem6.Index = 3;
this.menuItem6.Text = "中级 (&I)";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 4;
this.menuItem7.Text = "高级 (&E)";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] ...{
this.menuItem3,
this.menuItem5,
this.menuItem4,
this.menuItem6,
this.menuItem7,
this.menuItem9,
this.menuItem12});
this.menuItem1.Text = "游戏(&G)";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Shortcut = System.Windows.Forms.Shortcut.F2;
this.menuItem3.Text = "开局 (&N)";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem12
//
this.menuItem12.Index = 6;
this.menuItem12.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
this.menuItem12.Text = "退出 (&X)";
this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MineClearance
...{
/**//// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
...{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.ComponentModel.IContainer components;
private FaceControl faceControl1;
private MineCountControl mineCountControl1;
private TimerControl timerControl1;
private int [ , ] Mine;//==-2时,表示这个地雷已经爆炸;==-1时,代表这个位置是地雷;否则代表周围的地雷的数量
private int [ , ] Turn;//==-1 表示这个位置已经翻开;==0 表示这个位置没有翻开;==1 表示这个位置插上红旗;
private int BoardWidth;//宽度
private int BoardHeight;//高度
private uint MineCount;
private Point MP = new Point(0, 0);//用来记录鼠标点击的方格
private bool GameStartMark;//游戏开始标志
private uint Count
...{
get
...{
return MineCount;
}
set
...{
MineCount = value;
mineCountControl1.mineCount = (int)value;
}
}
public Form1()
...{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
mineCountControl1 = new MineCountControl();
faceControl1 = new FaceControl();
faceControl1.Click += new EventHandler(ClickFace);
timerControl1 = new TimerControl();
timerControl1.Rouse += new EventHandler(RouseTime);
timerControl1.rouseTime = 999;
Reset(9, 9, 10);
this.CenterToScreen();
this.Controls.Add(faceControl1);
this.Controls.Add(mineCountControl1);
this.Controls.Add(timerControl1);
}
/**//// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
...{
if( disposing )
...{
if (components != null)
...{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows Form Designer generated code#region Windows Form Designer generated code
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
...{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
//
// menuItem9
//
this.menuItem9.Index = 5;
this.menuItem9.Text = "-";
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.Text = "初级 (&B)";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "-";
//
// menuItem6
//
this.menuItem6.Index = 3;
this.menuItem6.Text = "中级 (&I)";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 4;
this.menuItem7.Text = "高级 (&E)";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] ...{
this.menuItem3,
this.menuItem5,
this.menuItem4,
this.menuItem6,
this.menuItem7,
this.menuItem9,
this.menuItem12});
this.menuItem1.Text = "游戏(&G)";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Shortcut = System.Windows.Forms.Shortcut.F2;
this.menuItem3.Text = "开局 (&N)";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem12
//
this.menuItem12.Index = 6;
this.menuItem12.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
this.menuItem12.Text = "退出 (&X)";
this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this