private void AnsversProsess(string rtf, HtmlStore quest) { using (RichTextBox rtq = new RichTextBox()) { rtq.Rtf = rtf; rtq.AppendText("►"); int start = rtq.Find("a)"); string st = "b)"; bool b = true; int n = 98; using (RichTextBox Rta = new RichTextBox()) { int end = rtq.Find(st, start + 2, RichTextBoxFinds.MatchCase); if (end == -1) { end = rtq.Find("►", start + 2, RichTextBoxFinds.MatchCase); b = false;; } while (end != -1) { bool isTrue = false; rtq.Select(start + 2, end - start - 2); Rta.Rtf = rtq.SelectedRtf; start = end; n++; st = (char)n + ")"; if (b) { end = rtq.Find(st, start + 2, RichTextBoxFinds.MatchCase); } else { end = -1; } if ((end == -1) && (b)) { end = rtq.Find("►", start + 2, RichTextBoxFinds.MatchCase); b = false;; } if (Rta.Find("!!!", RichTextBoxFinds.MatchCase) > -1) { Rta.Select(Rta.Find("!!!", RichTextBoxFinds.MatchCase), 3); Rta.SelectedText = String.Empty; isTrue = true; } HtmlStore answer = Rtf2HTML.GetHtml(Rta.Rtf); answer.IsTrue = isTrue; quest.SubItems.Add(answer); } } } }
private void QuestionProsessAsync(object param) { object[] paramArr = (object[])param; string rtf = (string)paramArr[0]; string rtfAnswers = (string)paramArr[1]; ManualResetEvent mre = (ManualResetEvent)paramArr[2]; int questionIndex = (int)paramArr[3] - 2; HtmlStore quest = new HtmlStore(); quest.QuestIndex = questionIndex; lock (_htmlStoreList) _htmlStoreList.Add(quest); Rtf2HTML.GetHtml(rtf, ref quest); AnsversProsess(rtfAnswers, quest); quest.QuestionType = QuestionTypeHelper.GetQuestionType(quest); mre.Set(); }