private void nextBtn_Click(object sender, EventArgs e) { // check NewWordItem curTestWord = (NewWordItem)m_testWords[m_curTestWordIndex]; int checkedIndex = -1; for (int i = 0; i < m_testWordRatioButtons.Count; i++ ) { if (((RadioButton)m_testWordRatioButtons[i]).Checked) { checkedIndex = i; break; } } if (checkedIndex >= 0) { if (curTestWord.Meaning == ((RadioButton)m_testWordRatioButtons[checkedIndex]).Text) { m_correctWords.Add(curTestWord); } } else { MessageBox.Show("You must choose one to proceed!"); return; } m_curTestWordIndex++; if (m_curTestWordIndex < m_testWords.Count) { UpdateWordUI(); } else { Result result; result.correctWords = (ArrayList)m_correctWords.Clone(); result.totalWords = m_testWords.Count; result.wrongWords = new ArrayList(); result.costTime = DateTime.Now - m_startTime; result.wrongWordsOptions = new Dictionary<string, ArrayList>(); for (int i = 0; i < m_testWords.Count; i++) { if (result.correctWords.Contains(m_testWords[i])) continue; result.wrongWords.Add(((NewWordItem)m_testWords[i]).Clone()); ArrayList wrongWordOption; if ( m_wordToOptionMap.TryGetValue( ((NewWordItem)m_testWords[i]).Name, out wrongWordOption) ) { NewWordItem word = (NewWordItem)result.wrongWords[result.wrongWords.Count-1]; ArrayList optionWords = new ArrayList(); foreach ( NewWordItem optionWord in wrongWordOption ) { optionWords.Add(optionWord); } result.wrongWordsOptions.Add(word.Name, optionWords); } } QuizResult resultDlg = new QuizResult( result ); this.Close(); this.Hide(); resultDlg.ShowDialog(MainDlg.Instance); } }
private void nextBtn_Click(object sender, EventArgs e) { // check NewWordItem curTestWord = (NewWordItem)m_testWords[m_curTestWordIndex]; int checkedIndex = -1; for (int i = 0; i < m_testWordRatioButtons.Count; i++) { if (((RadioButton)m_testWordRatioButtons[i]).Checked) { checkedIndex = i; break; } } if (checkedIndex >= 0) { if (curTestWord.Meaning == ((RadioButton)m_testWordRatioButtons[checkedIndex]).Text) { m_correctWords.Add(curTestWord); } } else { MessageBox.Show("You must choose one to proceed!"); return; } m_curTestWordIndex++; if (m_curTestWordIndex < m_testWords.Count) { UpdateWordUI(); } else { Result result; result.correctWords = (ArrayList)m_correctWords.Clone(); result.totalWords = m_testWords.Count; result.wrongWords = new ArrayList(); result.costTime = DateTime.Now - m_startTime; result.wrongWordsOptions = new Dictionary <string, ArrayList>(); for (int i = 0; i < m_testWords.Count; i++) { if (result.correctWords.Contains(m_testWords[i])) { continue; } result.wrongWords.Add(((NewWordItem)m_testWords[i]).Clone()); ArrayList wrongWordOption; if (m_wordToOptionMap.TryGetValue(((NewWordItem)m_testWords[i]).Name, out wrongWordOption)) { NewWordItem word = (NewWordItem)result.wrongWords[result.wrongWords.Count - 1]; ArrayList optionWords = new ArrayList(); foreach (NewWordItem optionWord in wrongWordOption) { optionWords.Add(optionWord); } result.wrongWordsOptions.Add(word.Name, optionWords); } } QuizResult resultDlg = new QuizResult(result); this.Close(); this.Hide(); resultDlg.ShowDialog(MainDlg.Instance); } }