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

📄 form1.cs

📁 game implemented java
💻 CS
📖 第 1 页 / 共 3 页
字号:
			// CB_Box
			// 
			this.CB_Box.Index = 0;
			this.CB_Box.Text = "Using a &Box";
			this.CB_Box.Click += new System.EventHandler(this.CB_Box_Click);
			// 
			// CB_Line
			// 
			this.CB_Line.Index = 1;
			this.CB_Line.Text = "Using a &Line";
			this.CB_Line.Click += new System.EventHandler(this.CB_Line_Click);
			// 
			// Inters
			// 
			this.Inters.Index = 1;
			this.Inters.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.I_Box,
																				   this.I_Line,
																				   this.I_Point});
			this.Inters.Text = "Select &Intersections";
			// 
			// I_Box
			// 
			this.I_Box.Index = 0;
			this.I_Box.Text = "Using a &Box";
			this.I_Box.Click += new System.EventHandler(this.I_Box_Click);
			// 
			// I_Line
			// 
			this.I_Line.Index = 1;
			this.I_Line.Text = "Using a &Line";
			this.I_Line.Click += new System.EventHandler(this.I_Line_Click);
			// 
			// I_Point
			// 
			this.I_Point.Index = 2;
			this.I_Point.Text = "Using a &Point";
			this.I_Point.Click += new System.EventHandler(this.I_Point_Click);
			// 
			// menuItem15
			// 
			this.menuItem15.Index = 2;
			this.menuItem15.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.menuItem18,
																					   this.menuItem19,
																					   this.menuItem16});
			this.menuItem15.Text = "Set &Thru Streets";
			// 
			// menuItem18
			// 
			this.menuItem18.Index = 0;
			this.menuItem18.Text = "Using a &Box";
			this.menuItem18.Click += new System.EventHandler(this.menuItem18_Click);
			// 
			// menuItem19
			// 
			this.menuItem19.Index = 1;
			this.menuItem19.Text = "Using a &Line";
			this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
			// 
			// menuItem16
			// 
			this.menuItem16.Index = 2;
			this.menuItem16.Text = "Using a &Point";
			this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 3;
			this.menuItem4.Text = "&End Select";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// menuItem12
			// 
			this.menuItem12.Index = 4;
			this.menuItem12.Text = "Re&draw Map";
			this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
			// 
			// OpenDialog
			// 
			this.OpenDialog.DefaultExt = "fhb";
			this.OpenDialog.Filter = "CitySim Files|*.fhb";
			this.OpenDialog.Title = "Open file for CitySim";
			this.OpenDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.OpenDialog_FileOk);
			// 
			// timer1
			// 
			this.timer1.Interval = 50;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// mapBox
			// 
			this.mapBox.BackColor = System.Drawing.Color.Black;
			this.mapBox.Dock = System.Windows.Forms.DockStyle.Fill;
			this.mapBox.Location = new System.Drawing.Point(0, 0);
			this.mapBox.Name = "mapBox";
			this.mapBox.Size = new System.Drawing.Size(656, 377);
			this.mapBox.TabIndex = 0;
			this.mapBox.TabStop = false;
			this.mapBox.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
			this.mapBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mapBox_MouseUp);
			this.mapBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mapBox_MouseDown);
			// 
			// countLbl
			// 
			this.countLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.countLbl.BackColor = System.Drawing.Color.White;
			this.countLbl.Location = new System.Drawing.Point(608, 0);
			this.countLbl.Name = "countLbl";
			this.countLbl.Size = new System.Drawing.Size(48, 24);
			this.countLbl.TabIndex = 1;
			this.countLbl.Text = "###";
			this.countLbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// ImportDialog
			// 
			this.ImportDialog.DefaultExt = "csv";
			this.ImportDialog.Filter = "CSV Data Files|*.csv";
			this.ImportDialog.Title = "Import CSV file for CitySim";
			this.ImportDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.ImportDialog_FileOk);
			// 
			// SaveDialog
			// 
			this.SaveDialog.Filter = "CitySim Files|*.fhb";
			this.SaveDialog.Title = "Save Map";
			this.SaveDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.SaveDialog_FileOk);
			// 
			// ExportDialog
			// 
			this.ExportDialog.Filter = "CSV Data Files|*.csv";
			this.ExportDialog.Title = "Export Map into CSV format";
			// 
			// carCount
			// 
			this.carCount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.carCount.BackColor = System.Drawing.Color.White;
			this.carCount.Location = new System.Drawing.Point(608, 32);
			this.carCount.Name = "carCount";
			this.carCount.Size = new System.Drawing.Size(48, 24);
			this.carCount.TabIndex = 2;
			this.carCount.Text = "No Sim";
			this.carCount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// legendBox
			// 
			this.legendBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.legendBox.BackColor = System.Drawing.Color.White;
			this.legendBox.Controls.Add(this.label7);
			this.legendBox.Controls.Add(this.label8);
			this.legendBox.Controls.Add(this.label5);
			this.legendBox.Controls.Add(this.label6);
			this.legendBox.Controls.Add(this.label3);
			this.legendBox.Controls.Add(this.label4);
			this.legendBox.Controls.Add(this.label2);
			this.legendBox.Controls.Add(this.label1);
			this.legendBox.Location = new System.Drawing.Point(528, 264);
			this.legendBox.Name = "legendBox";
			this.legendBox.Size = new System.Drawing.Size(128, 112);
			this.legendBox.TabIndex = 3;
			this.legendBox.TabStop = false;
			this.legendBox.Text = "Legend";
			this.legendBox.Visible = false;
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(32, 88);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(88, 16);
			this.label7.TabIndex = 7;
			this.label7.Text = "More than 50%";
			this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label8
			// 
			this.label8.BackColor = System.Drawing.Color.Red;
			this.label8.Location = new System.Drawing.Point(8, 88);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(16, 16);
			this.label8.TabIndex = 6;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(32, 64);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(88, 16);
			this.label5.TabIndex = 5;
			this.label5.Text = "25 to 50%";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label6
			// 
			this.label6.BackColor = System.Drawing.Color.Green;
			this.label6.Location = new System.Drawing.Point(8, 64);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(16, 16);
			this.label6.TabIndex = 4;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(32, 40);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(88, 16);
			this.label3.TabIndex = 3;
			this.label3.Text = "10 to 25%";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.Color.Orange;
			this.label4.Location = new System.Drawing.Point(8, 40);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(16, 16);
			this.label4.TabIndex = 2;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 16);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(88, 16);
			this.label2.TabIndex = 1;
			this.label2.Text = "Less than 10%";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.LightGray;
			this.label1.Location = new System.Drawing.Point(8, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(16, 16);
			this.label1.TabIndex = 0;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(656, 377);
			this.Controls.Add(this.legendBox);
			this.Controls.Add(this.carCount);
			this.Controls.Add(this.countLbl);
			this.Controls.Add(this.mapBox);
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.Text = "Car Simulator";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.legendBox.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 Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{//Draws all graphics in one go because GDI+ does not support layering
		//Triggered by Invalidate(true) calls
			Graphics g = e.Graphics;
			g.Clear(Color.Black);
			legendBox.Visible = false;
			if (!SimGraphics.Checked && Sim_Started)
			{
				Font myFont = new Font("Times New Roman", 26);
				g.DrawString("Graphics Disabled",myFont,new SolidBrush(Color.White),0,0);
			}
			else if (!Sim_Started && ticks > 0)
			{
				myMap.scale.Height = mapBox.Size.Height;
				myMap.scale.Width = mapBox.Size.Width;
				myMap.scale.calculate();
				myMap.drawMap(g,true);
				legendBox.Visible = true;
			}
			else
			{
				if (Map_Loaded)
				{
					myMap.scale.Height = mapBox.Size.Height;
					myMap.scale.Width = mapBox.Size.Width;
					myMap.scale.calculate();
					myMap.drawMap(g,false);
					myMap.getIntersectionList.draw(g,myMap.scale,ticks);
				}
				if (Sim_Started)
				{
					//MessageBox.Show("Painting Cars: "+myCars.Count);
					for (int i=0; i <myCars.Count;i++)
					{
						((Car)myCars[i]).Draw(g, myMap.scale);
					}
				}
			}
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{//Handles each step of the simulation process
			ticks++;
			countLbl.Text = ticks.ToString("00000");

			if (myCars.Count == 0)
			{//Simulation is over
				timer1.Stop();
				MessageBox.Show("Simulation Complete");
				Sim_Started = false;
				Invalidate(true);
				return;
			}

			//drive cars around
			for (int i=0; i<myCars.Count; i++)

⌨️ 快捷键说明

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