⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 Cluster validation program including Dunn s index, Davies-Bouldin Index and Scat-Dis index.
💻 CS
📖 第 1 页 / 共 3 页
字号:
			// 
			// 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>
		/// 拳老 捞抚捞 力措肺 急琶捞 等 捞亥飘甫 贸府窍绰 何盒
		/// 急琶等 拳老 捞抚 钎矫, 竣伎 郴侩阑 钎矫窍霸 窃
		/// </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) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -