把以前写的东西存下来 嘿嘿
原帖:http://hi.baidu.com/activezfj/blog/item/31cd4b3499f6eb4a241f14b7.html(此博客已无情被关,近3000多篇原创呀,说出来都是泪)
源代码:
[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
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//鼠标坐标转换成雷区方格的坐标
private Point MToA(int x, int y)
{
x -= 13; y -= 53;
if(x < 0 || x > BoardWidth * 20 || y < 0 || y > BoardWidth * 20 )
{
throw new Exception();
}
x = x / 20;
y = y / 20;
return new Point(x , y);
}
//鼠标坐