/// <summary> /// 删除一篇文章 /// </summary> /// <param name="wz"></param> public static void DeleteWz(ScienceResearchDataSetNew.文章Row wz) { if (MessageBox.Show("确认删除该文章及其所有关键词和语段", "重要", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { //删除所有关键词 List <ScienceResearchDataSetNew.文章_关键词Row> wz_gjc_list = GetWzGjc(wz); foreach (ScienceResearchDataSetNew.文章_关键词Row wz_gjc in wz_gjc_list) { wz_gjc.Delete(); } MainWindow.wz_gjc_ta.Update(MainWindow.wz_gjc_dt); //删除所有语段 OrderedEnumerableRowCollection <ScienceResearchDataSetNew.语段Row> ydCollection = GetYd(wz); foreach (ScienceResearchDataSetNew.语段Row yd in ydCollection) { DeleteYd(yd); } //删除该文章 wz.Delete(); MainWindow.wz_ta.Update(MainWindow.wz_dt); } else { return; } }
/// <summary> /// 获取文章的关键词列表 /// </summary> /// <param name="wz">文章</param> /// <returns>关键词列表</returns> public static List <ScienceResearchDataSetNew.文章_关键词Row> GetWzGjc(ScienceResearchDataSetNew.文章Row wz) { return((from wz_gjc in MainWindow.wz_gjc_dt join gjc in MainWindow.gjc_dt on wz_gjc.关键词ID equals gjc.ID where wz_gjc.文章ID == wz.ID select wz_gjc).ToList()); }
/// <summary> /// 获取某篇文章的匹配结果 /// </summary> /// <param name="filelist"></param> /// <param name="wz"></param> public override void get_pipei_result_paper(string[] filelist, ScienceResearchDataSetNew.文章Row wz) { //对一篇文章进行匹配,将匹配到的结果添加到流文档里面 for (int linenum = 0; linenum <= filelist.Length - 1; linenum++) { if (filelist[linenum].IndexOf(keyword) > -1) { string paper_file_str = wz.文件; string stringInPaper = "[" + wz.ID + "]"; if (paper_file_str != "") //从pdf文件导入的text文件 { for (int j = -dy_yujing / 2; j <= dy_yujing / 2; j++) { if (linenum + j >= 0 && linenum + j <= filelist.Length - 1) { stringInPaper = stringInPaper + filelist[linenum + j]; } } } else //网上下载的文件 { stringInPaper = stringInPaper + filelist[linenum]; } paragraph = new Paragraph(); Run run = new Run(stringInPaper); paragraph.Inlines.Add(run); flowDocument.Blocks.Add(paragraph); if (type_show == "part") { if (count >= 20) { return; } } count = count + 1; } } }
/// <summary> /// 获取匹配结果 /// </summary> protected void get_pipei_result() { //获取匹配的文章 UsedPaper paperUsedClass = new UsedPaper(); List <ScienceResearchDataSetNew.文章Row> paperList = paperUsedClass.provide_paper("text文件"); //按照文章编号循环 for (int i = 1; i <= paperList.Count; i++) { ScienceResearchDataSetNew.文章Row wz = paperList[i - 1]; int paperId = wz.ID; string paperName = wz.文章名; if (paperName == "再别康桥") { //int x = 1; } string paperPath = wz.text文件; paperPath = MainWindow.path_translate(paperPath); try { StreamReader sr = new StreamReader(paperPath, Encoding.Default); sr.Close(); } catch { MessageBox.Show("下列文件不存在:" + paperPath); break; } string[] filelist = TextFile.GetStringArrayInPaper(paperPath); get_pipei_result_paper(filelist, wz); } }
private void paperDataGrid_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { //选择变化时,查询该关键词对应的语段 if (paperDataGrid.SelectedItem != null) { var paper = paperDataGrid.SelectedItem as Paper2; int paperId = paper.ID; ScienceResearchDataSetNew.文章Row wz_using = (ScienceResearchDataSetNew.文章Row)wz_dt.Rows.Find(paperId); string file_str = wz_using.文件; if (file_str != "") { if (MainWindow.paperIdList_left.Contains(paperId) || MainWindow.paperIdList_right.Contains(paperId)) { //MessageBox.Show("该Word文章已经打开"); return; } } //查看是否已经打开 PaperUserControl paperUserControl = new PaperUserControl(paperId); TabItem paperTabItem = new TabItem(); string paperNameString; if (paper.文章名.Length > 3) { paperNameString = "[" + paperId + "]" + paper.文章名.Substring(0, 3); } else { paperNameString = "[" + paperId + "]" + paper.文章名; } Label headerLabel = new Label(); headerLabel.Content = paperNameString; paperTabItem.Header = headerLabel; paperTabItem.Content = paperUserControl; headerLabel.MouseLeftButtonUp += HeaderLabel_MouseLeftButtonUp; if (MainWindow.isZheng) { if (!MainWindow.paperIdList_left.Contains(paperId)) { paperUserControl.location = "left"; MainWindow.mainWindow.leftTabControl.Items.Add(paperTabItem); headerLabel.MouseDoubleClick += HeaderLabelLeft_MouseDoubleClick; MainWindow.paperIdList_left.Add(paperId); MainWindow.paperUserControlList_left.Add(paperUserControl); MainWindow.paperUserControlTabItemList_left.Add(paperTabItem); } else { //MessageBox.Show("该文章已经在左栏打开"); } } else { if (!MainWindow.paperIdList_right.Contains(paperId)) { paperUserControl.location = "right"; MainWindow.mainWindow.rightTabControl.Items.Add(paperTabItem); headerLabel.MouseDoubleClick += HeaderLabelRight_MouseDoubleClick; MainWindow.paperIdList_right.Add(paperId); } else { //MessageBox.Show("该文章已经在右栏打开"); } } } }
/// <summary> /// 获取文章的所有语段 /// </summary> /// <param name="wz">文章</param> /// <returns>语段有序集合</returns> public static OrderedEnumerableRowCollection <ScienceResearchDataSetNew.语段Row> GetYd(ScienceResearchDataSetNew.文章Row wz) { return(from data_item in MainWindow.yd_dt where data_item.文章ID == wz.ID orderby data_item.排序 ascending select data_item); }
public override void get_pipei_result_paper(string[] filelist, ScienceResearchDataSetNew.文章Row wz) { //获取一篇文章中的匹配结果 //判断该文章是从网上下载的text文件还是pdf文件 string pdf_or_text; int num_paper_lines = filelist.Count(); int juhao = 0; //每一段话是不是以句号结尾 foreach (string line_str in filelist) { if (line_str != "") { string s = line_str.Substring(line_str.Length - 1, 1); if (s == "." || s == "!" || s == "?" || s == "。" || s == "!" || s == "?") { juhao++; } } } if ((double)juhao / num_paper_lines > .8) { pdf_or_text = "text"; } else { pdf_or_text = "pdf"; } //--------------匹配由pdf导出的text文件---------------------------------------------------- //前后若干句称为一段,看看能不能匹配上 if (pdf_or_text == "pdf") { for (int linenum = pdf_yd_line / 2; linenum <= filelist.Length - 1 - pdf_yd_line / 2; linenum += pdf_yd_line) { string pdf_yd_str = ""; for (int j = -pdf_yd_line / 2; j <= pdf_yd_line / 2; j++) { pdf_yd_str = pdf_yd_str + filelist[linenum + j]; } //判定该语段是否含有该模式 List <int> mode_int_list = ZhinengPipeiUserControl.shibie_para_yd(pdf_yd_str); if (mode_int_list.Contains(yd_id)) { string paper_file_str = wz.文件; string stringInPaper = "[" + wz.ID + "]"; stringInPaper = stringInPaper + pdf_yd_str; paragraph = new Paragraph(); Run run = new Run(stringInPaper); paragraph.Inlines.Add(run); flowDocument.Blocks.Add(paragraph); if (type_show == "part") { if (count >= 20) { return; } } count = count + 1; } } } //--------------匹配text文件---------------------------------------------------- //一段一段匹配,看看能不能匹配上 if (pdf_or_text == "text") { } }
/// <summary> /// 获取某篇文章的匹配结果 /// </summary> /// <param name="filelist"></param> /// <param name="wz"></param> public abstract void get_pipei_result_paper(string[] filelist, ScienceResearchDataSetNew.文章Row wz);
/// <summary> /// 段文标签页 /// </summary> /// <param name="wz"></param> public ReferTabItemUserControl(ScienceResearchDataSetNew.文章Row wz) { //用于显示文章内容 InitializeComponent(); //saveToolBar.Visibility = Visibility.Collapsed; partAllToolBar.Visibility = Visibility.Collapsed; scienceResearchKey = MainWindow.scienceResearchKey; partRadioButton.IsChecked = true; type = "wz"; textboxInkcavasUserControl.type = "wz"; richTextBox = textboxInkcavasUserControl.paragraphRichTextBox; //FlowDocument flowDocument = new FlowDocument(); //flowDocument.LineHeight = 50; //Paragraph paragraph = new Paragraph(); //string title = "文章=" + wz.文章名; //Run run = new Run(title); //paragraph.Inlines.Add(run); //flowDocument.Blocks.Add(paragraph); //richTextBox.Document = flowDocument; textboxInkcavasUserControl.wz = wz; //---------------------读取文章------------------------------------------------ path_wz = wz.text文件; path_wz = MainWindow.path_translate(path_wz); //判断文章是否存在 try { StreamReader sr = new StreamReader(path_wz, Encoding.Default); sr.Close(); } catch { MessageBox.Show("下列文件不存在:" + path_wz); } //读取文章 string line_paper_str = TextFile.GetFileString(path_wz); //----------------------填充RichTextBox-------------------------------- if (line_paper_str.Length >= 13 && line_paper_str.Substring(0, 13) == "<FlowDocument") { richTextBox.Document = xamlManageClass.xaml_load(line_paper_str); } else { FlowDocument doc = new FlowDocument(); doc.LineHeight = 10; Paragraph p = new Paragraph(); p.LineHeight = 30; Run r = new Run(line_paper_str); //r.SetBinding(Run.TextProperty, binding); p.Inlines.Add(r); doc.Blocks.Add(p); richTextBox.Document = doc; } textboxInkcavasUserControl.paragraphRichTextBox.Width = MainWindow.yd_ck_width; textboxInkcavasUserControl.inkCanvas.Width = MainWindow.yd_ck_width; //--------------------加载墨笔-------------------------------------- path_isf = path_wz.Substring(0, path_wz.Length - 3) + "isf"; if (path_isf != "") { FileStream file_ink = new FileStream(path_isf, FileMode.OpenOrCreate); if (file_ink.Length != 0) { textboxInkcavasUserControl.inkCanvas.Strokes = new StrokeCollection(file_ink); } file_ink.Close(); } //----------------------设置智能匹配-------------------------------- zhinengPipeiUserControl.referTabItemUserControl = this; zhinengPipeiUserControl.textboxInkcavasUserControl_using = textboxInkcavasUserControl; zhinengPipeiUserControl.type = "refer"; }