⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmaze.cs

📁 迷宫游戏源码
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;

namespace MazeSolution
{
	/// <summary>
	/// Summary description for frmMaze.
	/// </summary>
	public class frmMaze : System.Windows.Forms.Form
	{
		// maze array

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Drawing.Printing.PrintDocument printDocument1;
		private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem PrintMenu;
		private System.Windows.Forms.MenuItem PreviewMenu;
		private System.Windows.Forms.MenuItem DimensionsMenu;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.StatusBar statusBar;
		private System.Windows.Forms.MenuItem ResetMenu;
		private System.Windows.Forms.MenuItem SolveTwoThreads;
		private System.Windows.Forms.MenuItem SolveSingleThread;
		private System.Windows.Forms.MenuItem SolveFourThreads;
		private System.Windows.Forms.MenuItem SolveEightThreads;
		private System.Windows.Forms.MenuItem Solve16Threads;
		private System.Windows.Forms.MenuItem mnuExit;
		private System.Windows.Forms.MenuItem menuItem4;
		private Maze TheMaze = null;
		private int threads = 0;
		private int threadCount = 0;
		private System.Windows.Forms.MenuItem SolveThreadPool;
		private DateTime startTime;

		public frmMaze()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			SetStyle(ControlStyles.AllPaintingInWmPaint,true);
			SetStyle(ControlStyles.UserPaint,true);
			SetStyle(ControlStyles.DoubleBuffer,true);

			this.Cursor = Cursors.WaitCursor;
			TheMaze = new Maze();
			TheMaze.Generate();
			TheMaze.MazeSolutionComplete += new Maze.MazeEventHandler(MazeComplete);
			this.Cursor = Cursors.Default;

			SetBounds(this.Left, this.Top, (Maze.kDimension + 8) * Cell.kCellSize + Cell.PADDING, (Maze.kDimension + 12) * Cell.kCellSize + Cell.PADDING + statusBar.Height );
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMaze));
			this.printDocument1 = new System.Drawing.Printing.PrintDocument();
			this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.DimensionsMenu = new System.Windows.Forms.MenuItem();
			this.SolveSingleThread = new System.Windows.Forms.MenuItem();
			this.SolveTwoThreads = new System.Windows.Forms.MenuItem();
			this.SolveFourThreads = new System.Windows.Forms.MenuItem();
			this.SolveEightThreads = new System.Windows.Forms.MenuItem();
			this.Solve16Threads = new System.Windows.Forms.MenuItem();
			this.ResetMenu = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.PrintMenu = new System.Windows.Forms.MenuItem();
			this.PreviewMenu = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.mnuExit = new System.Windows.Forms.MenuItem();
			this.statusBar = new System.Windows.Forms.StatusBar();
			this.SolveThreadPool = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// printDocument1
			// 
			this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
			// 
			// printPreviewDialog1
			// 
			this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
			this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
			this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
			this.printPreviewDialog1.Document = this.printDocument1;
			this.printPreviewDialog1.Enabled = true;
			this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
			this.printPreviewDialog1.Location = new System.Drawing.Point(148, 17);
			this.printPreviewDialog1.MaximumSize = new System.Drawing.Size(0, 0);
			this.printPreviewDialog1.Name = "printPreviewDialog1";
			this.printPreviewDialog1.Opacity = 1;
			this.printPreviewDialog1.TransparencyKey = System.Drawing.Color.Empty;
			this.printPreviewDialog1.Visible = false;
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.DimensionsMenu,
																					  this.SolveSingleThread,
																					  this.SolveTwoThreads,
																					  this.SolveFourThreads,
																					  this.SolveEightThreads,
																					  this.Solve16Threads,
																					  this.SolveThreadPool,
																					  this.ResetMenu,
																					  this.menuItem3,
																					  this.PrintMenu,
																					  this.PreviewMenu,
																					  this.menuItem4,
																					  this.mnuExit});
			this.menuItem1.Text = "File";
			// 
			// DimensionsMenu
			// 
			this.DimensionsMenu.Index = 0;
			this.DimensionsMenu.Text = "Generate New Maze...";
			this.DimensionsMenu.Click += new System.EventHandler(this.DimensionsMenu_Click);
			// 
			// SolveSingleThread
			// 
			this.SolveSingleThread.Index = 1;
			this.SolveSingleThread.Text = "Solve Single Thread";
			this.SolveSingleThread.Click += new System.EventHandler(this.SolveSingleThread_Click);
			// 
			// SolveTwoThreads
			// 
			this.SolveTwoThreads.Index = 2;
			this.SolveTwoThreads.Text = "Solve with 2 Threads";
			this.SolveTwoThreads.Click += new System.EventHandler(this.SolveTwoThreads_Click);
			// 
			// SolveFourThreads
			// 
			this.SolveFourThreads.Index = 3;
			this.SolveFourThreads.Text = "Solve with 4 Threads";
			this.SolveFourThreads.Click += new System.EventHandler(this.SolveFourThreads_Click);
			// 
			// SolveEightThreads
			// 
			this.SolveEightThreads.Index = 4;
			this.SolveEightThreads.Text = "Solve with 8 Threads";
			this.SolveEightThreads.Click += new System.EventHandler(this.SolveEightThreads_Click);
			// 
			// Solve16Threads
			// 
			this.Solve16Threads.Index = 5;
			this.Solve16Threads.Text = "Solve with 16 Threads";
			this.Solve16Threads.Click += new System.EventHandler(this.Solve16Threads_Click);
			// 
			// ResetMenu
			// 
			this.ResetMenu.Index = 7;
			this.ResetMenu.Text = "Reset Maze";
			this.ResetMenu.Click += new System.EventHandler(this.ResetMenu_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 8;
			this.menuItem3.Text = "-";
			// 
			// PrintMenu
			// 
			this.PrintMenu.Index = 9;
			this.PrintMenu.Text = "Print";
			this.PrintMenu.Click += new System.EventHandler(this.PrintMenu_Click);
			// 
			// PreviewMenu
			// 
			this.PreviewMenu.Index = 10;
			this.PreviewMenu.Text = "Print Preview...";
			this.PreviewMenu.Click += new System.EventHandler(this.PreviewMenu_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 11;
			this.menuItem4.Text = "-";
			// 
			// mnuExit
			// 
			this.mnuExit.Index = 12;
			this.mnuExit.Text = "Exit";
			this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
			// 
			// statusBar
			// 
			this.statusBar.Location = new System.Drawing.Point(0, 257);
			this.statusBar.Name = "statusBar";
			this.statusBar.Size = new System.Drawing.Size(360, 22);
			this.statusBar.TabIndex = 0;
			// 
			// SolveThreadPool
			// 
			this.SolveThreadPool.Index = 6;
			this.SolveThreadPool.Text = "Solve with Thread Pool";
			this.SolveThreadPool.Click += new System.EventHandler(this.SolveThreadPool_Click);
			// 
			// frmMaze
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(360, 279);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -