www.pudn.com > classifier.rar > splitForm.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace classifier
{
///
/// Form2 的摘要说明。
///
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Button openDirBtn;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button splitBtn;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private string[] fileString;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.openDirBtn = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.listBox1 = new System.Windows.Forms.ListBox();
this.splitBtn = new System.Windows.Forms.Button();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.SuspendLayout();
//
// openDirBtn
//
this.openDirBtn.Location = new System.Drawing.Point(8, 256);
this.openDirBtn.Name = "openDirBtn";
this.openDirBtn.TabIndex = 1;
this.openDirBtn.Text = "打开目录";
this.openDirBtn.Click += new System.EventHandler(this.openDirBtn_Click);
//
// openFileDialog1
//
this.openFileDialog1.Multiselect = true;
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
//
// listBox1
//
this.listBox1.HorizontalScrollbar = true;
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(8, 40);
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.Size = new System.Drawing.Size(272, 196);
this.listBox1.TabIndex = 0;
//
// splitBtn
//
this.splitBtn.Location = new System.Drawing.Point(104, 256);
this.splitBtn.Name = "splitBtn";
this.splitBtn.TabIndex = 2;
this.splitBtn.Text = "分词统计";
this.splitBtn.Click += new System.EventHandler(this.splitBtn_Click);
//
// saveFileDialog1
//
this.saveFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog1_FileOk);
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(288, 293);
this.Controls.Add(this.splitBtn);
this.Controls.Add(this.openDirBtn);
this.Controls.Add(this.listBox1);
this.Name = "Form2";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Form2";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private void openDirBtn_Click(object sender, System.EventArgs e)
{
openFileDialog1.ShowDialog();
}
///
/// 得到文件后
///
///
///
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
//将选择得到的文件传递给listBox
string fname="";
listBox1.Items.Clear();
fileString=new string[openFileDialog1.FileNames.Length];
for(int i=0;i
/// 分词统计按钮,创建线程进行分词统计,分次程序被写为一个类,以后再写成一个dll
/// 需要从已有类别中选择一个类别或者是新建一个类别
///
///
///
private void splitBtn_Click(object sender, System.EventArgs e)
{
Form f=new learn(fileString);
f.Show();
f.MdiParent=this.MdiParent;
this.Close();
//saveFileDialog1.ShowDialog(this);
}
///
///
///
///
///
private void saveFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
//保存为 类别数据库,如果已存在该类别则修改原有的类别表中的数据,如果不存在该类别
//则用户输入新类别名,并在类别数据库中创建新类别对应的表
MessageBox.Show(saveFileDialog1.FileNames[0]);
}
}
}