📄 tetris.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using GATetrisControl;
namespace GATetris
{
/// <summary>
/// Summary description for Tetris.
/// </summary>
public class Tetris : System.Windows.Forms.Form
{
#region Constructor
public Tetris()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
#endregion
#region Overriden Methods
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Tetris));
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.menuFile = new System.Windows.Forms.MenuItem();
this.menuNewGame = new System.Windows.Forms.MenuItem();
this.menuEndGame = new System.Windows.Forms.MenuItem();
this.menuSaveGame = new System.Windows.Forms.MenuItem();
this.menuLoadGame = new System.Windows.Forms.MenuItem();
this.menuExit = new System.Windows.Forms.MenuItem();
this.menuOptions = new System.Windows.Forms.MenuItem();
this.menuSettings = new System.Windows.Forms.MenuItem();
this.menuHelp = new System.Windows.Forms.MenuItem();
this.menuAbout = new System.Windows.Forms.MenuItem();
this.menuHuongDan = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuHighScore = new System.Windows.Forms.MenuItem();
this.gaTetris = new GATetrisControl.GATetris();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuFile,
this.menuOptions,
this.menuHelp});
//
// menuFile
//
this.menuFile.Index = 0;
this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuNewGame,
this.menuEndGame,
this.menuSaveGame,
this.menuLoadGame,
this.menuExit});
this.menuFile.Text = "&File";
//
// menuNewGame
//
this.menuNewGame.Index = 0;
this.menuNewGame.Shortcut = System.Windows.Forms.Shortcut.F2;
this.menuNewGame.Text = "&New Game";
this.menuNewGame.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuEndGame
//
this.menuEndGame.Index = 1;
this.menuEndGame.Shortcut = System.Windows.Forms.Shortcut.F3;
this.menuEndGame.Text = "&End Game";
this.menuEndGame.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuSaveGame
//
this.menuSaveGame.Index = 2;
this.menuSaveGame.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
this.menuSaveGame.Text = "Save Game";
this.menuSaveGame.Click += new System.EventHandler(this.menuItem10_Click);
//
// menuLoadGame
//
this.menuLoadGame.Index = 3;
this.menuLoadGame.Shortcut = System.Windows.Forms.Shortcut.CtrlL;
this.menuLoadGame.Text = "Load Game";
this.menuLoadGame.Click += new System.EventHandler(this.menuItem11_Click);
//
// menuExit
//
this.menuExit.Index = 4;
this.menuExit.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
this.menuExit.Text = "Exit Game";
this.menuExit.Click += new System.EventHandler(this.menuItem12_Click);
//
// menuOptions
//
this.menuOptions.Index = 1;
this.menuOptions.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuSettings});
this.menuOptions.Text = "&Options";
//
// menuSettings
//
this.menuSettings.Index = 0;
this.menuSettings.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
this.menuSettings.Text = "&Settings...";
this.menuSettings.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuHelp
//
this.menuHelp.Index = 2;
this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuAbout,
this.menuHuongDan,
this.menuItem8,
this.menuHighScore});
this.menuHelp.Text = "&Help";
//
// menuAbout
//
this.menuAbout.Index = 0;
this.menuAbout.Text = "&About...";
this.menuAbout.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuHuongDan
//
this.menuHuongDan.Index = 1;
this.menuHuongDan.Text = "Help";
this.menuHuongDan.Click += new System.EventHandler(this.menuHuongDan_Click);
//
// menuItem8
//
this.menuItem8.Index = 2;
this.menuItem8.Text = "-";
//
// menuHighScore
//
this.menuHighScore.Index = 3;
this.menuHighScore.Text = "&Hall Of Fame...";
this.menuHighScore.Click += new System.EventHandler(this.menuItem9_Click);
//
// gaTetris
//
this.gaTetris.Location = new System.Drawing.Point(0, 0);
this.gaTetris.Name = "gaTetris";
this.gaTetris.Padding = new System.Windows.Forms.Padding(2);
this.gaTetris.TabIndex = 0;
//
// Tetris
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(344, 239);
this.Controls.Add(this.gaTetris);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Name = "Tetris";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "GATetris";
this.ResumeLayout(false);
}
#endregion
#region Event Handlers
private void menuItem2_Click(object sender, System.EventArgs e)
{
gaTetris.TetrisGrid.InitNewGame();
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
gaTetris.ShowOptions();
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
gaTetris.TetrisGrid.InitGameOver();
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
gaTetris.ShowAbout();
}
private void tetrisGrid_Load(object sender, System.EventArgs e)
{
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
gaTetris.ShowBestPlayers(null);
}
private void menuItem12_Click(object sender, EventArgs e)
{
Close();
}
private void menuItem10_Click(object sender, EventArgs e)
{
gaTetris.TetrisGrid.OnPause();
gaTetris.TetrisGrid.InitGameSave();
}
private void menuItem11_Click(object sender, EventArgs e)
{
gaTetris.TetrisGrid.OnPause();
gaTetris.TetrisGrid.InitGameLoad();
gaTetris.RefreshScore();
}
#endregion
#region Fields
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuFile;
private System.Windows.Forms.MenuItem menuNewGame;
private System.Windows.Forms.MenuItem menuOptions;
private System.Windows.Forms.MenuItem menuSettings;
private System.Windows.Forms.MenuItem menuEndGame;
private System.Windows.Forms.MenuItem menuHelp;
private System.Windows.Forms.MenuItem menuAbout;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuHighScore;
private GATetrisControl.GATetris gaTetris;
#endregion
private MenuItem menuSaveGame;
private MenuItem menuLoadGame;
private MenuItem menuExit;
private MenuItem menuHuongDan;
private IContainer components;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Tetris());
}
private void menuHuongDan_Click(object sender, EventArgs e)
{
string duongDan = Application.StartupPath;
if (File.Exists(duongDan + "\\Tetris.chm"))
System.Diagnostics.Process.Start(duongDan + "\\Tetris.chm");
else MessageBox.Show("Không tìm thấy đường dẫn này", "Lỗi");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -