📄 mineform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MinesWeeper
{
public class Form1 : System.Windows.Forms.Form
{
private MinesWeeper.MinesArea minesArea1;
private System.Windows.Forms.Panel pnlZone;
private System.Windows.Forms.Panel panel1;
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.Label lblTime;
private System.Windows.Forms.Label lblLeft;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem10;
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
//
InitializeComponent();
//
// TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
//
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows InitializeComponent
private void InitializeComponent()
{
this.minesArea1 = new MinesWeeper.MinesArea();
this.pnlZone = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.lblTime = new System.Windows.Forms.Label();
this.lblLeft = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem3 = 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.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.pnlZone.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// minesArea1
//
this.minesArea1.Location = new System.Drawing.Point(5, 5);
this.minesArea1.MineEngine = null;
this.minesArea1.Name = "minesArea1";
this.minesArea1.Size = new System.Drawing.Size(190, 200);
this.minesArea1.TabIndex = 1;
this.minesArea1.SizeChanged += new System.EventHandler(this.minesArea1_SizeChanged);
//
// pnlZone
//
this.pnlZone.Controls.Add(this.minesArea1);
this.pnlZone.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlZone.Location = new System.Drawing.Point(0, 24);
this.pnlZone.Name = "pnlZone";
this.pnlZone.Size = new System.Drawing.Size(189, 193);
this.pnlZone.TabIndex = 2;
//
// panel1
//
this.panel1.Controls.Add(this.lblTime);
this.panel1.Controls.Add(this.lblLeft);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(189, 24);
this.panel1.TabIndex = 3;
//
// lblTime
//
this.lblTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lblTime.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblTime.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.lblTime.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblTime.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.lblTime.Location = new System.Drawing.Point(128, 2);
this.lblTime.Name = "lblTime";
this.lblTime.Size = new System.Drawing.Size(56, 20);
this.lblTime.TabIndex = 1;
this.lblTime.Text = "000";
this.lblTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblLeft
//
this.lblLeft.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblLeft.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.lblLeft.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblLeft.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.lblLeft.Location = new System.Drawing.Point(8, 2);
this.lblLeft.Name = "lblLeft";
this.lblLeft.Size = new System.Drawing.Size(56, 20);
this.lblLeft.TabIndex = 0;
this.lblLeft.Text = "000";
this.lblLeft.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuItem4,
this.menuItem5,
this.menuItem6,
this.menuItem7,
this.menuItem8,
this.menuItem9,
this.menuItem10});
this.menuItem1.Text = "Game";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Text = "New";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "-";
//
// menuItem5
//
this.menuItem5.Index = 2;
this.menuItem5.Text = "Beginner";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 3;
this.menuItem6.Text = "Intermediate";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 4;
this.menuItem7.Text = "Expert";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem8
//
this.menuItem8.Index = 5;
this.menuItem8.Text = "Custom...";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// menuItem9
//
this.menuItem9.Index = 6;
this.menuItem9.Text = "-";
//
// menuItem10
//
this.menuItem10.Index = 7;
this.menuItem10.Text = "Exit";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "Help";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(189, 217);
this.Controls.Add(this.pnlZone);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MinesWepper";
this.Load += new System.EventHandler(this.Form1_Load);
this.pnlZone.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//new
private void menuItem3_Click(object sender, System.EventArgs e)
{
minesArea1.MineEngine.Deploy(9,9,10);
}
//mines usercontrol size change
private void minesArea1_SizeChanged(object sender, System.EventArgs e)
{
this.Size = new Size(minesArea1.Width+15,minesArea1.Height+90);
}
private void Form1_Load(object sender, System.EventArgs e)
{
IMineEngine memento = new DefaultMineEngine();
memento.Deploy(10,10,10);
this.minesArea1.MineEngine = memento;
memento.CalculaGraph.Tick += new EventHandler(CalculaGraph_Tick);
}
//exit
private void menuItem10_Click(object sender, System.EventArgs e)
{
this.Close();
}
//intermediate
private void menuItem6_Click(object sender, System.EventArgs e)
{
minesArea1.MineEngine.Deploy(16,16,40);
}
//expert
private void menuItem7_Click(object sender, System.EventArgs e)
{
minesArea1.MineEngine.Deploy(30,16,99);
}
//custom...
private void menuItem8_Click(object sender, System.EventArgs e)
{
}
//beginner
private void menuItem5_Click(object sender, System.EventArgs e)
{
minesArea1.MineEngine.Deploy(9,9,10);
}
private void CalculaGraph_Tick(object sender, EventArgs e)
{
this.lblTime.Text = String.Format("{0:000}",minesArea1.MineEngine.UseTimes);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -