public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { AnswerContent staa = null; Subject[] subject= context.Instance as Subject[]; if (value != null) { staa = (AnswerContent)value; } else { staa = new AnswerContent("(...)"); } EditAnswerContent(ref staa); return staa; }
private void EditAnswerContent(ref AnswerContent value) { using (AnswerEditorForm editorform = new AnswerEditorForm(value.subjecthtmlanswer)) { DialogResult da = editorform.ShowDialog(); if (da.Equals(DialogResult.OK)) { if (editorform.editor1.BodyHtml != null && !editorform.editor1.BodyHtml.Equals("")) { value.subjecthtmlanswer = editorform.editor1.BodyHtml; value.subjecttextanswer = HtmlUtil.RemoveHTML(value.subjecthtmlanswer); } else { value.subjecttextanswer = null; value.subjecthtmlanswer = null; } } } }
private void editanswercontent(ref AnswerContent value) { EditorForm editorform = new EditorForm(value.subjecthtmlanswer); DialogResult da = editorform.ShowDialog(); if (da.Equals(DialogResult.OK)) { if (editorform.editor1.BodyHtml!= null && !editorform.editor1.BodyHtml.Equals("")) { //value.subjectbinaryanswer = editorform.editor1.BodyHtml; //value.subjecttextanswer = editorform.editor1.BodyHtml; value.subjecthtmlanswer = editorform.editor1.BodyHtml; } else { value.subjectbinaryanswer = null; value.subjecttextanswer = null; value.subjecthtmlanswer = null; } editorform.Dispose(); } }
private bool answerspot(ref TreeNode treenode, ref int endfor) { MartianSpot martianSpot = new MartianSpot(); List<SubjectInfo> listminisubject = null; Subject subject = (Subject)treenode.Tag; try { listminisubject = martianSpot.subjectSpot(mainContent1.WordBrowers.document, ref this.progressBarSpot, MatchArray.answerSpot, subject.rangestart, subject.rangeend); if (listminisubject == null || listminisubject.Count == 0) return false; for (int i = 0; i < listminisubject.Count; i++)//答案只有一个所以最后的答案为最终答案 { SubjectInfo subjectInfoStart = listminisubject[i]; int start = subjectInfoStart.paragraphsStart; endfor = start; SubjectInfo subjectInfoEnd; int end; if (i == listminisubject.Count - 1) { //subjectInfoEnd = listminisubject[i]; //object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ //最后一题将范围移动至文档结束 end = subject.rangeend; } else { subjectInfoEnd = listminisubject[i + 1]; end = subjectInfoEnd.paragraphsStart; } //设定选择范围 mainContent1.WordBrowers.document.Application.Selection.SetRange(start + answerprelength, end);//从答案:后面开始录入 //更新目录栏 mainContent1.WordBrowers.document.Application.Selection.Range.Copy(); String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); String cliptext = ClipboardHelper.getClipboardText(); this.webBrowser.DocumentText = html; AnswerContent staa = new AnswerContent(); //staa.subjectbinaryanswer = ClipboardHelper.getClipboardEmbed(); staa.subjecthtmlanswer = html; staa.subjecttextanswer = cliptext; mainContent1.WordBrowers.document.Application.Selection.SetRange(start, start + 4); int typeint = 1; try { string str = mainContent1.WordBrowers.document.Application.Selection.Text; typeint = Int16.Parse(str.Substring(2,1)); } catch (Exception ex) { typeint = 1; } switch (typeint) { case SubjectTypeDefine.singleselecti: staa.selectType = SubjectTypeDefine.singleselect; subject.题目类型 =Subject.SubjecttypeEnum.单选题; break; case SubjectTypeDefine.spacei: staa.selectType = SubjectTypeDefine.space; subject.题目类型 = Subject.SubjecttypeEnum.填空题; break; case SubjectTypeDefine.questioni: staa.selectType = SubjectTypeDefine.question; subject.题目类型 = Subject.SubjecttypeEnum.简答题; break; case SubjectTypeDefine.multiselecti: staa.selectType = SubjectTypeDefine.multiselect; subject.题目类型 = Subject.SubjecttypeEnum.多选题; break; case SubjectTypeDefine.judgei: staa.selectType = SubjectTypeDefine.judge; subject.题目类型 = Subject.SubjecttypeEnum.判断题; break; } subject.answer = staa; } } catch (NullReferenceException ex) { // MessageBox.Show("请先在程序中打开word文件。"); } return true; }