private static SubjectStructure subjectPreStructure; //= new SubjectStructure(subjectPre, 1, minisubjectPreStructure); #endregion Fields #region Constructors public MatchArray(string id) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Application.StartupPath + "/SpotTemplate.xml"); //配置共有信息 //配置对应学科 XmlElement xmlnode = xmldoc.GetElementById(id); //xmldoc.SelectSingleNode("//Template"); XmlNode matchSpaceNumnode = xmlnode.SelectSingleNode("matchSpaceNum"); XmlNode matchSpaceNum2node = xmlnode.SelectSingleNode("matchSpaceNum2"); XmlNode matchSelectOptionnode = xmlnode.SelectSingleNode("matchSelectOption"); XmlNode matchSelectOption2node = xmlnode.SelectSingleNode("matchSelectOption2"); matchSpaceNum = matchSpaceNumnode.InnerText; matchSpaceNum2 = matchSpaceNum2node.InnerText; matchSelectOption = matchSelectOptionnode.InnerText; matchSelectOption2 = matchSelectOption2node.InnerText; XmlNode xmlbigSubjectPre = xmlnode.SelectSingleNode("bigSubjectPre"); bigSubjectPre = xmlbigSubjectPre.InnerText.Split(','); XmlNode xmlanswer = xmlnode.SelectSingleNode("answer"); answer = xmlanswer.InnerText.Split(','); XmlNode xmlSubjectStructure = xmlnode.SelectSingleNode("SubjectStructure"); subjectPreStructure = InitSubjectStructure(xmlSubjectStructure); }
/// <summary> /// 过滤内容显示html预览以及添加试题列表节点 /// </summary> /// <param name="isSpot">是否为自动判题,用来判断是否需要显示提示信息</param> private void SubjectContentBuild(bool isSpot, TreeNode treenode, SubjectStructure subjectstructure) { Subject subject = new Subject();//创建试题对象 subject.rangestart = mainContent1.WordBrowers.document.Application.Selection.Range.Start;//取得当前范围 subject.rangeend = mainContent1.WordBrowers.document.Application.Selection.Range.End;//取得当前范围 if (!isexistnode(subject, treenode))//判断是否该题已存在,如果存在提示重新选择 { if (ischildnode(subject, treenode))//并且如果是大题下面的第一级子题,则验证范围界限 { if (behindJudage(subject, treenode))//判断属于题目后面的内容 ,如果选择了该节点前面的内容提示选择, { mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//包括题目前ID号内容的范围 String cliptext = ClipboardHelper.getClipboardText().TrimStart(); subject.subjecttextcontent = cliptext; int prelength = 0;//定义前段返回的字符串 string sequencestr = MatchContent.matchRe(subjectstructure.subjectPre, cliptext, ref prelength); TreeNode tn = new TreeNode(); int sequence = 1;//试题在套卷中的排序号 try { sequence = Int16.Parse(sequencestr); } catch (Exception ex) { sequence = 1; } subject.套卷序号 = sequence; if (cliptext.Length > 20) { tn.Text = cliptext.Substring(0, 20); } else { tn.Text = cliptext; } tn.Tag = subject;//对应内容属性 tn.Expand(); treenode.Nodes.Add(tn); treenode.Expand(); this.propertyGrid.SelectedObject = subject; //if (subjectstructure.childsubjectStructure != null)//判断是否还需判断子题 //{ // int subjectend = 0;//结束结束返回 // bool subjectb = SubjectBuild(tn, subjectstructure.childsubjectStructure, ref subjectend); // if (!subjectb)//没有字节点 // { // int end = 0;//结束位置返回 // bool bansw = answerspot(ref tn, ref end); // if (bansw)//存在答案。更新题目内容界定范围 // { // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, end); // } // else // { // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); // } // mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 // String html = ClipboardHelper.getClipboardHtml(); // HtmlUtil.htmlProcess(ref html); // this.webBrowser.DocumentText = html; // subject.subjecthtmlcontent = html; // subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); // } // else//更新题干或者大题内容范围 // { // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subjectend); // mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 // String html = ClipboardHelper.getClipboardHtml(); // HtmlUtil.htmlProcess(ref html); // this.webBrowser.DocumentText = html; // subject.subjecthtmlcontent = html; // subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); // } //} //else//没有子节点 //{ int end = 0; bool bansw = answerspot(ref tn, ref end); if (bansw || MessageBox.Show("确认此题不需要答案吗?","提示", MessageBoxButtons.OKCancel).Equals(DialogResult.OK))//存在答案。更新题目内容界定范围 { if (bansw) { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, end); } else { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); } } else { treenode.Nodes.Remove(tn); return; //mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); } mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); this.webBrowser.DocumentText = html; subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); // } } else if (!isSpot) { MessageBox.Show("题目子题必须是题目下面的内容!"); } } else if (!isSpot) { MessageBox.Show("子题不能超过大题范围!"); } } else if (!isSpot) { MessageBox.Show("同一内容不能属于多个题目!"); } }
public SubjectStructure(String [] subjectPre,int subjectlevel,SubjectStructure childsubjectStructure) { this.subjectPre=subjectPre; this.subjectlevel = subjectlevel; this.childsubjectStructure = childsubjectStructure; }
/// <summary> /// /// 题目内容建立 /// </summary> /// <param name="treenode">建立所在节点下</param> /// <param name="subjectstructure">题目对应匹配结构</param> /// <returns> 返回是否有子节点</returns> /// private bool SubjectBuild(TreeNode treenode, SubjectStructure subjectstructure,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, subjectstructure.subjectPre, subject.rangestart, subject.rangeend); if (listminisubject.Count == 0) return false; for (int i = 0; i < listminisubject.Count; i++) { SubjectInfo subjectInfoStart = listminisubject[i]; int start = subjectInfoStart.paragraphsStart; if (i == 0)//去第一个子题的头位置 { 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, end); //更新目录栏 SubjectContentBuild(true, treenode, subjectstructure); } return true; } catch (NullReferenceException ex) { return false; // MessageBox.Show("请先在程序中打开word文件。"); } }
/// <summary> /// 英语全局答案分析 /// </summary> /// <param name="subjectstructure"></param> /// <param name="endfor"></param> /// <param name="fatherID">父题的ID</param> /// <returns>返回用来标识是否有子答案</returns> private bool englishAnalyseAnswer(SubjectStructure subjectstructure, int startanswer, int endanswer) { MartianSpot martianSpot = new MartianSpot(); List<SubjectInfo> listminisubject = null; //Subject subject = (Subject)treenode.Tag; try { listminisubject = martianSpot.answerSpot(mainContent1.WordBrowers.document, ref this.progressBarSpot, subjectstructure.subjectPre, startanswer, endanswer); if (listminisubject.Count == 0) return false; for (int i = 0; i < listminisubject.Count; i++) { SubjectInfo subjectInfoStart = listminisubject[i]; int start = subjectInfoStart.paragraphsStart; SubjectInfo subjectInfoEnd; int end; if (i == listminisubject.Count - 1) { //subjectInfoEnd = listminisubject[i]; //object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ //最后一题将范围移动至文档结束 end = endanswer; } else { subjectInfoEnd = listminisubject[i + 1]; end = subjectInfoEnd.paragraphsStart; } //设定选择范围 mainContent1.WordBrowers.document.Application.Selection.SetRange(start, end); //更新目录栏 // analyseAnswerSecond(subjectstructure, fatherID, treenode); //获取答案范围 mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//包括题目前ID号内容的范围 String cliptext = ClipboardHelper.getClipboardText(); int prelength = 0;//定义前段返回的字符串 string sequencestr = MatchContent.matchRe(subjectstructure.subjectPre, cliptext, ref prelength); int sequence = 1;//试题在套卷中的排序号 try { sequence = Int16.Parse(sequencestr); } catch (Exception ex) { sequence = 1; } TreeNode treenodecurrect = englistJudgeAnswerForSubject(sequence);//判断答案对应的树节点 if (treenodecurrect == null) { } else { mainContent1.WordBrowers.document.Application.Selection.SetRange(start + prelength, end); Subject treenodecurrectsubject = (Subject)treenodecurrect.Tag; mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); treenodecurrectsubject.answer.subjecthtmlanswer = HtmlUtil.htmlreplace(html); //treenodecurrectsubject.answer.subjectbinaryanswer = ClipboardHelper.getClipboardEmbed(); treenodecurrectsubject.answer.subjecttextanswer = ClipboardHelper.getClipboardText(); } } return true; } catch (NullReferenceException ex) { return false; // MessageBox.Show("请先在程序中打开word文件。"); } }
/// <summary> /// 过滤内容显示html预览以及添加试题列表节点 /// </summary> /// <param name="isSpot">是否为自动判题,用来判断是否需要显示提示信息</param> private void analyseAnswerSecond(SubjectStructure subjectstructure, int fatherID, TreeNode treenode) { int rangestart = mainContent1.WordBrowers.document.Application.Selection.Range.Start;//取得当前范围 int rangeend = mainContent1.WordBrowers.document.Application.Selection.Range.End;//取得当前范围 mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//包括题目前ID号内容的范围 String cliptext = ClipboardHelper.getClipboardText(); int prelength = 0;//定义前段返回的字符串 string sequencestr = MatchContent.matchRe(subjectstructure.subjectPre, cliptext, ref prelength); int sequence = 1;//试题在套卷中的排序号 try { sequence = Int16.Parse(sequencestr); } catch (Exception ex) { sequence = 1; } TreeNode treenodecurrect = judgeAnswerForSubject(treenode, sequence);//判断答案对应的树节点 if (treenodecurrect == null) { return; } if (subjectstructure.childsubjectStructure != null)//判断是否还需判断子题 { bool subjectb = analyseAnswer(subjectstructure.childsubjectStructure, sequence, treenodecurrect, rangestart, rangeend); if (!subjectb)//没有子节点 { mainContent1.WordBrowers.document.Application.Selection.SetRange(rangestart + prelength, rangeend); Subject treenodecurrectsubject = (Subject)treenodecurrect.Tag; mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); treenodecurrectsubject.answer.subjecthtmlanswer = HtmlUtil.htmlreplace(html); //treenodecurrectsubject.answer.subjectbinaryanswer = ClipboardHelper.getClipboardEmbed(); treenodecurrectsubject.answer.subjecttextanswer = ClipboardHelper.getClipboardText(); } } else//没有子节点 { Subject treenodecurrectsubject = (Subject)treenodecurrect.Tag; mainContent1.WordBrowers.document.Application.Selection.SetRange(rangestart + prelength, rangeend); mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); treenodecurrectsubject.answer.subjecthtmlanswer = HtmlUtil.htmlreplace(html); //treenodecurrectsubject.answer.subjectbinaryanswer = ClipboardHelper.getClipboardEmbed(); treenodecurrectsubject.answer.subjecttextanswer = ClipboardHelper.getClipboardText(); } }
/// <summary> /// 过滤内容显示html预览以及添加试题列表节点 /// </summary> /// <param name="isSpot">是否为自动判题,用来判断是否需要显示提示信息</param> /// <param name="subjectstructure">试题匹配规则正则结构</param> /// <param name="treenode">节点信息</param> private void SubjectContentBuild(bool isSpot, TreeNode treenode, SubjectStructure subjectstructure) { Subject subject = new Subject();//创建试题对象 subject.rangestart = mainContent1.WordBrowers.document.Application.Selection.Range.Start;//取得当前范围 subject.rangeend = mainContent1.WordBrowers.document.Application.Selection.Range.End;//取得当前范围 //if (!isexistnode(subject, treenode) )//判断是否该题已存在 //{ //if (ischildnode(subject, treenode))//判断属于子节点范围 // { mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//包括题目前ID号内容的范围 String cliptext = ClipboardHelper.getClipboardText(); //subject.subjecttextcontent = cliptext; int prelength = 0;//定义前段返回的字符串 TreeNode tn = new TreeNode(); string sequencestr = MatchContent.matchRe(subjectstructure.subjectPre, cliptext, ref prelength); int sequence = 1;//试题在套卷中的排序号 try { sequence = Int16.Parse(sequencestr); } catch (Exception ex) { sequence = 1; } subject.套卷序号 = sequence; //this.webBrowser.DocumentText = html; //subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); if (cliptext.Length > 20) { tn.Text = cliptext.Substring(0, 20); } else { tn.Text = cliptext; } tn.Tag = subject;//对应内容属性 tn.Expand(); treenode.Nodes.Add(tn); treenode.Expand(); this.propertyGrid.SelectedObject = subject; if (subjectstructure.childsubjectStructure != null)//判断是否还需判断子题 { int subjectend = 0;//结束结束返回 bool subjectb = SubjectBuild(tn, subjectstructure.childsubjectStructure, ref subjectend,null,null); if (!subjectb)//没有字节点 { int end = 0;//结束位置返回 bool bansw = AnswerSpot(ref tn, ref end); if (bansw)//存在答案。更新题目内容界定范围 { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, end); } else { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); } mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); FilterHtmlAndShowInWebbrowser(ref html); subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); subject.subjecttextcontent = ClipboardHelper.getClipboardText(); } else//更新题干或者大题内容范围 { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subjectend); mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); html = HtmlUtil.htmlreplace(html); if (!isSpot) { if (html != null && !html.Trim().Equals("")) { try { this.webBrowser.DocumentText = html; } catch { MessageBox.Show("该题无法预览,请重新拆题", "提示"); } } //FilterHtmlAndShowInWebbrowser(ref html); } subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); //subject.subjecttextcontent = ClipboardHelper.getClipboardText(); } } else//没有子节点 { int end = 0; bool bansw = AnswerSpot(ref tn, ref end); if (bansw)//存在答案。更新题目内容界定范围 { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, end); } else { mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); } mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); html = HtmlUtil.htmlreplace(html); if (!isSpot) { if (html != null && !html.Trim().Equals("")) { try { this.webBrowser.DocumentText = html; } catch { MessageBox.Show("该题无法预览,请重新拆题", "提示"); } } //FilterHtmlAndShowInWebbrowser(ref html); } subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); subject.subjecttextcontent = ClipboardHelper.getClipboardText(); } }
/// <summary> /// /// 题目内容建立 /// </summary> /// <param name="treenode">建立所在节点下</param> /// <param name="subjectstructure">题目对应匹配结构</param> /// <returns> 返回是否有子节点</returns> /// private bool SubjectBuild(TreeNode treenode, SubjectStructure subjectstructure, ref int endfor, List<Subject> list2, List<Subject> list3=null,int index=1) { MartianSpot martianSpot = new MartianSpot(); List<SubjectInfo> listminisubject = null; Subject subject1 = (Subject)treenode.Tag; try { listminisubject = martianSpot.subjectSpot(mainContent1.WordBrowers.document, ref this.progressBarSpot, subjectstructure.subjectPre, subject1.rangestart, subject1.rangeend); if (listminisubject.Count == 0) return false; for (int i = 0; i < listminisubject.Count; i++) { SubjectInfo subjectInfoStart = listminisubject[i]; int start = subjectInfoStart.paragraphsStart; if (i == 0)//去第一个子题的头位置 { endfor = start; } SubjectInfo subjectInfoEnd; int end; if (i == listminisubject.Count - 1) { //subjectInfoEnd = listminisubject[i]; //object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ //最后一题将范围移动至文档结束 end = subject1.rangeend; } else { subjectInfoEnd = listminisubject[i + 1]; end = subjectInfoEnd.paragraphsStart; } Subject subject = new Subject();//创建试题对象 subject.rangestart = start;//取得当前范围 subject.rangeend = end;//取得当前范围 var item = list2.Where(x => x.ParentId == subject1.Id).ToList()[i]; subject.ParentId = item.ParentId; subject.Id = item.Id; String cliptext = item.subjecttextcontent; //subject.subjecttextcontent = cliptext; int prelength = 0;//定义前段返回的字符串 TreeNode tn = new TreeNode(); string sequencestr = MatchContent.matchRe(subjectstructure.subjectPre, cliptext, ref prelength); int sequence = 1;//试题在套卷中的排序号 try { sequence = Int16.Parse(sequencestr); } catch (Exception ex) { sequence = 1; } subject.套卷序号 = sequence; //this.webBrowser.DocumentText = html; //subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); string html = item.subjecthtmlcontent; string[] strs = null; //第一层 if (index == 1) { strs = MatchArray.SubjectPreStructure.subjectPre; //第一层需要去掉第二层的内容 var htmls = html.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (var itemHtml in htmls) { if (MatchContent.match(MatchArray.SubjectPreStructure.childsubjectStructure.subjectPre, NoHTML(itemHtml))) { html = html.Substring(0, GetStrIndex(html, itemHtml)); break; } } }else{ //第二层 strs = MatchArray.SubjectPreStructure.childsubjectStructure.subjectPre; } foreach (var sb in strs) { string tempsb = sb; if (tempsb.IndexOf("^") == 0) { tempsb = tempsb.Substring(1); } var match = Regex.Match(html, tempsb); if (match.Success) { html = html.Replace(match.Groups["pre"].Value, ""); } } if (cliptext.Length > 20) { tn.Text = cliptext.Substring(0, 20); } else { tn.Text = cliptext; } tn.Tag = subject;//对应内容属性 tn.Expand(); treenode.Nodes.Add(tn); treenode.Expand(); this.propertyGrid.SelectedObject = subject; if (subjectstructure.childsubjectStructure != null)//判断是否还需判断子题 { int subjectend = 0;//结束结束返回 bool subjectb = SubjectBuild(tn, subjectstructure.childsubjectStructure, ref subjectend, list3, null,index+1); if (!subjectb)//没有字节点 { //end = 0;//结束位置返回 //bool bansw = AnswerSpot(ref tn, ref end); //if (bansw)//存在答案。更新题目内容界定范围 //{ // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, end); //} //else //{ // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); //} //mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 //String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); FilterHtmlAndShowInWebbrowser(ref html); //需过滤题号 subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); //需过滤题号 subject.subjecttextcontent = item.subjecttextcontent; } else//更新题干或者大题内容范围 { //mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subjectend); //mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 //String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); html = HtmlUtil.htmlreplace(html); //if (!isSpot) //{ // if (html != null && !html.Trim().Equals("")) // { // try // { // this.webBrowser.DocumentText = html; // } // catch // { // MessageBox.Show("该题无法预览,请重新拆题", "提示"); // } // } // //FilterHtmlAndShowInWebbrowser(ref html); //} subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); //subject.subjecttextcontent = ClipboardHelper.getClipboardText(); } } else//没有子节点 { end = 0; //bool bansw = AnswerSpot(ref tn, ref end); //if (bansw)//存在答案。更新题目内容界定范围 //{ // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, end); //} //else //{ // mainContent1.WordBrowers.document.Application.Selection.SetRange(subject.rangestart + prelength, subject.rangeend); //} //mainContent1.WordBrowers.document.Application.Selection.Range.Copy();//不包括题目前ID号内容的范围 //String html = ClipboardHelper.getClipboardHtml(); HtmlUtil.HtmlPictureMove(ref html); html = HtmlUtil.HtmlFragmentClear(html); html = HtmlUtil.htmlreplace(html); //if (!isSpot) //{ // if (html != null && !html.Trim().Equals("")) // { // try // { // this.webBrowser.DocumentText = html; // } // catch // { // MessageBox.Show("该题无法预览,请重新拆题", "提示"); // } // } // //FilterHtmlAndShowInWebbrowser(ref html); //} subject.subjecthtmlcontent = html; //subject.subjectbinarycontent = ClipboardHelper.getClipboardEmbed(); // subject.subjecttextcontent = ClipboardHelper.getClipboardText(); subject.subjecttextcontent = item.subjecttextcontent; } //设定选择范围 // mainContent1.WordBrowers.document.Application.Selection.SetRange(start, end); //更新目录栏 //SubjectContentBuild(true, treenode, subjectstructure); } return true; } catch (NullReferenceException ex) { return false; // MessageBox.Show("请先在程序中打开word文件。"); } }