Walking Maze C # version (ii)

Source: Internet
Author: User
form, calling ...

Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;
Using System.Threading;

Namespace Mazedemo
{
<summary>
Summary description of the Form1.
</summary>
public class Form1:System.Windows.Forms.Form
{
Private System.Windows.Forms.Button button1;
<summary>
The required designer variable.
</summary>
///
Private Cmaze Mymaze;
Private System.Windows.Forms.Button button2;
Private System.Windows.Forms.Button btnabout;
Private System.Windows.Forms.Button Btnrun;
Private System.Windows.Forms.Button btnreset;
Private System.Windows.Forms.Panel Panel1;
Private System.Windows.Forms.Label Label1;
Private System.Windows.Forms.Label Label2;
Private System.Windows.Forms.Label label3;
Private System.Windows.Forms.Label label4;
Private System.Windows.Forms.Label Label5;
Private System.Windows.Forms.Label label6;
Private System.Windows.Forms.Label Label7;
Private System.Windows.Forms.Label Label8;
Private System.Windows.Forms.Button Button3;
Private System.ComponentModel.IContainer Components=null;

Public Form1 ()
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();

//
TODO: Add any constructor code after the InitializeComponent call
//
bool[,] _mg=new bool[,]{{true,false,false,true,false,false,false},
{True,true,true,true,true,true,true},
{False,false,true,false,true,false,true},
{False,false,true,false,true,false,false},
{False,true,true,false,true,false,false},
{True,true,false,false,true,true,false},
{False,false,false,false,false,true,true}
};
Mymaze=new Cmaze (_mg,new Point (0,0), new Point (6,6));
}

<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing);
}

Code generated #region the Windows forms Designer
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This.button1 = new System.Windows.Forms.Button ();
This.button2 = new System.Windows.Forms.Button ();
This.btnabout = new System.Windows.Forms.Button ();
This.btnrun = new System.Windows.Forms.Button ();
This.btnreset = new System.Windows.Forms.Button ();
This.panel1 = new System.Windows.Forms.Panel ();
This.label8 = new System.Windows.Forms.Label ();
THIS.LABEL7 = new System.Windows.Forms.Label ();
This.label6 = new System.Windows.Forms.Label ();
This.label5 = new System.Windows.Forms.Label ();
This.label4 = new System.Windows.Forms.Label ();
This.label3 = new System.Windows.Forms.Label ();
This.label2 = new System.Windows.Forms.Label ();
This.label1 = new System.Windows.Forms.Label ();
This.button3 = new System.Windows.Forms.Button ();
This.panel1.SuspendLayout ();
This. SuspendLayout ();
//
Button1
//
This.button1.Location = new System.Drawing.Point (360, 288);
This.button1.Name = "Button1";
This.button1.TabIndex = 0;
This.button1.Text = "Info";
This.button1.Click + = new System.EventHandler (This.button1_click);
//
Button2
//
This.button2.Location = new System.Drawing.Point (360, 192);
This.button2.Name = "Button2";
This.button2.TabIndex = 1;
This.button2.Text = "Step";
This.button2.Click + = new System.EventHandler (This.button2_click);
//
Btnabout
//
This.btnAbout.Location = new System.Drawing.Point (360, 320);
This.btnAbout.Name = "Btnabout";
This.btnAbout.TabIndex = 2;
This.btnAbout.Text = "about";
This.btnAbout.Click + = new System.EventHandler (This.btnabout_click);
//
Btnrun
//
This.btnRun.Location = new System.Drawing.Point (360, 160);
This.btnRun.Name = "Btnrun";
This.btnRun.TabIndex = 3;
This.btnRun.Text = "Run";
This.btnRun.Click + = new System.EventHandler (This.btnrun_click);
//
Btnreset
//
This.btnReset.Location = new System.Drawing.Point (360, 256);
This.btnReset.Name = "Btnreset";
This.btnReset.TabIndex = 4;
This.btnReset.Text = "Reset";
This.btnReset.Click + = new System.EventHandler (This.btnreset_click);
//
Panel1
//
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL8);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL7);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL6);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL5);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL4);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL3);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL2);
THIS.PANEL1.CONTROLS.ADD (THIS.LABEL1);
This.panel1.Location = new System.Drawing.Point (360, 8);
This.panel1.Name = "Panel1";
This.panel1.Size = new System.Drawing.Size (72, 144);
This.panel1.TabIndex = 5;
//
Label8
//
This.label8.Location = new System.Drawing.Point (32, 120);
This.label8.Name = "Label8";
This.label8.Size = new System.Drawing.Size (32, 16);
This.label8.TabIndex = 7;
This.label8.Text = "Wall";
//
Label7
//
This.label7.BackColor = System.Drawing.Color.Red;
This.label7.Location = new System.Drawing.Point (8, 112);
This.label7.Name = "Label7";
This.label7.Size = new System.Drawing.Size (20, 20);
This.label7.TabIndex = 6;
//
Label6
//
This.label6.Location = new System.Drawing.Point (32, 88);
This.label6.Name = "Label6";
This.label6.Size = new System.Drawing.Size (32, 16);
This.label6.TabIndex = 5;
This.label6.Text = "have gone";
//
Label5
//
This.label5.BackColor = System.Drawing.Color.Blue;
This.label5.Location = new System.Drawing.Point (8, 80);
This.label5.Name = "Label5";
This.label5.Size = new System.Drawing.Size (20, 20);
This.label5.TabIndex = 4;
//
Label4
//
This.label4.Location = new System.Drawing.Point (32, 56);
This.label4.Name = "Label4";
This.label4.Size = new System.Drawing.Size (32, 16);
This.label4.TabIndex = 3;
This.label4.Text = "optional Direction";
//
Label3
//
This.label3.BackColor = System.Drawing.Color.Yellow;
This.label3.Location = new System.Drawing.Point (8, 48);
This.label3.Name = "Label3";
This.label3.Size = new System.Drawing.Size (20, 20);
This.label3.TabIndex = 2;
//
Label2
//
This.label2.Location = new System.Drawing.Point (32, 24);
This.label2.Name = "Label2";
This.label2.Size = new System.Drawing.Size (32, 16);
This.label2.TabIndex = 1;
This.label2.Text = "pathway";
//
Label1
//
This.label1.BackColor = System.Drawing.Color.Green;
This.label1.Location = new System.Drawing.Point (8, 16);
This.label1.Name = "Label1";
This.label1.Size = new System.Drawing.Size (20, 20);
This.label1.TabIndex = 0;
//
Button3
//
This.button3.Location = new System.Drawing.Point (360, 224);
This.button3.Name = "Button3";
This.button3.TabIndex = 6;
This.button3.Text = "Auto";
This.button3.Click + = new System.EventHandler (This.button3_click);
//
Form1
//
This. AutoScaleBaseSize = new System.Drawing.Size (6, 14);
This. ClientSize = new System.Drawing.Size (442, 348);
This. Controls.Add (This.button3);
This. Controls.Add (THIS.PANEL1);
This. Controls.Add (This.btnreset);
This. Controls.Add (This.btnrun);
This. Controls.Add (this.btnabout);
This. Controls.Add (This.button2);
This. Controls.Add (This.button1);
This. MaximizeBox = false;
This. Name = "Form1";
This. Text = "Maze";
This. Load + = new System.EventHandler (this. Form1_Load);
This. Paint + = new System.Windows.Forms.PaintEventHandler (this. Form1_paint);
This.panel1.ResumeLayout (FALSE);
This. ResumeLayout (FALSE);

}
#endregion

