📄 city_blocks.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication2
{
/// <summary>
/// Allows an arbitrary number of city blocks to be modified at once
/// </summary>
public class City_Blocks : System.Windows.Forms.Form
{
private System.Windows.Forms.Button acceptor;
private ArrayList myBlocks;
private CityMap myMap;
private System.Windows.Forms.Label infoDisplay;
private System.Windows.Forms.ListBox BlockListBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button remover;
private System.Windows.Forms.Button canceler;
private System.Windows.Forms.Panel ToDo;
private System.Windows.Forms.TrackBar LanesFT;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lanelblFT;
private System.Windows.Forms.Label lanelblTF;
private System.Windows.Forms.TrackBar LanesTF;
private System.Windows.Forms.Label lblspeed;
private System.Windows.Forms.TrackBar SpeedBar;
private System.Windows.Forms.CheckBox LaneFTcbox;
private System.Windows.Forms.Label lblStreetName;
private System.Windows.Forms.TextBox StreetName;
private System.Windows.Forms.CheckBox LaneTFcbox;
private System.Windows.Forms.CheckBox SpeedLimitcbox;
private System.Windows.Forms.CheckBox StreetNamecbox;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public City_Blocks(ArrayList BlockIDs, CityMap oldMap)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
myBlocks = BlockIDs;
myMap = oldMap;
for (int i=0; i<myBlocks.Count;i++)
{
BlockListBox.Items.Add(myBlocks[i]);
}
}
/// <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.acceptor = new System.Windows.Forms.Button();
this.infoDisplay = new System.Windows.Forms.Label();
this.BlockListBox = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.remover = new System.Windows.Forms.Button();
this.canceler = new System.Windows.Forms.Button();
this.ToDo = new System.Windows.Forms.Panel();
this.StreetNamecbox = new System.Windows.Forms.CheckBox();
this.SpeedLimitcbox = new System.Windows.Forms.CheckBox();
this.LaneTFcbox = new System.Windows.Forms.CheckBox();
this.StreetName = new System.Windows.Forms.TextBox();
this.lblStreetName = new System.Windows.Forms.Label();
this.LaneFTcbox = new System.Windows.Forms.CheckBox();
this.lblspeed = new System.Windows.Forms.Label();
this.SpeedBar = new System.Windows.Forms.TrackBar();
this.lanelblTF = new System.Windows.Forms.Label();
this.LanesTF = new System.Windows.Forms.TrackBar();
this.lanelblFT = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.LanesFT = new System.Windows.Forms.TrackBar();
this.ToDo.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.SpeedBar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.LanesTF)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.LanesFT)).BeginInit();
this.SuspendLayout();
//
// acceptor
//
this.acceptor.Location = new System.Drawing.Point(248, 432);
this.acceptor.Name = "acceptor";
this.acceptor.Size = new System.Drawing.Size(96, 32);
this.acceptor.TabIndex = 1;
this.acceptor.Text = "Ok";
this.acceptor.Click += new System.EventHandler(this.acceptor_Click);
//
// infoDisplay
//
this.infoDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.infoDisplay.Location = new System.Drawing.Point(24, 264);
this.infoDisplay.Name = "infoDisplay";
this.infoDisplay.Size = new System.Drawing.Size(200, 200);
this.infoDisplay.TabIndex = 4;
this.infoDisplay.Text = "Specific block information appears here";
//
// BlockListBox
//
this.BlockListBox.Location = new System.Drawing.Point(24, 48);
this.BlockListBox.Name = "BlockListBox";
this.BlockListBox.Size = new System.Drawing.Size(200, 199);
this.BlockListBox.TabIndex = 5;
this.BlockListBox.SelectedValueChanged += new System.EventHandler(this.BlockListBox_SelectedValueChanged);
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(24, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(400, 24);
this.label1.TabIndex = 6;
this.label1.Text = "Change Map Segment Properties";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// remover
//
this.remover.Location = new System.Drawing.Point(232, 48);
this.remover.Name = "remover";
this.remover.Size = new System.Drawing.Size(208, 32);
this.remover.TabIndex = 7;
this.remover.Text = "Remove selected Map Segment from this update";
this.remover.Click += new System.EventHandler(this.remover_Click);
//
// canceler
//
this.canceler.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.canceler.Location = new System.Drawing.Point(360, 432);
this.canceler.Name = "canceler";
this.canceler.Size = new System.Drawing.Size(80, 32);
this.canceler.TabIndex = 8;
this.canceler.Text = "Cancel";
this.canceler.Click += new System.EventHandler(this.canceler_Click);
//
// ToDo
//
this.ToDo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.ToDo.Controls.Add(this.StreetNamecbox);
this.ToDo.Controls.Add(this.SpeedLimitcbox);
this.ToDo.Controls.Add(this.LaneTFcbox);
this.ToDo.Controls.Add(this.StreetName);
this.ToDo.Controls.Add(this.lblStreetName);
this.ToDo.Controls.Add(this.LaneFTcbox);
this.ToDo.Controls.Add(this.lblspeed);
this.ToDo.Controls.Add(this.SpeedBar);
this.ToDo.Controls.Add(this.lanelblTF);
this.ToDo.Controls.Add(this.LanesTF);
this.ToDo.Controls.Add(this.lanelblFT);
this.ToDo.Controls.Add(this.label2);
this.ToDo.Controls.Add(this.LanesFT);
this.ToDo.Location = new System.Drawing.Point(232, 96);
this.ToDo.Name = "ToDo";
this.ToDo.Size = new System.Drawing.Size(208, 320);
this.ToDo.TabIndex = 10;
//
// StreetNamecbox
//
this.StreetNamecbox.Checked = true;
this.StreetNamecbox.CheckState = System.Windows.Forms.CheckState.Checked;
this.StreetNamecbox.Location = new System.Drawing.Point(32, 288);
this.StreetNamecbox.Name = "StreetNamecbox";
this.StreetNamecbox.Size = new System.Drawing.Size(152, 16);
this.StreetNamecbox.TabIndex = 22;
this.StreetNamecbox.Text = "Do Not Change this value";
//
// SpeedLimitcbox
//
this.SpeedLimitcbox.Checked = true;
this.SpeedLimitcbox.CheckState = System.Windows.Forms.CheckState.Checked;
this.SpeedLimitcbox.Location = new System.Drawing.Point(32, 224);
this.SpeedLimitcbox.Name = "SpeedLimitcbox";
this.SpeedLimitcbox.Size = new System.Drawing.Size(152, 16);
this.SpeedLimitcbox.TabIndex = 21;
this.SpeedLimitcbox.Text = "Do Not Change this value";
//
// LaneTFcbox
//
this.LaneTFcbox.Checked = true;
this.LaneTFcbox.CheckState = System.Windows.Forms.CheckState.Checked;
this.LaneTFcbox.Location = new System.Drawing.Point(27, 151);
this.LaneTFcbox.Name = "LaneTFcbox";
this.LaneTFcbox.Size = new System.Drawing.Size(152, 16);
this.LaneTFcbox.TabIndex = 20;
this.LaneTFcbox.Text = "Do Not Change this value";
//
// StreetName
//
this.StreetName.Location = new System.Drawing.Point(96, 256);
this.StreetName.Name = "StreetName";
this.StreetName.Size = new System.Drawing.Size(104, 20);
this.StreetName.TabIndex = 19;
this.StreetName.Text = "";
//
// lblStreetName
//
this.lblStreetName.Location = new System.Drawing.Point(0, 248);
this.lblStreetName.Name = "lblStreetName";
this.lblStreetName.Size = new System.Drawing.Size(96, 40);
this.lblStreetName.TabIndex = 18;
this.lblStreetName.Text = "Street Name";
this.lblStreetName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// LaneFTcbox
//
this.LaneFTcbox.Checked = true;
this.LaneFTcbox.CheckState = System.Windows.Forms.CheckState.Checked;
this.LaneFTcbox.Location = new System.Drawing.Point(32, 80);
this.LaneFTcbox.Name = "LaneFTcbox";
this.LaneFTcbox.Size = new System.Drawing.Size(152, 16);
this.LaneFTcbox.TabIndex = 17;
this.LaneFTcbox.Text = "Do Not Change this value";
//
// lblspeed
//
this.lblspeed.Location = new System.Drawing.Point(0, 176);
this.lblspeed.Name = "lblspeed";
this.lblspeed.Size = new System.Drawing.Size(96, 48);
this.lblspeed.TabIndex = 16;
this.lblspeed.Text = "Speed Limit";
this.lblspeed.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// SpeedBar
//
this.SpeedBar.LargeChange = 10;
this.SpeedBar.Location = new System.Drawing.Point(96, 176);
this.SpeedBar.Maximum = 50;
this.SpeedBar.Minimum = 5;
this.SpeedBar.Name = "SpeedBar";
this.SpeedBar.Size = new System.Drawing.Size(112, 45);
this.SpeedBar.TabIndex = 15;
this.SpeedBar.TickFrequency = 5;
this.SpeedBar.Value = 5;
//
// lanelblTF
//
this.lanelblTF.Location = new System.Drawing.Point(0, 104);
this.lanelblTF.Name = "lanelblTF";
this.lanelblTF.Size = new System.Drawing.Size(96, 48);
this.lanelblTF.TabIndex = 14;
this.lanelblTF.Text = "Number of Lanes (To-> From)";
this.lanelblTF.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// LanesTF
//
this.LanesTF.Location = new System.Drawing.Point(96, 104);
this.LanesTF.Maximum = 5;
this.LanesTF.Name = "LanesTF";
this.LanesTF.Size = new System.Drawing.Size(112, 45);
this.LanesTF.TabIndex = 13;
//
// lanelblFT
//
this.lanelblFT.Location = new System.Drawing.Point(0, 32);
this.lanelblFT.Name = "lanelblFT";
this.lanelblFT.Size = new System.Drawing.Size(96, 48);
this.lanelblFT.TabIndex = 12;
this.lanelblFT.Text = "Number of Lanes (From -> To)";
this.lanelblFT.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(0, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(208, 32);
this.label2.TabIndex = 11;
this.label2.Text = "Changes to make to ALL selected segments";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// LanesFT
//
this.LanesFT.Location = new System.Drawing.Point(96, 32);
this.LanesFT.Maximum = 5;
this.LanesFT.Name = "LanesFT";
this.LanesFT.Size = new System.Drawing.Size(112, 45);
this.LanesFT.TabIndex = 10;
//
// City_Blocks
//
this.AcceptButton = this.acceptor;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.canceler;
this.ClientSize = new System.Drawing.Size(456, 470);
this.Controls.Add(this.ToDo);
this.Controls.Add(this.canceler);
this.Controls.Add(this.remover);
this.Controls.Add(this.label1);
this.Controls.Add(this.BlockListBox);
this.Controls.Add(this.infoDisplay);
this.Controls.Add(this.acceptor);
this.Name = "City_Blocks";
this.ShowInTaskbar = false;
this.Text = "Change City Blocks";
this.ToDo.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.SpeedBar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.LanesTF)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.LanesFT)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void acceptor_Click(object sender, System.EventArgs e)
{
for (int i=0; i<myBlocks.Count;i++)
{
int idx = (int)myBlocks[i];
if (!LaneFTcbox.Checked){myMap.getSegment(idx).LaneCount = LanesFT.Value;}
if (!LaneTFcbox.Checked){myMap.getSegment(idx).LaneCount_Reversed = LanesTF.Value;}
if (!SpeedLimitcbox.Checked){myMap.getSegment(idx).SpeedLimit = SpeedBar.Value;}
if (!StreetNamecbox.Checked){myMap.getSegment(idx).StreetName = StreetName.Text;}
}
this.Close();
}
private void BlockListBox_SelectedValueChanged(object sender, System.EventArgs e)
{
int idToFind = (int)BlockListBox.SelectedItem;
infoDisplay.Text = myMap.getSegment(idToFind).Report_Info();
}
private void remover_Click(object sender, System.EventArgs e)
{
try
{
int idToFind = (int)BlockListBox.SelectedItem;
myBlocks.Remove(idToFind);
BlockListBox.Items.Clear();
for (int i=0; i<myBlocks.Count;i++)
BlockListBox.Items.Add(myBlocks[i]);
}
catch{MessageBox.Show("You must select a Map Segment to remove");}
}
private void canceler_Click(object sender, System.EventArgs e)
{
this.Close();
}
public CityMap getMap
{
get{return myMap;}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -