forked from 11000100111010101100111/exam_-BrushQuestions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChiose.cs
217 lines (195 loc) · 6.81 KB
/
Chiose.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 快眼刷题
{
public partial class Chiose : Form
{
public Chiose()
{
InitializeComponent();
ch1 = this;
}
public static Chiose ch1;
int chioseTimes = 0;
string[] proType;
public string proYear = "";
private void mybutton1_Click(object sender, EventArgs e)
{
moveButtom(mybutton1, 1, mybutton2, 1 - chioseTimes);
if (chioseTimes==0)
{
panel1.Visible = true;
panel2.Visible = false;
panel3.Visible = false;
}
else if (chioseTimes == 1)
{
panel1.Visible = false ;
panel2.Visible = true ;
panel3.Visible = false;
}
else
{
panel1.Visible = false ;
panel2.Visible = false;
panel3.Visible = true ;
}
}
private void mybutton2_Click(object sender, EventArgs e)
{
moveButtom(mybutton2, -1, mybutton1, chioseTimes);
if (chioseTimes == 0)
{
panel1.Visible = true;
panel2.Visible = false;
panel3.Visible = false;
}
else if (chioseTimes == 1)
{
panel1.Visible = false;
panel2.Visible = true;
panel3.Visible = false;
}
else
{
panel1.Visible = false;
panel2.Visible = false;
panel3.Visible = true;
}
}
public void moveButtom(mybutton b1,int step, mybutton b2,int flage)
{
b2.Enabled = true;
if (b1.Enabled == true)
{
chioseTimes+=step;
}
if (flage >0)
{
b1.Enabled = true;
}
else
b1.Enabled = false;
if (chioseTimes == 2)
mybutton4.Visible = true;
else
mybutton4.Visible = false;
}
private void mybutton3_Click(object sender, EventArgs e)
{
if (File.Exists(Form2.f2.proPath))
File.Delete(Form2.f2.proPath);
this.Close();
Form2.f2.Close();
}
private void mybutton4_Click(object sender, EventArgs e)
{
string[] type = { "C语言","C++","Java","Web开发","C#程序设计"};
proType = new string[checkedListBox3.CheckedItems.Count];
int i = 0;
foreach (var item in checkedListBox3.CheckedItems)
{
for (int j = 0; j < type.Length; j++)
{
if (item.ToString () == type[j])
{
proType[i] = (j+1).ToString();
break;
}
}
i++;
}
if (proYear == "" || proType.Length == 0)
{
MessageBox.Show("选择不完整!无法继续!");
}
else
{
string str = "选择题库是:"+proYear ;
string str1 = "选择的题目类型有:";
i = 0;
foreach (var item in checkedListBox3.CheckedItems)
{
str1 += "[" + item + "] "; i++;
}
int proLength = 0;
string path = Path.Combine(System.IO.Directory.GetCurrentDirectory(),"题库", proYear.Trim());
Form2.f2.readProNum(@path,ref proLength);
string []temp = new string[10];
Dictionary<int, string[]> arr = new Dictionary<int,string[]> { };
int location = 0;
int times = 0;
for (; times < proType.Length; times++)
{
Form2.f2.readProMessage(@path, proLength, 1, ref arr, proType[times],ref location);
}
Form2.f2.readProMessage(@path, proLength, 1, ref arr,ref location);
Form2.f2.add_row(@"我的题库.xls",arr, arr.Count, 10);
if (MessageBox.Show("\t"+str+"!\n\t"+str1,
"配 置 完 成",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Information) == DialogResult.OK)
{
this.Close();
Form1 f1 = new Form1();
f1.Show();
}
}
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Chiose_Load(object sender, EventArgs e)
{
checkedListBox2.SetItemChecked(0, true);
show();
getFileName();
}
public void show()
{
panel1.Size = panel2.Size;
panel3.Size = panel2.Size;
panel1.Location = new Point(this.Width / 2 - panel1.Width / 2, this.Height / 2 - panel1.Height / 2);
panel2.Location = new Point(this.Width / 2 - panel2.Width / 2, this.Height / 2 - panel2.Height / 2);
panel3.Location = new Point(this.Width / 2 - panel3.Width / 2, this.Height / 2 - panel3.Height / 2);
}
public void getFileName()
{
int i = 0;
var files = Directory.GetFiles(@"题库", "*.xls");
checkedListBox2.Items.Clear();
string[] fileName = new string[files.Length];
foreach (var item in files)
{
fileName[i]=item.ToString();
fileName[i] = fileName[i].Substring(3, fileName[i].Length-3);
i++;
}
checkedListBox2.Items.AddRange(fileName);
}
private void checkedListBox2_SelectedIndexChanged(object sender, EventArgs e)
{}
private void checkedListBox2_Click(object sender, EventArgs e)
{
int index = checkedListBox2.SelectedIndex;
for (int i = 0; i < checkedListBox2.Items.Count; i++)
{
if (checkedListBox2.Items.IndexOf(i) != index)
checkedListBox2.SetItemChecked(i, false);
else
checkedListBox2.SetItemChecked(i, true);
}
proYear = checkedListBox2.SelectedItem.ToString().Trim();
}
private void checkedListBox2_DoubleClick(object sender, EventArgs e)
{}
}
}