📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
namespace WindowsApplication6
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel pnlResult;
private System.Windows.Forms.Button btnTextOut;
private System.Windows.Forms.Button btnBack;
private System.Windows.Forms.OpenFileDialog ofiledlg;
private System.Windows.Forms.SaveFileDialog sfiledlg;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox txtResult;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtAdd;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnLoadTask;
private System.Windows.Forms.Button btnSaveTask;
private System.Windows.Forms.Button btnCleanTask;
private System.Windows.Forms.ListBox lstTask;
private System.Windows.Forms.Panel pnlTask;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label lblFormat;
private System.Windows.Forms.Button btnCompute;
int lNum;
public frmMain()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.pnlResult = new System.Windows.Forms.Panel();
this.btnBack = new System.Windows.Forms.Button();
this.btnTextOut = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.txtResult = new System.Windows.Forms.TextBox();
this.ofiledlg = new System.Windows.Forms.OpenFileDialog();
this.sfiledlg = new System.Windows.Forms.SaveFileDialog();
this.pnlTask = new System.Windows.Forms.Panel();
this.btnCompute = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnLoadTask = new System.Windows.Forms.Button();
this.btnSaveTask = new System.Windows.Forms.Button();
this.btnCleanTask = new System.Windows.Forms.Button();
this.lstTask = new System.Windows.Forms.ListBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnAdd = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.lblFormat = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtAdd = new System.Windows.Forms.TextBox();
this.pnlResult.SuspendLayout();
this.groupBox4.SuspendLayout();
this.pnlTask.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// pnlResult
//
this.pnlResult.Controls.Add(this.btnBack);
this.pnlResult.Controls.Add(this.btnTextOut);
this.pnlResult.Controls.Add(this.groupBox4);
this.pnlResult.Location = new System.Drawing.Point(8, 8);
this.pnlResult.Name = "pnlResult";
this.pnlResult.Size = new System.Drawing.Size(488, 400);
this.pnlResult.TabIndex = 8;
this.pnlResult.Visible = false;
//
// btnBack
//
this.btnBack.Location = new System.Drawing.Point(400, 360);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(72, 24);
this.btnBack.TabIndex = 2;
this.btnBack.Text = "返回(&B)";
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
//
// btnTextOut
//
this.btnTextOut.Location = new System.Drawing.Point(256, 360);
this.btnTextOut.Name = "btnTextOut";
this.btnTextOut.Size = new System.Drawing.Size(128, 24);
this.btnTextOut.TabIndex = 1;
this.btnTextOut.Text = "输出结果到文本(&O)";
this.btnTextOut.Click += new System.EventHandler(this.btnTextOut_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.txtResult);
this.groupBox4.Location = new System.Drawing.Point(16, 16);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(456, 336);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "计算结果:";
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(8, 24);
this.txtResult.Multiline = true;
this.txtResult.Name = "txtResult";
this.txtResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtResult.Size = new System.Drawing.Size(440, 304);
this.txtResult.TabIndex = 1;
this.txtResult.Text = "";
//
// ofiledlg
//
this.ofiledlg.Filter = "文本文件 (*.txt)|*.txt";
//
// sfiledlg
//
this.sfiledlg.Filter = "文本文件 (*.txt)|*.txt";
//
// pnlTask
//
this.pnlTask.Controls.Add(this.btnCompute);
this.pnlTask.Controls.Add(this.groupBox2);
this.pnlTask.Controls.Add(this.groupBox1);
this.pnlTask.Location = new System.Drawing.Point(8, 8);
this.pnlTask.Name = "pnlTask";
this.pnlTask.Size = new System.Drawing.Size(488, 400);
this.pnlTask.TabIndex = 9;
//
// btnCompute
//
this.btnCompute.Location = new System.Drawing.Point(392, 368);
this.btnCompute.Name = "btnCompute";
this.btnCompute.Size = new System.Drawing.Size(80, 24);
this.btnCompute.TabIndex = 11;
this.btnCompute.Text = "计算(&R)";
this.btnCompute.Click += new System.EventHandler(this.btnCompute_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnLoadTask);
this.groupBox2.Controls.Add(this.btnSaveTask);
this.groupBox2.Controls.Add(this.btnCleanTask);
this.groupBox2.Controls.Add(this.lstTask);
this.groupBox2.Location = new System.Drawing.Point(8, 120);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(464, 232);
this.groupBox2.TabIndex = 7;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "作业列表";
//
// btnLoadTask
//
this.btnLoadTask.Location = new System.Drawing.Point(384, 112);
this.btnLoadTask.Name = "btnLoadTask";
this.btnLoadTask.Size = new System.Drawing.Size(64, 24);
this.btnLoadTask.TabIndex = 4;
this.btnLoadTask.Text = "读取(&L)";
this.btnLoadTask.Click += new System.EventHandler(this.btnLoadTask_Click);
//
// btnSaveTask
//
this.btnSaveTask.Location = new System.Drawing.Point(384, 80);
this.btnSaveTask.Name = "btnSaveTask";
this.btnSaveTask.Size = new System.Drawing.Size(64, 24);
this.btnSaveTask.TabIndex = 3;
this.btnSaveTask.Text = "保存(&S)";
this.btnSaveTask.Click += new System.EventHandler(this.btnSaveTask_Click);
//
// btnCleanTask
//
this.btnCleanTask.Location = new System.Drawing.Point(384, 48);
this.btnCleanTask.Name = "btnCleanTask";
this.btnCleanTask.Size = new System.Drawing.Size(64, 24);
this.btnCleanTask.TabIndex = 2;
this.btnCleanTask.Text = "清空(&C)";
this.btnCleanTask.Click += new System.EventHandler(this.btnCleanTask_Click);
//
// lstTask
//
this.lstTask.ItemHeight = 12;
this.lstTask.Location = new System.Drawing.Point(16, 24);
this.lstTask.Name = "lstTask";
this.lstTask.Size = new System.Drawing.Size(352, 184);
this.lstTask.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnAdd);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.lblFormat);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.txtAdd);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(464, 104);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "添加作业";
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(384, 24);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(64, 24);
this.btnAdd.TabIndex = 9;
this.btnAdd.Text = "添加(&A)";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(16, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(301, 17);
this.label3.TabIndex = 8;
this.label3.Text = "提交时间:XXYY XX是时,YY是分 预计运行时间:分钟";
//
// lblFormat
//
this.lblFormat.AutoSize = true;
this.lblFormat.Location = new System.Drawing.Point(16, 56);
this.lblFormat.Name = "lblFormat";
this.lblFormat.Size = new System.Drawing.Size(258, 17);
this.lblFormat.TabIndex = 7;
this.lblFormat.Text = "格式: 作业名称(提交时间:预计运行时间)";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 17);
this.label1.TabIndex = 6;
this.label1.Text = "添加作业:";
//
// txtAdd
//
this.txtAdd.Location = new System.Drawing.Point(80, 24);
this.txtAdd.Name = "txtAdd";
this.txtAdd.Size = new System.Drawing.Size(296, 21);
this.txtAdd.TabIndex = 5;
this.txtAdd.Text = "";
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(504, 413);
this.Controls.Add(this.pnlTask);
this.Controls.Add(this.pnlResult);
this.MaximizeBox = false;
this.Name = "frmMain";
this.Text = "多批道处理作业调度模拟程序(by shootsoft@qq.com)";
this.Load += new System.EventHandler(this.Form1_Load);
this.pnlResult.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.pnlTask.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}
# region 清空任务列表
private void btnCleanTask_Click(object sender, System.EventArgs e)
{
lstTask.Items.Clear();
}
#endregion
# region 保存任务列表
private void btnSaveTask_Click(object sender, System.EventArgs e)
{
sfiledlg.ShowDialog();
if(sfiledlg.FileName!="")
{
using (StreamWriter sw = new StreamWriter(sfiledlg.FileName))
{
sw.WriteLine("多批道处理作业调度模拟程序作业列表文件.");
for(int i=0 ; i<lstTask.Items.Count ; i++)
{
sw.WriteLine(lstTask.Items[i].ToString());
}//for
sw.Close();
}//using
}
}
#endregion
# region 添加任务
private void btnAdd_Click(object sender, System.EventArgs e)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -