Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Form1.cs
Package: Visual.rar [view]
Upload User: yiyuerguo
Upload Date: 2014-09-27
Package Size: 3781k
Code Size: 6k
Category:
CSharp
Development Platform:
Others
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace WindowsApplication9
- {
- /// <summary>
- /// Form1 的摘要说明。
- /// </summary>
- public class Form1 : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Timer timer1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
- private System.ComponentModel.IContainer components;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Label label2;
- //声明场地类
- private Floor floor;
- public Form1()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- floor = new Floor(new Point(100, 100));
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.timer1 = new System.Windows.Forms.Timer(this.components);
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.button3 = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.button4 = new System.Windows.Forms.Button();
- this.label2 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // timer1
- //
- this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(16, 8);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(48, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "开始";
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(72, 8);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(48, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "暂停";
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(240, 8);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(64, 21);
- this.textBox1.TabIndex = 2;
- this.textBox1.Text = "100";
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(312, 8);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(64, 23);
- this.button3.TabIndex = 3;
- this.button3.Text = "改变速度";
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(128, 8);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(100, 16);
- this.label1.TabIndex = 4;
- this.label1.Text = "输入大于1的整数";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(400, 8);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(64, 23);
- this.button4.TabIndex = 5;
- this.button4.Text = "重新开始";
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(48, 272);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(392, 16);
- this.label2.TabIndex = 6;
- this.label2.Text = "说明:鼠标控制蛇的方向,左击向右转,右击向左转。";
- //
- // Form1
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.BackColor = System.Drawing.SystemColors.Control;
- this.ClientSize = new System.Drawing.Size(488, 317);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.button4);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
- this.Name = "Form1";
- this.Text = "Form1";
- this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
- this.Load += new System.EventHandler(this.Form1_Load);
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new Form1());
- }
- private void button1_Click(object sender, System.EventArgs e)
- {
- timer1.Enabled = true;
- }
- private void button2_Click(object sender, System.EventArgs e)
- {
- timer1.Enabled = false;
- }
- private void timer1_Tick(object sender, System.EventArgs e)
- {
- floor.Display(this.CreateGraphics());
- }
- private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- floor.S.TurnDirection(0);
- else if (e.Button == MouseButtons.Right)
- floor.S.TurnDirection(1);
- }
- private void button3_Click(object sender, System.EventArgs e)
- {
- timer1.Interval = Convert.ToInt32(textBox1.Text);
- }
- private void button4_Click(object sender, System.EventArgs e)
- {
- floor.ReSet(this.CreateGraphics());
- }
- private void Form1_Load(object sender, System.EventArgs e)
- {
- floor.initFloor(this.CreateGraphics());
- floor.Display(this.CreateGraphics());
- floor.S.snakeDie += new SnakeDele(S_snakeDie);
- }
- private void S_snakeDie()
- {
- timer1.Enabled = false;
- }
- }
- }