-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForm1.cs
75 lines (69 loc) · 2.28 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class txtSplit : Form
{
public txtSplit()
{
InitializeComponent();
}
private void txtSplit_Load(object sender, EventArgs e)
{
button1.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("请添加正则表达式");
return;
}
button3.Enabled = false;
button2.Enabled = false;
button1.Enabled = false;
progressBar1.Value = 0;
Task.Factory.StartNew(() =>
{
SplitHandler splitHandler = new SplitHandler(this,
textBox1.Text,
label1.Text,
Path.Combine(Path.GetDirectoryName(label1.Text), "out"),
button3.Text);
int counter = splitHandler.Split();
BeginInvoke(new Action(() =>
{
if (counter != -1)
{
label1.Text = $"切割完毕 - 共生成{counter}个文件";
}
else
{
MessageBox.Show($"出错了!");
label1.Text = "切割失败";
}
button2.Enabled = true;
button3.Enabled = true;
}));
});
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "文本文件(*.txt)|*.txt";
openFileDialog.Title = "请选择文件";
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
button1.Enabled = true;
label1.Text = openFileDialog.FileName;
}
}
private void button3_Click(object sender, EventArgs e)
{
button3.Text = (button3.Text == "UTF-8") ? "GB2312" : "UTF-8";
}
}
}