📄 simulation_setup.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication2
{
/// <summary>
/// Allows the user to select how many cars it include in the simulation
/// </summary>
public class Simulation_Setup : System.Windows.Forms.Form
{
private int theValue;
private bool isOk;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TrackBar SimValue;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button noButton;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Simulation_Setup(int MaxValue)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
SimValue.Maximum = MaxValue;
theValue = SimValue.Value;
isOk = false;
}
/// <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.label1 = new System.Windows.Forms.Label();
this.SimValue = new System.Windows.Forms.TrackBar();
this.label2 = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.noButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.SimValue)).BeginInit();
this.SuspendLayout();
//
// 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(8, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(280, 32);
this.label1.TabIndex = 0;
this.label1.Text = "How many cars would you like to simulate?";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// SimValue
//
this.SimValue.LargeChange = 1000;
this.SimValue.Location = new System.Drawing.Point(24, 48);
this.SimValue.Maximum = 10000;
this.SimValue.Minimum = 1;
this.SimValue.Name = "SimValue";
this.SimValue.Size = new System.Drawing.Size(192, 45);
this.SimValue.SmallChange = 100;
this.SimValue.TabIndex = 1;
this.SimValue.TickFrequency = 500;
this.SimValue.Value = 1000;
this.SimValue.Scroll += new System.EventHandler(this.SimValue_Scroll);
//
// label2
//
this.label2.Location = new System.Drawing.Point(224, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 48);
this.label2.TabIndex = 2;
this.label2.Text = "1000";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// okButton
//
this.okButton.Location = new System.Drawing.Point(40, 104);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(96, 24);
this.okButton.TabIndex = 3;
this.okButton.Text = "START";
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// noButton
//
this.noButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.noButton.Location = new System.Drawing.Point(160, 104);
this.noButton.Name = "noButton";
this.noButton.Size = new System.Drawing.Size(96, 24);
this.noButton.TabIndex = 4;
this.noButton.Text = "CANCEL";
this.noButton.Click += new System.EventHandler(this.noButton_Click);
//
// Simulation_Setup
//
this.AcceptButton = this.okButton;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.noButton;
this.ClientSize = new System.Drawing.Size(292, 134);
this.ControlBox = false;
this.Controls.Add(this.noButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.SimValue);
this.Controls.Add(this.label1);
this.Name = "Simulation_Setup";
this.ShowInTaskbar = false;
this.Text = "Choose number of cars";
((System.ComponentModel.ISupportInitialize)(this.SimValue)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void SimValue_Scroll(object sender, System.EventArgs e)
{
theValue = SimValue.Value;
label2.Text = theValue.ToString();
}
private void okButton_Click(object sender, System.EventArgs e)
{
isOk = true;
this.Close();
}
private void noButton_Click(object sender, System.EventArgs e)
{
this.Close();
}
public int Value
{
get
{
if (isOk)
return theValue;
else
return -1;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -