public XpsUserControl(ScienceResearchDataSetNew.关键词Row _gjc, ScienceResearchDataSetNew.单词Row dc) { InitializeComponent(); xpsReferTabItemUserControl = new XpsReferTabItemUserControl(); xpsReferTabItemUserControl.type = "xps"; referGrid.Children.Add(xpsReferTabItemUserControl); gjc = _gjc; if (gjc == null) { title = "关键词=null" + ",单词=" + dc.单词; } else { title = "关键词=" + gjc.关键词 + ",单词=" + dc.单词; } keyword = dc.单词; UsedPaper paperUsedClass = new UsedPaper(); paperList = paperUsedClass.provide_paper("xps文件"); current_paper = 0; current_page = 0; selection("next"); //OpenFile(null); }
/// <summary> /// 生成ReferText和Xps标签页 /// </summary> /// <param name="gjc_page"></param> /// <param name="dc_page"></param> private void createReferTextXps(ScienceResearchDataSetNew.关键词Row gjc_page, ScienceResearchDataSetNew.单词Row dc_page) { //ReferTabItem TabItem referTabItemTabItem; if (ModeSetup.pipeiDictionary["is_dc_ckwz_pipei"] == "是") { ReferTabItemUserControl referTabItemUserControl = new DcPipeiReferTabItemUserControl(gjc_page, dc_page); referTabItemTabItem = new TabItem(); referTabItemTabItem.Header = dc_page.单词; referTabItemTabItem.Content = referTabItemUserControl; referUserControl_using.referTabControl.Items.Add(referTabItemTabItem); referTabItemUserControl.zhinengPipeiUserControl.shibie_control(); } //对该单词生成一个Xps控件 if (ModeSetup.pipeiDictionary["is_dc_xps_pipei"] == "是") { XpsUserControl xpsUserControl = new XpsUserControl(gjc_page, dc_page); referTabItemTabItem = new TabItem(); referTabItemTabItem.Header = dc_page.单词; referTabItemTabItem.Content = xpsUserControl; referUserControl_using.referTabControl.Items.Add(referTabItemTabItem); } }
/// <summary> /// 对富文本框中的单词进行识别 /// </summary> private void shibie_rtb_dc(RichTextBox rtb) { //TextRange range = rtb.Selection; //TextPointer tp1 = range.Start; //TextPointer tp2 = range.End; for (int i = 0; i < dc_dt.Rows.Count; i++) { ScienceResearchDataSetNew.单词Row dc = (ScienceResearchDataSetNew.单词Row)dc_dt.Rows[i]; string dc_str = dc.单词; string fenlei_str = dc.分类; if (allRadioButton.IsChecked == true) { TextProcessClass.ChangeColor(ColorManager.color_mode_word, rtb, dc_str, "前景"); } else if (fenleiRadioButton.IsChecked == true && modeFenleiTextBox.Text == fenlei_str) { TextProcessClass.ChangeColor(ColorManager.color_mode_word, rtb, dc_str, "前景"); } else if (keywordRadioButton.IsChecked == true) { List <ScienceResearchDataSetNew.关键词Row> currentGjcAndSons = MainWindow.keywordTreeUserControl.currentGjcAndSons; foreach (ScienceResearchDataSetNew.单词_关键词Row dc_gjc in dc.Get单词_关键词Rows()) { if (currentGjcAndSons.Contains(dc_gjc.关键词Row)) { TextProcessClass.ChangeColor(ColorManager.color_mode_word, rtb, dc_str, "前景"); break; } } } } //range.Select(tp1, tp2); }
int dc_yujing = 7; //单词语境长度 /// <summary> /// 构造函数 /// </summary> /// <param name="_gjc"></param> /// <param name="dc"></param> public DcPipeiReferTabItemUserControl(ScienceResearchDataSetNew.关键词Row _gjc, ScienceResearchDataSetNew.单词Row dc) { gjc = _gjc; string title; if (gjc == null) { title = "关键词=null" + ",单词=" + dc.单词; } else { title = "关键词=" + gjc.关键词 + ",单词=" + dc.单词; } Run run = new Run(title); paragraph.Inlines.Add(run); flowDocument.Blocks.Add(paragraph); richTextBox.Document = flowDocument; keyword = dc.单词; //进行匹配 get_pipei_result(); //着色 TextProcessClass.ChangeColor(ColorManager.color_mode_word, richTextBox, keyword, "前景"); //调整宽度 textboxInkcavasUserControl.paragraphRichTextBox.Width = MainWindow.yd_ck_width; textboxInkcavasUserControl.inkCanvas.Width = MainWindow.yd_ck_width; zhinengPipeiUserControl.referTabItemUserControl = this; zhinengPipeiUserControl.type = "refer"; }
/// <summary> /// 获取同单词word对应的段图、段文和Xps文件 /// </summary> /// <param name="danci"></param> public void pipei_dc(string danci) { if (danci != "") { set_refer(); danci = danci.Replace("\r", ""); danci = danci.Replace("\n", ""); var dc_list = (from dc in dc_dt where dc.单词 == danci select dc).ToList(); if (dc_list.Count == 0) { MessageBox.Show("不存在单词:" + danci); return; } var gjc_list = (from dc_gjc in dc_gjc_dt where dc_gjc.单词ID == dc_list[0].ID select dc_gjc.关键词Row).ToList(); if (gjc_list.Count == 0) { createReferTextXps(null, dc_list[0]); } else { string gjc_output_str = "选中的单词含有以下关键词:"; for (int i = 0; i < gjc_list.Count; i++) { //对关键词对应的语段生成段图和段文 if (ModeSetup.pipeiDictionary["is_dc_yd_pipei"] == "是") { var yd_list = (from gjc in gjc_dt join yd_gjc in MainWindow.yd_gjc_dt on gjc.ID equals yd_gjc.关键词ID join yd in MainWindow.yd_dt on yd_gjc.语段ID equals yd.ID where gjc.ID == gjc_list[i].ID select yd).ToList(); for (int j = 0; j < yd_list.Count; j++) { //段图 if (yd_list[j].图片 != "") { ParagraphFigureUserControl paragraphFigureUserControl = new ParagraphFigureUserControl(); ParaResourceClass_PaperDataGrid paraResourceClass_PaperDataGrid = new ParaResourceClass_PaperDataGrid(); paraResourceClass_PaperDataGrid.creat_figure(paragraphFigureUserControl, yd_list[j]); TabItem referTabItemTabItem = new TabItem(); referTabItemTabItem.Header = yd_list[j].ID; referTabItemTabItem.Content = paragraphFigureUserControl; referUserControl_using.referTabControl.Items.Add(referTabItemTabItem); } //段文 if (yd_list[j].语段 != "") { ReferUserControl referUserControl = new ReferUserControl("yd"); ParaResourceClass_PaperDataGrid paraResourceClass_PaperDataGrid = new ParaResourceClass_PaperDataGrid(); paraResourceClass_PaperDataGrid.creat_text(yd_list[j], referUserControl); TabItem referTabItemTabItem = new TabItem(); referTabItemTabItem.Header = yd_list[j].ID; referTabItemTabItem.Content = referUserControl; referUserControl_using.referTabControl.Items.Add(referTabItemTabItem); } } } //ReferText和Xps gjc_output_str += gjc_list[i].关键词 + ","; var dc_list2 = (from dc_gjc in dc_gjc_dt where dc_gjc.关键词ID == gjc_list[i].ID select dc_gjc.单词Row).ToList(); for (int j = 0; j < dc_list2.Count; j++) { //对该单词生成一个ReferText和Xps标签页 ScienceResearchDataSetNew.关键词Row gjc_page = gjc_list[i]; ScienceResearchDataSetNew.单词Row dc_page = dc_list2[j]; createReferTextXps(gjc_page, dc_page); } //对于文章创作标签页,跳参后要将关键词标注 if (type == "paper") { //对keywordDataGrid2中的选项做标识 for (int j = 0; j < keywordDataGrid2.Items.Count; j++) { ScienceResearchDataSetNew.关键词Row drv = keywordDataGrid2.Items[j] as ScienceResearchDataSetNew.关键词Row; string gjc = drv.关键词; if (gjc == gjc_list[i].关键词) { DataGridRow row = (DataGridRow)keywordDataGrid2.ItemContainerGenerator.ContainerFromIndex(j); row.Foreground = new SolidColorBrush(ColorManager.color_mode_word); } } } } } if (referUserControl_using.referTabControl.Items.Count > 0) { referUserControl_using.referTabControl.SelectedIndex = 0; } } }