<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main ()
{
Application.Run (New Form1 ());
}

private void Button1_Click (object sender, System.EventArgs e)
{
String Msgstr= "";
msgstr+= "Maze diagram: \ n";
Msgstr+=mymaze. ToString ();
msgstr+= "\ n";
msgstr+= "Stack info: \ n";
msgstr+= "Current data sum:" +mymaze. Stackcount.tostring () + "\ n";
msgstr+= "Current number of walks:" +mymaze. Stepcount.tostring () + "\ n";

MessageBox.Show (MSGSTR);
}

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)
{
E.graphics.drawrectangle (New Pen (color.red), 0,0,10,10);
Mymaze. Drawbox (E.graphics);
Mymaze. DrawPath (E.graphics);
Mymaze. Drawnextpath (E.graphics);
}

private void Form1_Load (object sender, System.EventArgs e)
{

}

private void Button2_Click (object sender, System.EventArgs e)
{
if (Mymaze. Step () ==1)
MessageBox.Show ("Already to exit");
This. Refresh ();
}

private void Btnrun_click (object sender, System.EventArgs e)
{
Mymaze. Run ();
This. Refresh ();
}

private void Btnreset_click (object sender, System.EventArgs e)
{
Mymaze. Reset ();
This. Refresh ();
}

private void Btnabout_click (object sender, System.EventArgs e)
{
MessageBox.Show ("Author: lovered (GV) \nm s n:lovered_gv@hotmail.com\n finish date: April 04, 04");
}

private void Button3_Click (object sender, System.EventArgs e)
{
Mymaze. Reset ();
while (Mymaze. Step ()!=1)
{
This. Refresh ();
Thread.Sleep (500);
}
MessageBox.Show ("Already to exit");
}

}
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.