Walking the Maze C # Edition (2)

zhaozj2021-02-16  55

// Form, call ...

Using system.drawing; using system.collections; using system.windows.form; using system.data; using system.Threading;

A summary description of Namespace Mazedemo {///

/// Form1. /// public class form1: system.windows.forms.form {private system.windows.forms.button button1; /// // / / The designer variable. /// /// 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 () {// // Windows Form Designer Support for // InitializeComponent ();

// // Todo: Add any constructor code after INITIALIZECMOMPONENT // Bool [,] _mg = new bool [,] {{True, false, false, true, false, false, false}, {true, true, True, True, True, True}, {False, true, false, true, false, true}, {false, false, true, false, true, false, false}, {false, true, true, False, true, false, false}, false, true, true, false}, {false, false}, false, false, false, false, false, true, true}}; mymaze = new cmaze (_mg, new Point (0, 0), New Point (6, 6));

///

/// Clean all the resources being used. /// Protected Override Void Dispose (Bool Disposing) {if (disponents! = null) {Components.dispose ();}} Base.Dispose (DISPOSION);} #Region Windows Form The code generated by the designer /// /// designer supports the required method - do not use the code editor to modify the // / this method.

/// private () {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.b Utton1.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.pal1.location = new system.drawing.point (360, 8); this.Panel1.name = "PA NEL1 "; 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 = "Take"; // 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); THISLABEL4.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 sys Tem.drawing.point (32, 24); this.label2.name = "label2"; this.label2.size = new system.drawing.size (32, 16); this.Label2.tabindex = 1; this.label2 .Text = "path"; // // label1 // this.label1.backcolor = system.drawing.color.d; 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

///

/// The primary entry point of the application. /// [stathread] static void main () {Application.run (new form1 ());}

Private void button1_click (object sender, system.eventargs e) {string msgstr = ""; msgstr = "Maze MA] / n"; msgstr = mymaze.tostring (); msgstr = "/ n"; msgstr = "stack information : / n "; msgstr =" Current data sum: " mymaze.stackcount.toStive () " / n "; msgstr =" The current number of steps: " mymaze.stepcount.toString () " / n " ;

Messagebox.show (msgstr);

Private void form1_paint (object sender, system.windows) {//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 ("has arrived out"); 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 completion date: 04 April 4");}

Private void button3_click (object sender, system.eventargs e) {mymaze.reset (); while (mymaze.step ()! = 1) {this.refresh (); thread.sleep (500);} messagebox.show (" Has arrived ");

}

转载请注明原文地址:https://www.9cbs.com/read-19124.html

New Post(0)