📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 作业调度实验
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public System.Windows.Forms.Button button1;
public System.Windows.Forms.Button button2;
public System.Windows.Forms.Button button3;
public System.Windows.Forms.Button button4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.DataGrid RunGrid;
private System.Windows.Forms.DataGrid WaitGrid;
private System.Windows.Forms.DataGrid FinishGrid;
private DataTable RunTable = new DataTable("RunTable");
private DataTable WaitTable = new DataTable("WaitTable");
private DataTable FinishTable = new DataTable("FinishTable");
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioFCFS;
private System.Windows.Forms.RadioButton radioSJF;
private System.Windows.Forms.RadioButton radioHRN;
private System.Windows.Forms.Timer timer1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components;
public InputForm inputform=new InputForm();
private DataColumn RunTableColumn,WaitTableColumn,FinishTableColumn;
private DataRow RunTableRow,WaitTableRow,FinishTableRow;
public 全局变量 A=new 全局变量();
private Queue WaitQueue,FinishQueue = new Queue();
private Queue BackupQueue = new Queue();
private float SumPeriodTime,SumValuePeriod;
public JCB RunJCB =new JCB();
private System.Windows.Forms.Button button5;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private int ID;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
MakeRunTable();
MakeWaitTable();
MakeFinishTable();
A.TimeNowChanged += new TimeChangedEventHandler(NowTime_Changed);
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Make a Data Table code
public void MakeRunTable()
{
///Declare DataColumn and DataRow variables.
///Create new DataColumn, set DataType, ColumnName and add to DataTable.
RunTableColumn=new DataColumn();
RunTableColumn.DataType=typeof(int);
RunTableColumn.ColumnName = "ID";
RunTable.Columns.Add(RunTableColumn);
// Create second column.
RunTableColumn = new DataColumn();
RunTableColumn.DataType = typeof(string);
RunTableColumn.ColumnName = "作业名";
RunTable.Columns.Add(RunTableColumn);
// Create third column.
RunTableColumn = new DataColumn();
RunTableColumn.DataType = typeof(int);
RunTableColumn.ColumnName = "开始运行时刻";
RunTable.Columns.Add(RunTableColumn);
// Create forth column.
RunTableColumn = new DataColumn();
RunTableColumn.DataType = typeof(int);
RunTableColumn.ColumnName = "已运行的时间";
RunTable.Columns.Add(RunTableColumn);
// Create fifth column.
RunTableColumn = new DataColumn();
RunTableColumn.DataType = typeof(int);
RunTableColumn.ColumnName = "还需运行的时间";
RunTable.Columns.Add(RunTableColumn);
// Create sixth column.
RunTableColumn = new DataColumn();
RunTableColumn.DataType = typeof(char);
RunTableColumn.ColumnName = "所需资源";
RunTable.Columns.Add(RunTableColumn);
//Create seventh column.
RunTableColumn = new DataColumn();
RunTableColumn.DataType = typeof(char);
RunTableColumn.ColumnName = "状态";
RunTable.Columns.Add(RunTableColumn);
}
public void MakeWaitTable()
{
///Declare DataColumn and DataRow variables.
///Create new DataColumn, set DataType, ColumnName and add to DataTable.
WaitTableColumn=new DataColumn();
WaitTableColumn.DataType=typeof(int);
WaitTableColumn.ColumnName = "ID";
WaitTable.Columns.Add(WaitTableColumn);
// Create second column.
WaitTableColumn = new DataColumn();
WaitTableColumn.DataType = typeof(string);
WaitTableColumn.ColumnName = "作业名";
WaitTable.Columns.Add(WaitTableColumn);
// Create third column.
WaitTableColumn = new DataColumn();
WaitTableColumn.DataType = typeof(int);
WaitTableColumn.ColumnName = "提交时间";
WaitTable.Columns.Add(WaitTableColumn);
// Create forth column.
WaitTableColumn = new DataColumn();
WaitTableColumn.DataType = typeof(int);
WaitTableColumn.ColumnName = "需要的运行时间";
WaitTable.Columns.Add(WaitTableColumn);
// Create fifth column.
WaitTableColumn = new DataColumn();
WaitTableColumn.DataType = typeof(char);
WaitTableColumn.ColumnName = "所需资源";
WaitTable.Columns.Add(WaitTableColumn);
// Create sixth column.
WaitTableColumn = new DataColumn();
WaitTableColumn.DataType = typeof(char);
WaitTableColumn.ColumnName = "状态";
WaitTable.Columns.Add(WaitTableColumn);
}
public void MakeFinishTable()
{
///Declare DataColumn and DataRow variables.
///Create new DataColumn, set DataType, ColumnName and add to DataTable.
FinishTableColumn=new DataColumn();
FinishTableColumn.DataType=typeof(int);
FinishTableColumn.ColumnName = "ID";
FinishTable.Columns.Add(FinishTableColumn);
// Create second column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(string);
FinishTableColumn.ColumnName = "作业名";
FinishTable.Columns.Add(FinishTableColumn);
// Create third column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(int);
FinishTableColumn.ColumnName = "开始运行时刻";
FinishTable.Columns.Add(FinishTableColumn);
//Creat forth column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(int);
FinishTableColumn.ColumnName = "运行时间";
FinishTable.Columns.Add(FinishTableColumn);
// Create fifth column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(int);
FinishTableColumn.ColumnName = "完成时刻";
FinishTable.Columns.Add(FinishTableColumn);
// Create sixth column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(int);
FinishTableColumn.ColumnName = "周转时间";
FinishTable.Columns.Add(FinishTableColumn);
// Create seventh column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(float);
FinishTableColumn.ColumnName = "带权周转时间";
FinishTable.Columns.Add(FinishTableColumn);
// Create eighth column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(char);
FinishTableColumn.ColumnName = "所需资源";
FinishTable.Columns.Add(FinishTableColumn);
// Create ninth column.
FinishTableColumn = new DataColumn();
FinishTableColumn.DataType = typeof(char);
FinishTableColumn.ColumnName = "状态";
FinishTable.Columns.Add(FinishTableColumn);
}
#endregion
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.RunGrid = new System.Windows.Forms.DataGrid();
this.WaitGrid = new System.Windows.Forms.DataGrid();
this.FinishGrid = new System.Windows.Forms.DataGrid();
this.label1 = new System.Windows.Forms.Label();
this.radioFCFS = new System.Windows.Forms.RadioButton();
this.radioSJF = new System.Windows.Forms.RadioButton();
this.radioHRN = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.button5 = new System.Windows.Forms.Button();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
((System.ComponentModel.ISupportInitialize)(this.RunGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.WaitGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.FinishGrid)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Font = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.Location = new System.Drawing.Point(48, 168);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 32);
this.button1.TabIndex = 1;
this.button1.Text = "添加新作业";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Enabled = false;
this.button2.Font = new System.Drawing.Font("华文中宋", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.Location = new System.Drawing.Point(176, 168);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 32);
this.button2.TabIndex = 2;
this.button2.Text = "运行";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("华文中宋", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.Location = new System.Drawing.Point(312, 168);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 32);
this.button3.TabIndex = 3;
this.button3.Text = "清除";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Font = new System.Drawing.Font("华文中宋", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button4.Location = new System.Drawing.Point(448, 168);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 32);
this.button4.TabIndex = 4;
this.button4.Text = "退出";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// RunGrid
//
this.RunGrid.AllowSorting = false;
this.RunGrid.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.RunGrid.BackColor = System.Drawing.Color.GhostWhite;
this.RunGrid.BackgroundColor = System.Drawing.Color.Lavender;
this.RunGrid.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.RunGrid.CaptionFont = new System.Drawing.Font("华文中宋", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.RunGrid.CaptionForeColor = System.Drawing.Color.White;
this.RunGrid.CaptionText = "正在运行的作业";
this.RunGrid.DataMember = "";
this.RunGrid.FlatMode = true;
this.RunGrid.Font = new System.Drawing.Font("Arial Black", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.RunGrid.ForeColor = System.Drawing.Color.MidnightBlue;
this.RunGrid.GridLineColor = System.Drawing.Color.RoyalBlue;
this.RunGrid.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.RunGrid.HeaderFont = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.RunGrid.HeaderForeColor = System.Drawing.Color.Lavender;
this.RunGrid.LinkColor = System.Drawing.Color.Teal;
this.RunGrid.Location = new System.Drawing.Point(32, 32);
this.RunGrid.Name = "RunGrid";
this.RunGrid.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.RunGrid.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.RunGrid.PreferredColumnWidth = 71;
this.RunGrid.ReadOnly = true;
this.RunGrid.RowHeadersVisible = false;
this.RunGrid.SelectionBackColor = System.Drawing.Color.Teal;
this.RunGrid.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.RunGrid.Size = new System.Drawing.Size(501, 75);
this.RunGrid.TabIndex = 0;
this.RunGrid.TabStop = false;
//
// WaitGrid
//
this.WaitGrid.AllowSorting = false;
this.WaitGrid.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.WaitGrid.BackColor = System.Drawing.Color.GhostWhite;
this.WaitGrid.BackgroundColor = System.Drawing.Color.Lavender;
this.WaitGrid.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.WaitGrid.CaptionFont = new System.Drawing.Font("华文中宋", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.WaitGrid.CaptionForeColor = System.Drawing.Color.White;
this.WaitGrid.CaptionText = "就绪作业队列";
this.WaitGrid.DataMember = "";
this.WaitGrid.FlatMode = true;
this.WaitGrid.Font = new System.Drawing.Font("Arial Black", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.WaitGrid.ForeColor = System.Drawing.Color.MidnightBlue;
this.WaitGrid.GridLineColor = System.Drawing.Color.RoyalBlue;
this.WaitGrid.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.WaitGrid.HeaderFont = new System.Drawing.Font("华文中宋", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.WaitGrid.HeaderForeColor = System.Drawing.Color.Lavender;
this.WaitGrid.LinkColor = System.Drawing.Color.Teal;
this.WaitGrid.Location = new System.Drawing.Point(32, 208);
this.WaitGrid.Name = "WaitGrid";
this.WaitGrid.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.WaitGrid.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.WaitGrid.PreferredColumnWidth = 83;
this.WaitGrid.ReadOnly = true;
this.WaitGrid.RowHeadersVisible = false;
this.WaitGrid.SelectionBackColor = System.Drawing.Color.Teal;
this.WaitGrid.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.WaitGrid.Size = new System.Drawing.Size(502, 200);
this.WaitGrid.TabIndex = 0;
this.WaitGrid.TabStop = false;
//
// FinishGrid
//
this.FinishGrid.AllowSorting = false;
this.FinishGrid.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.FinishGrid.BackColor = System.Drawing.Color.GhostWhite;
this.FinishGrid.BackgroundColor = System.Drawing.Color.Lavender;
this.FinishGrid.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.FinishGrid.CaptionFont = new System.Drawing.Font("华文中宋", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.FinishGrid.CaptionForeColor = System.Drawing.Color.White;
this.FinishGrid.CaptionText = "已完成的作业";
this.FinishGrid.DataMember = "";
this.FinishGrid.FlatMode = true;
this.FinishGrid.Font = new System.Drawing.Font("Arial Black", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.FinishGrid.ForeColor = System.Drawing.Color.MidnightBlue;
this.FinishGrid.GridLineColor = System.Drawing.Color.RoyalBlue;
this.FinishGrid.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.FinishGrid.HeaderFont = new System.Drawing.Font("华文中宋", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.FinishGrid.HeaderForeColor = System.Drawing.Color.Lavender;
this.FinishGrid.LinkColor = System.Drawing.Color.Teal;
this.FinishGrid.Location = new System.Drawing.Point(32, 424);
this.FinishGrid.Name = "FinishGrid";
this.FinishGrid.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.FinishGrid.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.FinishGrid.PreferredColumnWidth = 55;
this.FinishGrid.ReadOnly = true;
this.FinishGrid.RowHeadersVisible = false;
this.FinishGrid.SelectionBackColor = System.Drawing.Color.Teal;
this.FinishGrid.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.FinishGrid.Size = new System.Drawing.Size(499, 200);
this.FinishGrid.TabIndex = 0;
this.FinishGrid.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("华文中宋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(32, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 22);
this.label1.TabIndex = 7;
this.label1.Text = "当前时刻:";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// radioFCFS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -