📄 inputform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 作业调度实验
{
/// <summary>
/// InputForm 的摘要说明。
/// </summary>
public class InputForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button buttonFinish;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonNext;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label4;
public System.Windows.Forms.Label label5;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private JCB j = new JCB();
public Queue queue = new Queue();
public int num=1;
public InputForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.buttonFinish = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonNext = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("华文中宋", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(101, 19);
this.label1.TabIndex = 0;
this.label1.Text = "输入作业n信息";
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox1.Location = new System.Drawing.Point(24, 56);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(152, 23);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// buttonFinish
//
this.buttonFinish.Font = new System.Drawing.Font("华文中宋", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.buttonFinish.Location = new System.Drawing.Point(24, 96);
this.buttonFinish.Name = "buttonFinish";
this.buttonFinish.Size = new System.Drawing.Size(80, 32);
this.buttonFinish.TabIndex = 5;
this.buttonFinish.Text = "输入完成";
this.buttonFinish.Click += new System.EventHandler(this.buttonFinish_Click);
//
// buttonCancel
//
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Font = new System.Drawing.Font("华文中宋", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.buttonCancel.Location = new System.Drawing.Point(256, 96);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(80, 32);
this.buttonCancel.TabIndex = 6;
this.buttonCancel.Text = "取消";
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonNext
//
this.buttonNext.Font = new System.Drawing.Font("华文中宋", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.buttonNext.Location = new System.Drawing.Point(144, 96);
this.buttonNext.Name = "buttonNext";
this.buttonNext.Size = new System.Drawing.Size(80, 32);
this.buttonNext.TabIndex = 4;
this.buttonNext.Text = "提交";
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox1.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20"});
this.comboBox1.Location = new System.Drawing.Point(192, 56);
this.comboBox1.MaxDropDownItems = 20;
this.comboBox1.MaxLength = 2;
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(88, 22);
this.comboBox1.TabIndex = 2;
this.comboBox1.Tag = "";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(24, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(54, 16);
this.label2.TabIndex = 10;
this.label2.Text = "作业名称";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.Location = new System.Drawing.Point(192, 40);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(91, 16);
this.label3.TabIndex = 11;
this.label3.Text = "需要的运行时间";
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox2.ItemHeight = 14;
this.comboBox2.Items.AddRange(new object[] {
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z"});
this.comboBox2.Location = new System.Drawing.Point(296, 56);
this.comboBox2.MaxDropDownItems = 20;
this.comboBox2.MaxLength = 2;
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(48, 22);
this.comboBox2.TabIndex = 3;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.Location = new System.Drawing.Point(296, 40);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(66, 16);
this.label4.TabIndex = 12;
this.label4.Text = "所需的资源";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("华文中宋", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.Location = new System.Drawing.Point(192, 16);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(101, 19);
this.label5.TabIndex = 13;
this.label5.Text = "当前的时刻:T";
//
// InputForm
//
this.AcceptButton = this.buttonNext;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(386, 149);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label5,
this.label4,
this.label3,
this.label2,
this.comboBox2,
this.comboBox1,
this.buttonNext,
this.buttonCancel,
this.buttonFinish,
this.textBox1,
this.label1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InputForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultBounds;
this.Text = "输入作业信息";
this.Load += new System.EventHandler(this.InputForm_Load);
this.ResumeLayout(false);
}
#endregion
private void InputForm_Load(object sender, System.EventArgs e)
{
Form1 OwnerForm=(Form1)this.Owner;
this.Height=184;this.Width=380;
label1.Text="输入作业"+this.num.ToString()+"的信息";
label5.Text="当前时刻:"+OwnerForm.A.NowTime.ToString();
}
private void buttonFinish_Click(object sender, System.EventArgs e)
{
if(textBox1.Text!="" && comboBox1.Text!="" && comboBox2.Text!="")
{
Form1 OwnerForm = (Form1)this.Owner;
this.input();
this.Hide();
textBox1.Text=null;comboBox1.Text=null;comboBox2.Text=null;
num++;
label1.Text="输入作业"+this.num.ToString()+"的信息";
OwnerForm.button2.Enabled=true;
OwnerForm.Run();
}
else if(textBox1.Text=="" && comboBox1.Text=="" && comboBox2.Text=="")
{
Form1 OwnerForm = (Form1)this.Owner;
OwnerForm.button1.Enabled=true;
OwnerForm.button2.Enabled=true;
this.Hide();
textBox1.Text=null;comboBox1.Text=null;comboBox2.Text=null;
}
else if(textBox1.Text=="")
{
MessageBox.Show("请输入作业名","您的输入有误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else if(comboBox1.Text!="")
{
MessageBox.Show("请选择需要运行的时间","您的输入有误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else if(comboBox2.Text!="")
{
MessageBox.Show("请选择作业所需资源","您的输入有误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void buttonNext_Click(object sender, System.EventArgs e)
{
if(textBox1.Text!=null && comboBox1.Text!="" && comboBox2.Text!="")
{
input();
textBox1.Text=null;comboBox1.Text=null;comboBox2.Text=null;
num++;
label1.Text="输入作业"+this.num.ToString()+"的信息";
Form1 OwnerForm=(Form1)this.Owner;
OwnerForm.Run();
}
else if(textBox1.Text=="")
{
MessageBox.Show("请输入作业名","您的输入有误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else if(comboBox1.Text=="")
{
MessageBox.Show("请选择需要运行的时间","您的输入有误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else
{
MessageBox.Show("请选择作业所需资源","您的输入有误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, System.EventArgs e)
{
Form1 OwnerForm = (Form1)this.Owner;
OwnerForm.button1.Enabled=true;
this.Hide();
textBox1.Text=null;comboBox1.Text=null;comboBox2.Text=null;
}
void input() /*输入信息*/
{
Form1 OwnerForm = (Form1)this.Owner;
j.name=textBox1.Text;
j.RunTime=Convert.ToInt32(comboBox1.SelectedItem);
j.NeedTime=j.RunTime;
j.ReferTime=this.num;
j.NeedSource=Convert.ToChar(comboBox2.SelectedItem);
j.state='W';
queue.Enqueue(j);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -