📄 frmstart.cs
字号:
this.panel7.Controls.Add(this.panel8);
this.panel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel7.Location = new System.Drawing.Point(0, 0);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(462, 325);
this.panel7.TabIndex = 21;
//
// panel4
//
this.panel4.Controls.Add(this.rtbTitle);
this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel4.Location = new System.Drawing.Point(0, 24);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(462, 199);
this.panel4.TabIndex = 25;
//
// rtbTitle
//
this.rtbTitle.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbTitle.Location = new System.Drawing.Point(0, 0);
this.rtbTitle.Name = "rtbTitle";
this.rtbTitle.ReadOnly = true;
this.rtbTitle.Size = new System.Drawing.Size(462, 199);
this.rtbTitle.TabIndex = 24;
this.rtbTitle.Text = "";
//
// panel5
//
this.panel5.Controls.Add(this.labTime);
this.panel5.Controls.Add(this.lblTopic);
this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
this.panel5.Location = new System.Drawing.Point(0, 0);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(462, 24);
this.panel5.TabIndex = 26;
//
// labTime
//
this.labTime.Dock = System.Windows.Forms.DockStyle.Right;
this.labTime.Location = new System.Drawing.Point(318, 0);
this.labTime.Name = "labTime";
this.labTime.Size = new System.Drawing.Size(144, 24);
this.labTime.TabIndex = 21;
this.labTime.Text = "剩余时间:";
this.labTime.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// lblTopic
//
this.lblTopic.Dock = System.Windows.Forms.DockStyle.Left;
this.lblTopic.Location = new System.Drawing.Point(0, 0);
this.lblTopic.Name = "lblTopic";
this.lblTopic.Size = new System.Drawing.Size(48, 24);
this.lblTopic.TabIndex = 20;
this.lblTopic.Text = "题干:";
this.lblTopic.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
// panel8
//
this.panel8.Controls.Add(this.clbAnwser);
this.panel8.Controls.Add(this.lblAnswer);
this.panel8.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel8.Location = new System.Drawing.Point(0, 223);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(462, 102);
this.panel8.TabIndex = 24;
//
// clbAnwser
//
this.clbAnwser.Location = new System.Drawing.Point(62, 8);
this.clbAnwser.Name = "clbAnwser";
this.clbAnwser.Size = new System.Drawing.Size(160, 84);
this.clbAnwser.TabIndex = 25;
this.clbAnwser.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbAnwser_ItemCheck);
//
// lblAnswer
//
this.lblAnswer.Location = new System.Drawing.Point(6, 10);
this.lblAnswer.Name = "lblAnswer";
this.lblAnswer.Size = new System.Drawing.Size(48, 16);
this.lblAnswer.TabIndex = 24;
this.lblAnswer.Text = "答案:";
//
// timerExam
//
this.timerExam.Interval = 1000;
this.timerExam.Tick += new System.EventHandler(this.timer1_Tick);
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(138, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 325);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// FrmStart
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(600, 373);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel3);
this.KeyPreview = true;
this.Name = "FrmStart";
this.Text = "考试";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FrmStart_KeyDown);
this.Load += new System.EventHandler(this.FrmStart_Load);
this.panel3.ResumeLayout(false);
this.panel6.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel7.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.panel5.ResumeLayout(false);
this.panel8.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void FrmStart_Load(object sender, System.EventArgs e)
{
ArrayList ids=filterTopicID();
TopicsFac topicFac=new TopicsFac();
dsTitle=topicFac.getTopicByIDs(ids);
dsTitle.Tables[0].Columns.Add("myAnswer",typeof(System.String));
fillList();
examTime=new ExamTime();
this.examTime.Minute=this.curExam.ExamTime;
if(!this.insertInfo())
{
MessageBox.Show("你已经考过这试了","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
return;
}
MessageBox.Show("开始考试\n考试时间是:"+examTime.Minute.ToString()+"分钟","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
timerExam.Enabled=true;
}
private void btnStart_Click(object sender, System.EventArgs e)
{
}
private void dlvTitles_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.dlvTitles.SelectedIndices.Count>0)
{
int index=dlvTitles.SelectedIndices[0];
if(index<0)
{
return;
}
fillTitleInfo(index);
}
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if(examTime.nextSecond())
{
if(examTime.Minute<5)
{
labTime.ForeColor=Color.Red;
labTime.Font=new Font("宋体",12);
}
else
{
labTime.ForeColor=Color.Black;
labTime.Font=new Font("宋体",9);
}
labTime.Text="剩余时间:"+examTime.ToString();
}
else
{
timerExam.Enabled=false;
MessageBox.Show("考试完毕","时间到了",MessageBoxButtons.OK,MessageBoxIcon.Information);
createResult();
}
}
private void createResult()
{
int trueCount=0;
for(int i=0;i<dsTitle.Tables[0].Rows.Count;i++)
{
if(dsTitle.Tables[0].Rows[i]["TopicAnwser"].ToString()==dsTitle.Tables[0].Rows[i]["myAnswer"].ToString())
{
trueCount++;
}
}
double result=Math.Round(((double)trueCount/(double)dsTitle.Tables[0].Rows.Count)*100,1);
//MessageBox.Show(result.ToString());
ResultCreater rc=new ResultCreater(Application.StartupPath+@"\bak\modle\modle");
string res=rc.createResult(this.dsTitle.Tables[0],this.curExam,result,100);
string root=Application.StartupPath+@"\bak\bak.htm";
if(this.curExam.ExamID>0)
{
updateResult(res,result);
}
ResultCreater.saveResult(res,root);
FrmView frmView=new FrmView();
frmView.MdiParent=this.MdiParent;
frmView.Show();
frmView.linkFile(root);
this.Close();
}
private void btnEnd_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("是否要交卷","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
{
createResult();
}
}
private void timeSetAnswer_Tick(object sender, System.EventArgs e)
{
}
private string getListAnswer(ArrayList list)
{
MyReverserClass myRev=new MyReverserClass();
list.Sort(0,list.Count,myRev);
string str="";
for(int i=0;i<list.Count;i++)
{
str+=list[i].ToString();
if(i<list.Count-1)
{
str+=",";
}
}
return str;
}
private void clbAnwser_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
if(dlvTitles.SelectedIndices.Count>0)
{
int index=dlvTitles.SelectedIndices[0];
if(index<0)
{
return;
}
ArrayList answer=getAnswer();
if(e.NewValue==CheckState.Checked)
{
answer.Add(clbAnwser.Items[e.Index].ToString());
}if(e.NewValue==CheckState.Unchecked)
{
answer.Remove(clbAnwser.Items[e.Index].ToString());
}
string strAns=getListAnswer(answer);
dlvTitles.Items[index].SubItems[2].Text=strAns;
dsTitle.Tables[0].Rows[index]["myAnswer"]=strAns;
}
}
private void btnNext_Click(object sender, System.EventArgs e)
{
if(dlvTitles.SelectedIndices.Count>0)
{
int index=dlvTitles.SelectedIndices[0];
if(index<0)
{
dlvTitles.Items[0].Selected=true;
return;
}
if(index>=dlvTitles.Items.Count-1)
{
MessageBox.Show("已经到最后一题了!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
dlvTitles.Items[index+1].Selected=true;
}
}
private void btnBack_Click(object sender, System.EventArgs e)
{
if(dlvTitles.SelectedIndices.Count>0)
{
int index=dlvTitles.SelectedIndices[0];
if(index<0)
{
dlvTitles.Items[dlvTitles.Items.Count-1].Selected=true;
return;
}
if(index<=0)
{
MessageBox.Show("已经到第一题了!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
dlvTitles.Items[index-1].Selected=true;
}
}
private void FrmStart_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyValue==38)
{
btnBack_Click(null,null);
}
if(e.KeyValue==40)
{
btnNext_Click(null,null);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
examTime.Minute=0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -