private void Timer_Speaking_Tick(object sender, EventArgs e) { DateTime time = new DateTime(); DateTime time2 = new DateTime(); TimeSpan span = new TimeSpan(); DateTime time3 = new DateTime(); string str = ""; if (this.TestSection != TestingSection.SPEAKING) { if (this.TestSection == TestingSection.WRITING) { switch (this.CurrentWritingStep) { case 0: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WDIRECTION; this.MP3Player = new MP3MCI(); str = @"Tests\Direction\writeA1.mp3"; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.HasLoadMP3 = true; } catch { } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentWritingStep = 1; this.HasLoadMP3 = false; } break; case 1: if (!this.HasLoadMP3) { try { base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WSPEECH; this.MP3Player = new MP3MCI(); str = @"Tests\Direction\writeA2.mp3"; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.pb_writingScene.Load(Application.StartupPath + @"\Tests\images\WaitPerson.jpg"); this.wpb_speak.Maximum = this.MP3Player.Duration; this.wtb_speak.Maximum = this.MP3Player.Duration; this.HasLoadMP3 = true; } catch { } } this.wpb_speak.Value = this.MP3Player.CurrentPosition; this.wtb_speak.Value = this.MP3Player.CurrentPosition; if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentWritingStep = 2; this.HasLoadMP3 = false; } break; case 2: if (!this.HasLoadMP3) { base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); base.btn_preQuestion.Enabled = false; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back"); this.MP3Player.StopT(); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WINDEPENDENT; this.wrtb_writing2.ReadOnly = true; this.wrtbQuestion2.Rtf = this.WritingQuestions[0]; base.lbl_timeremain.Text = "03:00"; base.lbl_timeremain.ForeColor = SystemColors.ControlText; this.HasLoadMP3 = true; } time = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); if (DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) <= DateTime.ParseExact("00:00", "mm:ss", null)) { this.CurrentWritingStep = 3; this.HasLoadMP3 = false; } break; case 3: if (!this.HasLoadMP3) { try { if (this.rb_PracticeMode.Checked) { base.btn_preQuestion.Enabled = true; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back1"); } base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WSPEECH; this.MP3Player = new MP3MCI(); base.lbl_timeremain.Text = "20:00"; base.lbl_timeremain.ForeColor = SystemColors.ControlText; str = @"Tests\" + this.TPONO + @"\Writing\Speech.mp3"; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.wpb_speak.Maximum = this.MP3Player.Duration; this.wtb_speak.Maximum = this.MP3Player.Duration; this.pb_writingScene.Load(Application.StartupPath + @"\Tests\images\write" + this.TPONO.ToString() + ".jpg"); this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } this.wpb_speak.Value = this.MP3Player.CurrentPosition; this.wtb_speak.Value = this.MP3Player.CurrentPosition; if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentWritingStep = 4; this.HasLoadMP3 = false; } break; case 4: if (!this.HasLoadMP3) { try { if (this.rb_PracticeMode.Checked) { base.btn_preQuestion.Enabled = true; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back1"); } base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WINDEPENDENT; this.MP3Player = new MP3MCI(); str = @"Tests\Direction\writeA3.mp3"; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.wrtb_writing2.ReadOnly = false; this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } this.wpb_speak.Value = this.MP3Player.CurrentPosition; this.wtb_speak.Value = this.MP3Player.CurrentPosition; if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentWritingStep = 5; this.HasLoadMP3 = false; } break; case 5: if (!this.HasLoadMP3) { if (this.rb_PracticeMode.Checked) { base.btn_preQuestion.Enabled = true; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back1"); } base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); this.MP3Player.StopT(); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WINDEPENDENT; base.lbl_questionNO.Text = "Question 1 of 2"; this.wrtbQuestion2.Rtf = this.WritingQuestions[0]; this.wrtb_writing2.ReadOnly = false; this.lbl_writeDirection.Text = "Directions: You have 20 minutes to plan and write your response. Your response will be judged on the basis of the quality of your writing and on how well your response presents in the lecture and their relationship to the reading passage. Typically, an effective response will be 150 to 225 words.\n Question: Summarize the points made in the lecture, being sure to explain how they cast doubt on specific points made in the reading passage."; base.lbl_timeremain.Text = "20:00"; base.lbl_timeremain.ForeColor = SystemColors.ControlText; this.HasLoadMP3 = true; } time = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); time3 = DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null); this.WriteWritingAnswers("write1.txt", this.wrtb_writing2.Text); if (time3 <= DateTime.ParseExact("00:00", "mm:ss", null)) { this.Timer_Speaking.Stop(); if (MessageBox.Show("Time over", "Warning", MessageBoxButtons.OK) == DialogResult.OK) { this.Timer_Speaking.Start(); } this.CurrentWritingStep = 6; this.HasLoadMP3 = false; } break; case 6: if (!this.HasLoadMP3) { this.MP3Player.StopT(); if (this.rb_PracticeMode.Checked) { base.btn_preQuestion.Enabled = true; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back1"); } this.WriteWritingAnswers("write1.txt", this.wrtb_writing2.Text); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WINDEPENDENT; this.lbl_writeDirection.Text = "Directions: Read the question below. You have 30 minutes to plan, write, and revise your essay. Typically, an effective response will contain a minimum of 300 words."; this.wrtb_writing2.Text = ""; this.wrtb_writing2.ReadOnly = false; this.wrtbQuestion2.Rtf = this.WritingQuestions[1]; base.lbl_questionNO.Text = "Question 2 of 2"; base.lbl_timeremain.Text = "30:00"; base.lbl_timeremain.ForeColor = SystemColors.ControlText; this.HasLoadMP3 = true; } this.WriteWritingAnswers("write2.txt", this.wrtb_writing2.Text); time = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); if (DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) <= DateTime.ParseExact("00:00", "mm:ss", null)) { this.WriteWritingAnswers("write2.txt", this.wrtb_writing2.Text); this.Timer_Speaking.Stop(); if (MessageBox.Show("Time over", "Warning", MessageBoxButtons.OK) == DialogResult.OK) { this.btn_mainmenu_Click(sender, e); } this.CurrentWritingStep = 6; this.HasLoadMP3 = false; } break; } } } else { XMLFileReader reader = new XMLFileReader(@"Tests\" + this.TPONO + @"\Speaking\questions.xml"); string attr = reader.GetAttr("//question[@NO=" + this.QuestionNO + "]/@SpeakingIntro"); string str3 = reader.GetAttr("//question[@NO=" + this.QuestionNO + "]/@SpeakingMP3"); string str4 = reader.GetAttr("//question[@NO=" + this.QuestionNO + "]/@ReadingMP3"); string str5 = reader.GetAttr("//question[@NO=" + this.QuestionNO + "]/@SpeakingQuestion"); string str6 = reader.GetAttr("//question[@NO=" + this.QuestionNO + "]/@BeepPrepare"); string str7 = reader.GetAttr("//question[@NO=" + this.QuestionNO + "]/@BeepSpeak"); switch (this.CurrentSpeakingStep) { case 0: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SDIRECTION; this.MP3Player = new MP3MCI(); str = @"Tests\Direction\Speaking_Introduction.mp3"; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.HasLoadMP3 = true; this.srtb_introduction.Rtf = this.SpeakingQuestions[this.QuestionNO - 1].ToString(); this.srtb_introduction.Visible = true; this.srtb_timeindicator.Visible = false; this.srtb_timer.Visible = false; this.spb.Visible = false; } catch { MessageBox.Show("open" + str + "出错!"); } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentSpeakingStep = 1; this.HasLoadMP3 = false; } break; case 1: if (this.CONTINUECLICKED) { if (!this.HasLoadMP3) { try { this.pb_speakingScene.Load(Application.StartupPath + @"\Tests\images\WaitPerson.jpg"); base.lbl_questionNO.Text = "Question " + this.QuestionNO + " of 6"; this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.pb_speakingScene.Visible = true; this.srtb_introduction.Visible = false; this.MP3Player = new MP3MCI(); str = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Speaking\", attr }); this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.srtb_timeindicator.Visible = false; this.srtb_timer.Visible = false; this.spb.Visible = false; this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { if ((((this.QuestionNO == 1) || (this.QuestionNO == 2)) || (this.QuestionNO == 5)) || (this.QuestionNO == 6)) { this.CurrentSpeakingStep = 4; } else if ((this.QuestionNO == 3) || (this.QuestionNO == 4)) { this.CurrentSpeakingStep = 2; } this.HasLoadMP3 = false; } } break; case 2: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.MP3Player = new MP3MCI(); str = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Speaking\", str4 }); this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.pb_speakingScene.Visible = false; base.lbl_timeremain.Text = "00:45"; this.srtb_timeindicator.Text = "READING TIME"; this.srtb_introduction.Rtf = this.SReadingMaterials[this.QuestionNO - 3]; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; this.srtb_introduction.Visible = true; this.srtb_timeindicator.Visible = true; this.srtb_timer.Visible = true; this.spb.Visible = false; this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentSpeakingStep = 3; this.HasLoadMP3 = false; } break; case 3: if (!this.HasLoadMP3) { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.srtb_introduction.Rtf = this.SReadingMaterials[this.QuestionNO - 3]; this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; base.lbl_timeremain.Text = "00:45"; this.srtb_timeindicator.Text = "READING TIME"; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; this.srtb_timeindicator.Visible = true; this.srtb_timer.Visible = true; this.spb.Visible = false; this.HasLoadMP3 = true; } time = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); this.srtb_timeindicator.Text = "READING TIME"; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; if (DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) <= DateTime.ParseExact("00:00", "mm:ss", null)) { this.CurrentSpeakingStep = 4; this.HasLoadMP3 = false; } break; case 4: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.MP3Player = new MP3MCI(); str = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Speaking\", str3 }); this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.spb.Maximum = this.MP3Player.Duration; if (this.QuestionNO > 2) { this.spb.Visible = true; } else { this.spb.Visible = false; } this.srtb_introduction.Rtf = this.SpeakingQuestions[this.QuestionNO - 1]; if ((this.QuestionNO == 1) || (this.QuestionNO == 2)) { this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; } else { this.srtb_introduction.Visible = false; this.pb_speakingScene.Load(string.Concat(new object[] { Application.StartupPath, @"\Tests\images\speak", this.QuestionNO, ".jpg" })); this.srtb_timeindicator.Visible = false; this.srtb_timer.Visible = false; this.pb_speakingScene.Visible = true; } this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } this.spb.Value = this.MP3Player.CurrentPosition; if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { if ((this.QuestionNO == 1) || (this.QuestionNO == 2)) { this.CurrentSpeakingStep = 6; this.spb.Visible = false; base.lbl_timeremain.Text = "00:15"; this.srtb_timeindicator.Text = "PREPARATION TIME"; this.srtb_timeindicator.Visible = true; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; this.srtb_timer.Visible = true; } else { this.CurrentSpeakingStep = 5; } this.HasLoadMP3 = false; } break; case 5: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.MP3Player = new MP3MCI(); str = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Speaking\", str5 }); this.spb.Visible = false; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.srtb_introduction.Rtf = this.SpeakingQuestions[this.QuestionNO - 1]; this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; if ((this.QuestionNO == 3) || (this.QuestionNO == 4)) { base.lbl_timeremain.Text = "00:30"; } else { base.lbl_timeremain.Text = "00:20"; } this.srtb_timeindicator.Text = "PREPARATION TIME"; this.srtb_timeindicator.Visible = true; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; this.srtb_timer.Visible = true; this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentSpeakingStep = 6; this.HasLoadMP3 = false; } break; case 6: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.MP3Player = new MP3MCI(); str = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Speaking\", str6 }); this.spb.Visible = false; this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentSpeakingStep = 7; this.HasLoadMP3 = false; } break; case 7: if (!this.HasLoadMP3) { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; this.HasLoadMP3 = true; } time = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; if (DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) <= DateTime.ParseExact("00:00", "mm:ss", null)) { if ((this.QuestionNO == 1) || (this.QuestionNO == 2)) { base.lbl_timeremain.Text = "00:45"; } else { base.lbl_timeremain.Text = "01:00"; } this.srtb_timeindicator.Visible = true; this.srtb_timer.Visible = true; this.srtb_timeindicator.Text = "RESPONSE TIME"; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; this.CurrentSpeakingStep = 8; this.HasLoadMP3 = false; } break; case 8: if (!this.HasLoadMP3) { try { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.MP3Player = new MP3MCI(); str = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Speaking\", str7 }); this.MP3Player.FileName = str; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; this.HasLoadMP3 = true; } catch { MessageBox.Show("open" + str + "出错!"); } } if (this.MP3Player.CurrentPosition >= this.MP3Player.Duration) { this.CurrentSpeakingStep = 9; this.HasLoadMP3 = false; } break; case 9: if (!this.HasLoadMP3) { this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SQUESTION; this.MP3Recorder = new MP3Record(); this.MP3Recorder.SetFilePath(string.Concat(new object[] { @"users\", USERNAME, @"\", this.TPONO, @"\SpeakingAnswer", this.QuestionNO, ".wav" })); this.MP3Recorder.Start(); this.srtb_introduction.Visible = true; this.pb_speakingScene.Visible = false; this.HasLoadMP3 = true; } time = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); this.srtb_timeindicator.Visible = true; this.srtb_timer.Visible = true; this.srtb_timer.Text = "00:" + base.lbl_timeremain.Text; if (DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) <= DateTime.ParseExact("00:00", "mm:ss", null)) { this.CurrentSpeakingStep = 10; this.MP3Recorder.Stop(); this.HasLoadMP3 = false; } break; case 10: if (!this.HasLoadMP3) { if (this.QuestionNO >= 6) { this.TestSection = TestingSection.WRITING; this.btn_LoadTest_Click(new Button(), e); break; } this.QuestionNO++; this.CurrentSpeakingStep = 1; this.srtb_introduction.Visible = false; this.pb_speakingScene.Visible = true; this.srtb_timeindicator.Visible = false; this.srtb_timer.Visible = false; } break; } } }
private void btn_preQuestion_Click(object sender, EventArgs e) { #region too dirty switch (this.TestSection) { case TestingSection.READING: break; case TestingSection.LISTENING: this.HasClickedNext = false; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("ok"); this.OnClickPrevButton(sender, e); if (!this.rb_TestMode.Checked || this.HasAnswered()) { //this.SaveUserAnswers(); base.btn_preQuestion.Enabled = false; this.Timer_Listening.Start(); if (this.QuestionNO >= this.PassageLastQuestionIndex) { if (this.PassageNO >= this.PartLastPassageIndex) { if (this.PartNO >= this.PartCount) { if (MessageBox.Show("You have seen all the questions in this listening section.\nClick on Cancel to continue working.\nClick on OK to go on.\nOnce you leave the listening section, you WILL NOT be able to return to it", "Finish Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.OK) { this.PartNO = 0; this.PassageNO = 0; this.QuestionNO = 0; this.TestSection = TestingSection.SPEAKING; this.btn_LoadTest_Click(sender, e); } } else if (MessageBox.Show("You have seen all the questions in this part of listening section.\nClick on Cancel to continue working.\nClick on OK to go on.\nOnce you leave the part, you WILL NOT be able to return to it", "Finish Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.OK) { this.scoreReport(2); this.PartNO++; this.PassageNO++; this.btn_LoadTest_Click(sender, e); } } else { this.PassageNO++; this.IsQuestionAfter = true; this.QuestionNO++; this.LoadListeningMaterial(); } } else { this.QuestionNO++; if (this.IsQuestionAfter) { this.QuestionNO--; this.IsQuestionAfter = false; } this.LoadListeningQA(); base.btn_nextQuestion.Enabled = false; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next"); } break; } MessageBox.Show("You must answer the question!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; case TestingSection.SPEAKING: base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); if (this.QuestionNO > 1) { this.QuestionNO--; this.CurrentSpeakingStep = 1; this.HasLoadMP3 = false; } if (this.QuestionNO <= 1) { base.btn_preQuestion.Enabled = false; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back"); } break; case TestingSection.WRITING: this.CurrentWritingStep--; base.btn_preQuestion.Enabled = false; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("back"); this.HasLoadMP3 = false; break; } #endregion too dirty }
private void Timer_Listening_Tick(object sender, EventArgs e) { DateTime time6; TimeSpan span; this.Timer_Listening.Interval = 0x3e8; int currentPosition = 0; if (this.TestSection == TestingSection.LISTENING) { currentPosition = this.MP3Player.CurrentPosition; } this.tb_currentpos.Value = currentPosition; this.pb_currentpos.Value = currentPosition; this.tb_currentpos1.Value = currentPosition; this.pb_currentpos1.Value = currentPosition; DateTime time = DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null); if (time < DateTime.ParseExact("00:01", "mm:ss", null)) { this.Timer_Listening.Stop(); this.SaveUserAnswers(); if (this.TestSection == TestingSection.LISTENING) { MessageBox.Show("Time over!", "Warning", MessageBoxButtons.OK); this.PartNO++; if (this.PartNO > this.PartCount) { this.PartNO = 0; this.PassageNO = 0; this.QuestionNO = 0; this.TestSection = TestingSection.SPEAKING; this.btn_LoadTest_Click(new Button(), e); } else { this.scoreReport(2); this.PassageNO = 4; this.QuestionNO = 0x11; this.btn_LoadTest_Click(new Button(), e); } return; } if (this.TestSection == TestingSection.READING) { MessageBox.Show("Time over!", "Warning", MessageBoxButtons.OK); this.PassageNO++; if (this.PassageNO <= this.PassageCount) { this.scoreReport(2); this.PreInsertPosition = -1; XMLFileReader reader = new XMLFileReader(@"Tests\" + this.TPONO + @"\Reading\config.xml"); this.RSpiltQuestionNO = int.Parse(reader.GetAttr("//Passage[@NO=" + this.PassageNO + "]/@spiltQuestionNO")); base.lbl_timeremain.Text = reader.GetAttr("//Passage[@NO=" + this.PassageNO + "]/@time"); this.tabf_test.SelectedIndex = READING; this.tabf_Reading.SelectedIndex = RDIRECTION; this.QuestionNO = 0; this.RMaterial = new TPOPassage(RtfReader.getRTF(@"Tests\" + this.TPONO.ToString() + @"\Reading\" + this.PassageNO.ToString() + ".txt").Substring(0xb5), RtfReader.getRTF(@"Explanations\" + this.TPONO.ToString() + @"\Reading\P" + this.PassageNO.ToString() + ".txt").Substring(0xb5)); if (File.Exists(@"Explanations\" + this.TPONO.ToString() + @"\Reading\" + this.ReadingPassageNo.ToString() + ".mp3") && ConstantValues.TPOEXPLANATION[this.TPONO]) { this.bn_readText.Visible = true; this.bn_readText.Enabled = true; } else { this.bn_readText.Visible = false; } this.TestQuestions = new TPOQuestions(RtfReader.getRTF(@"Tests\" + this.TPONO.ToString() + @"\Reading\questions" + this.PassageNO.ToString() + ".txt").Substring(0xb5), "", RtfReader.getRTF(@"Explanations\" + this.TPONO.ToString() + @"\Reading\Q" + this.PassageNO.ToString() + ".txt").Substring(0xb5)); this.QuestionCount = this.TestQuestions.QuestionCount; this.LoadReadingMaterialAndQA(); } else { int num2 = this.TPONO % 10; if (num2 == 0) { num2 = 10; } this.btn_LoadTest_Click(this.BtnLoadTest[10 + num2], e); this.PartNO = 1; this.PassageNO = 1; this.QuestionNO = 0; } } } if (time < DateTime.ParseExact("05:00", "mm:ss", null)) { base.button1.Visible = false; base.lbl_timeremain.Visible = true; this.flash_timer.Start(); } if (time < DateTime.ParseExact("04:45", "mm:ss", null)) { this.flash_timer.Stop(); base.lbl_timeremain.ForeColor = Color.Red; } if (this.TestSection == TestingSection.LISTENING) { int num4; if (this.IsPassageMP3) { if (this.rb_PracticeMode.Checked) { this.ckb_viewSpeakingText.Visible = true; } int length = this.SPictureTimeLines.Length; DateTime time2 = DateTime.ParseExact(this.MP3Player.CurrentPosStr, "mm:ss", null); if (length == 1) { this.pb_ListenScene.Load(Application.StartupPath + @"\Tests\images\" + this.SPicturePaths[0]); this.pb_ListenScene1.Load(Application.StartupPath + @"\Tests\images\" + this.SPicturePaths[0]); } else { for (num4 = 1; num4 < length; num4++) { DateTime time3 = DateTime.ParseExact(this.SPictureTimeLines[num4 - 1], "mm:ss", null); DateTime time4 = DateTime.ParseExact(this.SPictureTimeLines[num4], "mm:ss", null); if ((time3 <= time2) && (time2 <= time4)) { this.pb_ListenScene.Load(Application.StartupPath + @"\Tests\images\" + this.SPicturePaths[num4 - 1]); this.pb_ListenScene1.Load(Application.StartupPath + @"\Tests\images\" + this.SPicturePaths[num4 - 1]); } } DateTime time5 = DateTime.ParseExact(this.SPictureTimeLines[length - 1], "mm:ss", null); if (time2 > time5) { this.pb_ListenScene.Load(Application.StartupPath + @"\Tests\images\" + this.SPicturePaths[length - 1]); this.pb_ListenScene1.Load(Application.StartupPath + @"\Tests\images\" + this.SPicturePaths[length - 1]); } } } else { this.ckb_viewSpeakingText.Visible = false; } if (this.rb_TestMode.Checked && ((this.MP3Player.CurrentPosition + 1) < this.MP3Player.Duration)) { base.btn_preQuestion.Enabled = false; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("ok"); } if (this.MP3Player.CurrentPosition < this.MP3Player.Duration) { this.ckb_ShowAnswer.Visible = false; } else { if (!this.HasClickedNext) { base.btn_nextQuestion.Enabled = true; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next1"); } if (this.rb_PracticeMode.Checked) { this.ckb_ShowAnswer.Visible = true; } if (this.QuestionNO > 0) { time6 = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time6); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); } if (this.QuestionNO >= 1) { Question question = (Question)this.TestQuestions.Questions[this.QuestionNO - 1]; switch (question.QuestionType) { case QuestionType.TABEL: if (!this.ckb_ShowAnswer.Checked) { this.lbl_tableAnswer.Visible = false; break; } this.lbl_tableAnswer.Visible = true; this.lbl_tableAnswer.Text = question.RightAnswersStr; break; case QuestionType.SORT: if (question.QuestionType == QuestionType.SORT) { this.rtb_sumQuestion.Rtf = question.QuestionTitle; this.rtb_sumQuestion.Visible = true; num4 = 0; while ((num4 < question.Answer.Length) && (num4 < this.CkbSummary.Length)) { this.RtbSumAnswersToBeSelected[num4].Visible = true; this.CkbSummary[num4].Visible = true; this.RtbSumAnswersToBeSelected[num4].Rtf = (question.Answer[num4]).ToString(); num4++; } for (num4 = 0; num4 < question.RightAnswers.Length; num4++) { this.RtbSumSelected[num4].Visible = true; } this.Timer_Listening.Stop(); } break; default: for (num4 = 0; (num4 < question.Answer.Length) && (num4 < this.CkbReading.Length); num4++) { this.LRtbAnswers[num4].Visible = true; this.LCkbAnswers[num4].Visible = true; this.LRtbAnswers[num4].Rtf = (question.Answer[num4]).ToString(); } break; } if (this.IsQuestionAfter) { this.tabf_Listening.SelectedIndex = LQUESTIONS; this.LoadListeningQA(); this.IsQuestionAfter = false; } } } } if ((this.TestSection == TestingSection.READING) && (this.CurrentReadingStep >= 1)) { time6 = DateTime.ParseExact("00:01", "mm:ss", null); span = (TimeSpan)(DateTime.ParseExact(base.lbl_timeremain.Text.ToString(), "mm:ss", null) - time6); base.lbl_timeremain.Text = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0'); } }
private void btn_LoadTest_Click(object sender, EventArgs e) { this.rtb_writinganswers.Text = ""; try { for (int i = 1; i < 0x1c; i++) { string path = @"users\" + USERNAME + @"\" + i.ToString(); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } this.InitialParas(); this.flash_timer.Stop(); Button button = (Button)sender; string name = button.Name; if (name.Contains("Reading")) { this.TestSection = TestingSection.READING; } if (name.Contains("Listening")) { this.TestSection = TestingSection.LISTENING; } if (name.Contains("Speaking")) { this.TestSection = TestingSection.SPEAKING; } if (name.Contains("Writing")) { this.TestSection = TestingSection.WRITING; } if (name.Contains("Review")) { this.TestSection = TestingSection.REVIEW; } if (name.Contains("Answer")) { this.TestSection = TestingSection.VIEWANSWERS; } if (this.TPONO <= 0) { this.TPONO = Convert.ToInt16(name.Substring(name.Length - 2)) + ((this.CurrentTPOPage - 1) * 10); } if (this.PartNO <= 0) { this.PartNO = 1; } if (this.PassageNO <= 0) { this.PassageNO = 1; } if (!ConstantValues.TPOACTIVED[this.TPONO]) { if (MessageBox.Show("The TPO" + this.TPONO.ToString() + " is not actived yet, Do you want to buy the product?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.OK) { Process.Start("http://item.taobao.com/item.htm?id=12627161348"); new RegisterForm().Show(); } this.TPONO = 0; this.PartNO = 0; this.PassageNO = 0; this.QuestionNO = 0; } else if (this.CheckFileConsistence()) { base.btn_continue.Enabled = true; base.btn_continue.Visible = true; this.BottonsStatus(); this.rb_PracticeMode.Visible = false; this.rb_TestMode.Visible = false; if (this.rb_PracticeMode.Checked) { base.lbl_mode.Text = "PRACTICE MODE"; } else { base.lbl_mode.Text = "TEST MODE"; } XMLFileReader reader = new XMLFileReader(); switch (this.TestSection) { case TestingSection.READING: this.Timer_Listening.Start(); this.lbl_testingSection.Visible = true; this.lbl_testingSection.Text = "Reading Section"; base.lbl_timeremain.ForeColor = SystemColors.ControlText; base.lbl_timeremain.Text = "20:00"; this.ReadingPassageNo = 1; this.QuestionNO = 0; this.tabf_test.SelectedIndex = READING; this.tabf_Reading.SelectedIndex = RDIRECTION; reader = new XMLFileReader(@"Tests\" + this.TPONO + @"\Reading\config.xml"); this.RSpiltQuestionNO = int.Parse(reader.GetAttr("//Passage[@NO=" + this.PassageNO + "]/@spiltQuestionNO")); this.PassageCount = int.Parse(reader.GetAttr("//@passageCount")); base.lbl_timeremain.Text = reader.GetAttr("//Passage[@NO=" + this.PassageNO + "]/@time"); this.RMaterial = new TPOPassage(RtfReader.getRTF(@"Tests\" + this.TPONO.ToString() + @"\Reading\" + this.PassageNO.ToString() + ".txt").Substring(0xb5), RtfReader.getRTF(@"Explanations\" + this.TPONO.ToString() + @"\Reading\P" + this.PassageNO.ToString() + ".txt").Substring(0xb5)); if (!File.Exists(@"Explanations\" + this.TPONO.ToString() + @"\Reading\" + this.ReadingPassageNo.ToString() + ".mp3") || !ConstantValues.TPOEXPLANATION[this.TPONO]) { goto Label_0597; } this.bn_readText.Visible = true; this.bn_readText.Enabled = true; goto Label_05A6; case TestingSection.LISTENING: { this.lbl_testingSection.Visible = true; base.btn_nextQuestion.Enabled = false; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next"); base.btn_preQuestion.Enabled = false; base.btn_preQuestion.BackgroundImage = (Image)this.resmgr.GetObject("ok"); base.lbl_timeremain.ForeColor = SystemColors.ControlText; base.lbl_timeremain.Text = "10:00"; this.lbl_testingSection.Text = "Listening Section"; reader = new XMLFileReader(@"Tests\" + this.TPONO + @"\Listening\questions.xml"); this.PartCount = int.Parse(reader.GetAttr("//parts/@partCount")); string attr = reader.GetAttr("//passage[@NO=" + 2 + "]/pictures/picture/@pictureName"); base.lbl_timeremain.Text = reader.GetAttr("//part[@NO=" + this.PartNO + "]/@timeLimitation"); this.TimeLimitation = DateTime.ParseExact(reader.GetAttr("//part[@NO=" + this.PartNO + "]/@timeLimitation"), "mm:ss", null); this.QuestionCount = int.Parse(reader.GetAttr("//part[@NO=" + this.PartNO + "]/@questionCount")); this.tabf_test.SelectedIndex = LISTENING; this.tabf_Listening.SelectedIndex = LDIRECTION1; if (this.PassageNO <= 1) { this.TestQuestions = new TPOQuestions(RtfReader.getRTF(@"Tests\" + this.TPONO.ToString() + @"\Listening\questions.rtf"), @"Tests\" + this.TPONO.ToString() + @"\Listening\questions.xml", ""); } string str4 = reader.GetAttr("//part[@NO=" + this.PartNO + "]/@partDirection"); try { this.MP3Player = new MP3MCI(); string str5 = string.Concat(new object[] { @"Tests\", this.TPONO, @"\Listening\", str4 }); this.MP3Player.FileName = str5; this.PlayFileName.Text = str5; this.pb_currentpos.Maximum = this.MP3Player.Duration; this.pb_currentpos1.Maximum = this.MP3Player.Duration; this.tb_currentpos.Maximum = this.MP3Player.Duration; this.tb_currentpos1.Maximum = this.MP3Player.Duration; this.MP3Player.play(); this.MP3Player.SetVolume(base.tb_sound.Value.ToString()); this.Timer_Listening.Start(); } catch { MessageBox.Show("open出错!"); } break; } case TestingSection.SPEAKING: this.lbl_testingSection.Visible = true; this.lbl_testingSection.Text = "Speaking Section"; base.btn_nextQuestion.Visible = false; base.btn_preQuestion.Visible = false; this.LoadSpeakingQuestion(); this.tabf_test.SelectedIndex = SPEAKING; this.tabf_speaking.SelectedIndex = SDIRECTION; this.QuestionNO = 1; this.CurrentSpeakingStep = 0; this.Timer_Speaking.Start(); break; case TestingSection.WRITING: this.Timer_Listening.Start(); this.lbl_testingSection.Visible = true; base.btn_nextQuestion.Enabled = false; base.btn_nextQuestion.BackgroundImage = (Image)this.resmgr.GetObject("next"); base.lbl_timeremain.ForeColor = SystemColors.ControlText; base.lbl_timeremain.Text = "03:00"; this.lbl_testingSection.Text = "Writing Section"; base.lbl_questionNO.Text = "Question 1 of 2"; this.LoadWritingQuestion(); this.tabf_test.SelectedIndex = WRITING; this.tabf_writing.SelectedIndex = WDIRECTION; this.CurrentWritingStep = 0; this.Timer_Speaking.Start(); break; case TestingSection.REVIEW: { this.rb_TestMode.Checked = true; int index = this.TPONO % 10; if (index == 0) { index = 10; } this.btn_LoadTest_Click(this.BtnLoadTest[index], e); break; } case TestingSection.VIEWANSWERS: base.btn_continue.Visible = false; this.ReportingScores(); this.tabf_test.SelectedIndex = USERANSWERS; this.btn_NexPage.Visible = false; this.btn_LastPage.Visible = false; base.btn_mainmenu.Visible = true; break; } } return; Label_0597: this.bn_readText.Visible = false; Label_05A6: ; this.TestQuestions = new TPOQuestions(RtfReader.getRTF(@"Tests\" + this.TPONO.ToString() + @"\Reading\questions" + this.PassageNO.ToString() + ".txt").Substring(0xb5), "", RtfReader.getRTF(@"Explanations\" + this.TPONO.ToString() + @"\Reading\Q" + this.PassageNO.ToString() + ".txt").Substring(0xb5)); this.QuestionCount = this.TestQuestions.QuestionCount; this.LoadReadingMaterialAndQA(); if (this.rb_PracticeMode.Checked && (MessageBox.Show("Do you want to load the answers you saved last time?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.OK)) { this.LoadUserAnswer(); } } catch (Exception exception) { MessageBox.Show(exception.StackTrace); } }