?? mainform.cs
字號:
//
// listViewRawData
//
this.listViewRawData.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewRawData.Name = "listViewRawData";
this.listViewRawData.Size = new System.Drawing.Size(480, 410);
this.listViewRawData.TabIndex = 0;
//
// tabPage2
//
this.tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listViewGDIResult});
this.tabPage2.Location = new System.Drawing.Point(4, 21);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(480, 410);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "GDI 搬苞";
//
// listViewGDIResult
//
this.listViewGDIResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewGDIResult.Name = "listViewGDIResult";
this.listViewGDIResult.Size = new System.Drawing.Size(480, 410);
this.listViewGDIResult.TabIndex = 1;
//
// tabPage3
//
this.tabPage3.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listViewDBIResult});
this.tabPage3.Location = new System.Drawing.Point(4, 21);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(480, 410);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "DBI 搬苞";
//
// listViewDBIResult
//
this.listViewDBIResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewDBIResult.Name = "listViewDBIResult";
this.listViewDBIResult.Size = new System.Drawing.Size(480, 410);
this.listViewDBIResult.TabIndex = 1;
//
// tabPage4
//
this.tabPage4.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listViewSDIResult});
this.tabPage4.Location = new System.Drawing.Point(4, 21);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(480, 410);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "SDI 搬苞";
//
// listViewSDIResult
//
this.listViewSDIResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewSDIResult.Name = "listViewSDIResult";
this.listViewSDIResult.Size = new System.Drawing.Size(480, 410);
this.listViewSDIResult.TabIndex = 1;
//
// tabControl
//
this.tabControl.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabPage1,
this.tabPage2,
this.tabPage3,
this.tabPage4});
this.tabControl.Dock = System.Windows.Forms.DockStyle.Right;
this.tabControl.ItemSize = new System.Drawing.Size(77, 17);
this.tabControl.Location = new System.Drawing.Point(302, 0);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(488, 435);
this.tabControl.TabIndex = 0;
//
// groupBox4
//
this.groupBox4.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBoxOpenFile,
this.buttonOpenFile});
this.groupBox4.Location = new System.Drawing.Point(8, 16);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(280, 56);
this.groupBox4.TabIndex = 8;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Select Data File";
//
// buttonValidate
//
this.buttonValidate.Enabled = false;
this.buttonValidate.Location = new System.Drawing.Point(8, 400);
this.buttonValidate.Name = "buttonValidate";
this.buttonValidate.Size = new System.Drawing.Size(88, 23);
this.buttonValidate.TabIndex = 9;
this.buttonValidate.Text = "Validate";
this.buttonValidate.Click += new System.EventHandler(this.buttonValidate_Click);
//
// buttonExit
//
this.buttonExit.Location = new System.Drawing.Point(200, 400);
this.buttonExit.Name = "buttonExit";
this.buttonExit.Size = new System.Drawing.Size(88, 23);
this.buttonExit.TabIndex = 10;
this.buttonExit.Text = "Exit";
this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
//
// buttonSave
//
this.buttonSave.Enabled = false;
this.buttonSave.Location = new System.Drawing.Point(104, 400);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(88, 23);
this.buttonSave.TabIndex = 11;
this.buttonSave.Text = "Save";
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(790, 435);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonSave,
this.buttonExit,
this.buttonValidate,
this.groupBox4,
this.groupBox3,
this.groupBox1,
this.tabControl});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "MainForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Cluster Validation Tools";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDBIt)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDBIq)).EndInit();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSetNumber)).EndInit();
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tabControl.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
/// <summary>
/// xls 屈怕肺 等 Raw Data 拳老佬扁
/// openFileDialog甫 何弗促
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonOpenFile_Click(object sender, System.EventArgs e) {
if ( this.openFileDialog.ShowDialog() == DialogResult.OK ){
// 矯埃撈 坷貳 吧府綽 何盒籃 Thread肺 刀賦矯淖促
// C#俊輯綽 撈犯霸 刀賦矯難具 UI俊 積扁綽 鞏力啊 臨絹電促
Thread ValidateThread = new Thread( new ThreadStart( RawDataShowThread ) );
ValidateThread.Start();
// Validate甫 且 薦 樂綽啊
this.IsValidateReady();
// Save甫 給竅霸 阜瀾
this.buttonSave.Enabled = false;
}
}
private void RawDataShowThread(){
// 拳老 郴儈闌 List View俊 釬矯
this.listViewRawData.Hide();
this.RawDataShow( this.textBoxOpenFile.Text );
this.listViewRawData.Show();
}
/// <summary>
/// 拳老 撈撫撈 力措肺 急琶撈 等 撈亥飄甫 貿(mào)府竅綽 何盒
/// 急琶等 拳老 撈撫 釬矯, 竣伎 郴儈闌 釬矯竅霸 竊
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) {
// 拳老 撈撫闌 Text Box俊 釬矯
this.textBoxOpenFile.Clear();
this.textBoxOpenFile.AppendText( this.openFileDialog.FileName );
}
private void checkBoxGDI_CheckedChanged(object sender, System.EventArgs e) {
// Validate甫 且 薦 樂綽啊
this.IsValidateReady();
}
private void checkBoxDBI_CheckedChanged(object sender, System.EventArgs e) {
bool bCheck = this.checkBoxDBI.Checked;
this.buttonDBIadd.Enabled = bCheck;
this.buttonDBIdelete.Enabled = bCheck;
this.treeViewDBI.Enabled = bCheck;
this.numericUpDownDBIq.Enabled = bCheck;
this.numericUpDownDBIt.Enabled = bCheck;
// Validate甫 且 薦 樂綽啊
this.IsValidateReady();
}
private void buttonDBIadd_Click(object sender, System.EventArgs e) {
// List View 俊 急琶等 q客 t藹闌 歷厘茄促
String strMsg = this.numericUpDownDBIq.Value + " , " + this.numericUpDownDBIt.Value;
foreach ( TreeNode tvItem in this.treeViewDBI.Nodes ){
if ( tvItem.Text.Equals( strMsg ) )
return;
}
this.treeViewDBI.Nodes.Add( strMsg );
// Validate甫 且 薦 樂綽啊
this.IsValidateReady();
}
/// <summary>
/// 急琶等 Item闌 瘤款促
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonDBIdelete_Click(object sender, System.EventArgs e) {
if ( this.treeViewDBI.SelectedNode == null )
return;
this.treeViewDBI.Nodes.Remove( this.treeViewDBI.SelectedNode );
// Validate甫 且 薦 樂綽啊
this.IsValidateReady();
}
private void checkBoxSDI_CheckedChanged(object sender, System.EventArgs e) {
// Validate甫 且 薦 樂綽啊
this.IsValidateReady();
}
private void buttonValidate_Click(object sender, System.EventArgs e) {
ProgressForm progressform = new ProgressForm();
progressform.RunValidate(
this.m_worksheet,
this.textBoxOpenFile.Text,
this.checkBoxGDI.Checked,
this.checkBoxDBI.Checked,
this.checkBoxSDI.Checked,
this);
this.buttonSave.Enabled = true;
}
private void IsValidateReady(){
// Data File撈 汲瀝 登瘤 臼疽欄擱 Validate 霖厚啊 登絹樂瘤 臼籃 巴烙
if ( this.textBoxOpenFile.Text == "" ){
this.buttonValidate.Enabled = false;
return;
}
// GDI客 SDI Check Box 吝 竅唱扼檔 ok 牢瘤 犬牢
if ( ((this.checkBoxGDI.Checked || this.checkBoxSDI.Checked) && !this.checkBoxDBI.Checked ) == true ){
this.buttonValidate.Enabled = true;
return;
}
else
this.buttonValidate.Enabled = false;
// DBI啊 拌魂 Check 登絹 樂絆 拌魂 啊瓷茄 惑怕牢瘤 犬牢
if ( (this.checkBoxDBI.Checked && ( this.treeViewDBI.Nodes.Count != 0 ) ) == true )
this.buttonValidate.Enabled = true;
else
this.buttonValidate.Enabled = false;
}
/// <summary>
/// 橇肺弊伐 輛豐竅扁
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonExit_Click(object sender, System.EventArgs e) {
this.Dispose();
}
private void RawDataShow( String fileName ){
// Excel 拳老闌 咯綽 單 鞘夸茄 努貳膠甸
Excel.Workbook theWorkbook;
Excel.Sheets sheets;
Excel.Worksheet worksheet;
int i = 1;
// Raw 單撈磐 棺 搬苞甫 釬矯竅綽 list viwe甫 檬扁拳 茄促
this.InitListView( true, this.listViewRawData );
this.InitListView( true, this.listViewDBIResult );
this.InitListView( true, this.listViewGDIResult );
this.InitListView( true, this.listViewSDIResult );
// It uses most of the default values (except for the read-only which we set to true)
theWorkbook = this.objExcel.Workbooks.Open(
fileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
// Workbook狼 Sheet Collection闌 掘絹柯促
sheets = theWorkbook.Worksheets;
// Worksheet Collection狼 霉 Sheet父 掘絹柯促
worksheet = (Excel.Worksheet)sheets.get_Item(1);
this.m_worksheet = worksheet;
// Column狼 骯薦甫 瀝竊 ( 霉鍋擄 臨 ), Column Header甫 厘僥
Excel.Range titleRange = worksheet.get_Range("A1", "IV1");
System.Array titleValues = (System.Array) titleRange.Cells.Value;
for ( i = 1; i <= titleValues.Length; i ++ ){
ColumnHeader headColumn = new ColumnHeader();
if (titleValues.GetValue(1, i) == null)
break;
else
headColumn.Text = (string)titleValues.GetValue(1, i).ToString();
this.listViewRawData.Columns.Add( headColumn );
this.listViewRawData.Columns[i - 1].Width = headColumn.Width + 15;
}
// 2 何磐 3鱉瘤狼 Row俊 樂綽 單撈磐甫 List View俊 釬矯
for (int j = 2; j <= 20; j++) {
Excel.Range range = worksheet.get_Range("A"+j.ToString(), "IV" + j.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
if ( myvalues.GetValue(1,1) == null )
break;
string[] strArray = ConvertToStringArray(myvalues);
this.listViewRawData.Items.Add(new ListViewItem(strArray));
}
// 力老 付瘤阜 臨俊 " ... "闌 釬矯竅檔廢 茄促
this.listViewRawData.Items.Add( new ListViewItem("...") );
}
/// <summary>
/// value Array甫 String[]欄肺 官槽促.
/// </summary>
string[] ConvertToStringArray(System.Array values) {
string[] anArray = new string[values.Length];
for (int i = 1; i <= values.Length; i++) {
if (values.GetValue(1, i) == null)
anArray[i-1] = "";
else
anArray[i-1] = (string)values.GetValue(1, i).ToString();
}
return anArray;
}
string[] ConvertToStringArray(ArrayList values) {
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -