📄 form1.cs
字号:
using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
//Constants used to drive mouse selection events
public const int NONE = 0;
public const int CITY_BLOCK = 1;
public const int INTERSECTION = 2;
public const int CARS = 3;
public const int THRU_STREETS = 7;
public const int SELECT_BOX = 4;
public const int SELECT_LINE = 5;
public const int SELECT_POINT = 6;
private CityMap myMap;
private int to_Select = 0; //Variables that...
private int select_Type = 0; //...store constants above
private PointF select_Point_1; //For dragging lines and boxes
private bool Map_Loaded = false; //Boolean flags ensuring...
private bool Sim_Started = false; //...nothing is done out of order
private int ticks = 0; //How long a simulation has been running
private ArrayList myCars = new ArrayList(); //Cars being simulated
private ArrayList[] congestedInters; //Structure to store informatin for phase 2 of simulation
private string Sim_Events; //Basic (sample) storage method for results
#region Microsoft's Definitions
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.OpenFileDialog OpenDialog;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.PictureBox mapBox;
private System.Windows.Forms.Label countLbl;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.OpenFileDialog ImportDialog;
private System.Windows.Forms.SaveFileDialog SaveDialog;
private System.Windows.Forms.SaveFileDialog ExportDialog;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem CB_Box;
private System.Windows.Forms.MenuItem CB_Line;
private System.Windows.Forms.MenuItem I_Box;
private System.Windows.Forms.MenuItem I_Line;
private System.Windows.Forms.MenuItem I_Point;
private System.Windows.Forms.MenuItem CBs;
private System.Windows.Forms.MenuItem Inters;
private System.Windows.Forms.MenuItem CSVs;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.Label carCount;
private System.Windows.Forms.MenuItem SimGraphics;
private System.Windows.Forms.GroupBox legendBox;
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.MenuItem menuItem15;
private System.Windows.Forms.MenuItem menuItem16;
private System.Windows.Forms.MenuItem menuItem17;
private System.Windows.Forms.MenuItem menuItem18;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem20;
private System.Windows.Forms.MenuItem menuItem21;
private System.ComponentModel.IContainer components;
#endregion
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//SetStyle() calls setup double buffering.
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
myCars.Capacity = 1000;
}
/// <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()
{
this.components = new System.ComponentModel.Container();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.CSVs = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem21 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.SimGraphics = new System.Windows.Forms.MenuItem();
this.menuItem17 = new System.Windows.Forms.MenuItem();
this.menuItem20 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.CBs = new System.Windows.Forms.MenuItem();
this.CB_Box = new System.Windows.Forms.MenuItem();
this.CB_Line = new System.Windows.Forms.MenuItem();
this.Inters = new System.Windows.Forms.MenuItem();
this.I_Box = new System.Windows.Forms.MenuItem();
this.I_Line = new System.Windows.Forms.MenuItem();
this.I_Point = new System.Windows.Forms.MenuItem();
this.menuItem15 = new System.Windows.Forms.MenuItem();
this.menuItem18 = new System.Windows.Forms.MenuItem();
this.menuItem19 = new System.Windows.Forms.MenuItem();
this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.OpenDialog = new System.Windows.Forms.OpenFileDialog();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.mapBox = new System.Windows.Forms.PictureBox();
this.countLbl = new System.Windows.Forms.Label();
this.ImportDialog = new System.Windows.Forms.OpenFileDialog();
this.SaveDialog = new System.Windows.Forms.SaveFileDialog();
this.ExportDialog = new System.Windows.Forms.SaveFileDialog();
this.carCount = new System.Windows.Forms.Label();
this.legendBox = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.legendBox.SuspendLayout();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem8,
this.menuItem11});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem13,
this.menuItem6,
this.CSVs,
this.menuItem3});
this.menuItem1.Text = "&File";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "&Load Map";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem13
//
this.menuItem13.Index = 1;
this.menuItem13.Text = "&Close Map";
this.menuItem13.Click += new System.EventHandler(this.menuItem13_Click);
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Text = "&Save Map";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// CSVs
//
this.CSVs.Index = 3;
this.CSVs.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem5,
this.menuItem7});
this.CSVs.Text = "Import/Export";
//
// menuItem5
//
this.menuItem5.Index = 0;
this.menuItem5.Text = "&Import from CSV";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem7
//
this.menuItem7.Enabled = false;
this.menuItem7.Index = 1;
this.menuItem7.Text = "&Export to CSV";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem3
//
this.menuItem3.Index = 4;
this.menuItem3.Text = "E&xit";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem8
//
this.menuItem8.Index = 1;
this.menuItem8.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem9,
this.menuItem10,
this.menuItem21,
this.SimGraphics,
this.menuItem17,
this.menuItem20,
this.menuItem14});
this.menuItem8.Text = "Si&mulation";
//
// menuItem9
//
this.menuItem9.Index = 0;
this.menuItem9.Text = "&Start New Simulation";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem10
//
this.menuItem10.Index = 1;
this.menuItem10.Text = "&Pause";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
// menuItem21
//
this.menuItem21.Index = 2;
this.menuItem21.Text = "Terminate Simulation";
this.menuItem21.Click += new System.EventHandler(this.menuItem21_Click);
//
// menuItem14
//
this.menuItem14.Enabled = false;
this.menuItem14.Index = 6;
this.menuItem14.Text = "&View Events";
this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
//
// SimGraphics
//
this.SimGraphics.Checked = true;
this.SimGraphics.Index = 3;
this.SimGraphics.Text = "&Display Graphics";
this.SimGraphics.Click += new System.EventHandler(this.SimGraphics_Click);
//
// menuItem17
//
this.menuItem17.Index = 4;
this.menuItem17.Text = "Re-Randomi&ze Map";
this.menuItem17.Click += new System.EventHandler(this.menuItem17_Click);
//
// menuItem20
//
this.menuItem20.Index = 5;
this.menuItem20.Text = "&Restore Map";
this.menuItem20.Click += new System.EventHandler(this.menuItem20_Click);
//
// menuItem11
//
this.menuItem11.Index = 2;
this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.CBs,
this.Inters,
this.menuItem15,
this.menuItem4,
this.menuItem12});
this.menuItem11.Text = "&Tools";
//
// CBs
//
this.CBs.Index = 0;
this.CBs.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.CB_Box,
this.CB_Line});
this.CBs.Text = "Select City &Blocks";
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -