private void ObjCitationClusterEditorControl_CitationClusterOpenPDFByReferenceKey(string reference_key) { CSLProcessorBibTeXFinder.MatchingBibTeXRecord matching_bibtex_record = CSLProcessorBibTeXFinder.LocateBibTexForCitationItem(reference_key, web_library_detail.library); if (null != matching_bibtex_record) { MainWindowServiceDispatcher.Instance.OpenDocument(matching_bibtex_record.pdf_document); } }
private void Refresh_BACKGROUND(WebLibraryDetail primary_library) { StatusManager.Instance.UpdateStatus("UsedCitations", "Finding used citations..."); try { // Get the citations from Word List <CitationCluster> citation_clusters = WordConnector.Instance.GetAllCitationClustersFromCurrentDocument(); Dictionary <string, CSLProcessorBibTeXFinder.MatchingBibTeXRecord> bitex_items = CSLProcessorBibTeXFinder.Find(citation_clusters, primary_library); // Catalogue the citations List <UsedCitation> used_citations = new List <UsedCitation>(); List <MissingCitation> missing_citations = new List <MissingCitation>(); foreach (CitationCluster citation_cluster in citation_clusters) { foreach (CitationItem citation_item in citation_cluster.citation_items) { CSLProcessorBibTeXFinder.MatchingBibTeXRecord bibtex_record = bitex_items[citation_item.reference_key]; if (null != bibtex_record) { PDFDocument pdf_document = bibtex_record.pdf_document; used_citations.Add(new UsedCitation { citation_cluster = citation_cluster, citation_item = citation_item, pdf_document = pdf_document }); } else { missing_citations.Add(new MissingCitation { citation_cluster = citation_cluster, citation_item = citation_item }); } } } // Sort them by author used_citations.Sort(delegate(UsedCitation p1, UsedCitation p2) { return(String.Compare(p1.pdf_document.AuthorsCombined, p2.pdf_document.AuthorsCombined)); }); WPFDoEvents.InvokeInUIThread(() => { // Store them for the GUI latest_used_citations = used_citations; latest_missing_citations = missing_citations; // First set the used citations List <PDFDocument> pdf_documents = new List <PDFDocument>(); used_citations.ForEach(o => pdf_documents.Add(o.pdf_document)); ObjUsedCitationsCatalog.SetPDFDocuments(pdf_documents); // Then set the missing citations ObjMissingCitationsList.Children.Clear(); foreach (MissingCitation missing_citation in missing_citations) { TextBlock text_doc = new TextBlock(); text_doc.Text = missing_citation.citation_item.reference_key; text_doc.Tag = missing_citation; text_doc.MouseDown += text_doc_MouseDown; ListFormattingTools.AddGlowingHoverEffect(text_doc); ObjMissingCitationsList.Children.Add(text_doc); } // Only show the missing area if we have missing items... ObjGridMissingCitations.Visibility = (0 < missing_citations.Count) ? Visibility.Visible : Visibility.Collapsed; }); } catch (Exception ex) { Logging.Error(ex, "There was an exception while looking for used citations."); MessageBoxes.Error("There was a problem while looking for used citations. Are you sure Word is running?"); } StatusManager.Instance.UpdateStatus("UsedCitations", "Found used citations"); }