private int CostTime; //所用时间
private int MineNum = 10; //雷的总数
private int MineWidth = 30; //雷方块的大小(宽度为30像素)
private Button[,] Mines;
private int RestMine = 10; //剩余的雷数
private int[,] Turn; //==-1 表示这个位置已经翻开;
private int XNum = 8; //一行方块的数目
private int YNum = 9; //一列方块的数目
private void Form2_Load(object sender, EventArgs e)
{
Turn = new int[XNum, YNum];
Mines = new Button[XNum, YNum];
for (int x = 0; x < XNum; x += 1)
for (int y = 0; y < YNum; y += 1)
{
Mines[x, y] = new Button();
Controls.Add(Mines[x, y]);
Mines[x, y].Left = 10 + MineWidth * x;
Mines[x, y].Top = 50 + MineWidth * y;
Mines[x, y].Width = MineWidth;
Mines[x, y].Height = MineWidth;
Mines[x, y].Font = new Font("宋体", 10.5F, FontStyle.Bold, GraphicsUnit.Point, ((134)));
Mines[x, y].BackgroundImageLayout = ImageLayout.Stretch;
Mines[x, y].Name = "Mines" + (x + y * XNum).ToString();
// Mines[x, y].MouseUp += bt_MouseUp;
// Mines[x, y].Visible = false;
Mines[x, y].Text = "";
Mines[x, y].Visible = true;
Mines[x, y].Enabled = true;
Mines[x, y].Tag = null;
Mines[x, y].BackgroundImage = null;
Turn[x, y] = 0;
}
}