private void ReSearch() { int MAX_DOCUMENTS = 20; ObjPDFDocuments.ItemsSource = null; if (null != web_library_detail) { string query = TxtSearchTerms.Text; if (!String.IsNullOrEmpty(query)) { List <IndexResult> matches = web_library_detail.library.LibraryIndex.GetFingerprintsForQuery(query); List <TextBlock> text_blocks = new List <TextBlock>(); bool alternator = false; for (int i = 0; i < MAX_DOCUMENTS && i < matches.Count; ++i) { PDFDocument pdf_document = web_library_detail.library.GetDocumentByFingerprint(matches[i].fingerprint); if (null == pdf_document || pdf_document.Deleted) { continue; } string prefix = String.Format("{0:0%} - ", matches[i].score); TextBlock text_block = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, null, VOID_MouseButtonEventHandler, prefix, null); text_blocks.Add(text_block); } ObjPDFDocuments.ItemsSource = text_blocks; if (0 < text_blocks.Count) { ObjPDFDocuments.SelectedIndex = 0; } } } }
void ApplyNewSearch() { ObjDocumentsPanel.Children.Clear(); WebLibraryDetail web_library_detail = ObjLibraryPicker.WebLibraryDetail; if (null != web_library_detail) { string query = ObjSearchFilter.Text; if (!String.IsNullOrEmpty(query)) { HashSet <string> fingerprints = web_library_detail.library.GetDocumentFingerprintsWithKeyword(query); List <PDFDocument> pdf_documents = web_library_detail.library.GetDocumentByFingerprints(fingerprints); List <PDFDocument> pdf_documents_sorted = new List <PDFDocument>(pdf_documents.OrderBy(x => x.TitleCombined)); bool alternator = false; foreach (PDFDocument pdf_document in pdf_documents_sorted) { TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, Feature, OnDocumentClicked); ObjDocumentsPanel.Children.Add(text_doc); } // If the panel is empty, put NONE if (0 == ObjDocumentsPanel.Children.Count) { TextBlock text_doc = new TextBlock(); text_doc.Text = "(none)"; ObjDocumentsPanel.Children.Add(text_doc); } } } }
public void SetItems(MultiMap <string, PDFDocument> items) { // Clear our items PanelItems.Children.Clear(); bool alternator = false; foreach (string author in items.Keys) { TextBlock text_author = new TextBlock(); text_author.ToolTip = text_author.Text = author; text_author.FontWeight = FontWeights.Bold; PanelItems.Children.Add(text_author); List <PDFDocument> pdf_documents_sorted = new List <PDFDocument>(items.Get(author).OrderBy(x => x.YearCombined)); foreach (PDFDocument pdf_document in pdf_documents_sorted) { TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, Features.SimilarAuthor_OpenDoc); PanelItems.Children.Add(text_doc); } } if (0 == PanelItems.Children.Count) { TextBlock text_doc = new TextBlock(); text_doc.Text = "None in this library."; PanelItems.Children.Add(text_doc); } }
private void word_connector_ContextChanged_BACKGROUND_PopulateRecommendations(List <PDFDocument> context_pdf_documents) { // Out with the old... ObjRecommendedCitationsList.Children.Clear(); // In with the new bool added_recommendation = false; bool alternator = false; foreach (PDFDocument pdf_document in context_pdf_documents) { added_recommendation = true; TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, null, RecommendedCitationsMouseDown); ObjRecommendedCitationsList.Children.Add(text_doc); } ObjGridNoRecommendationsInstructions.Visibility = added_recommendation ? Visibility.Collapsed : Visibility.Visible; }
private void RenderDuplicates(List <PDFDocument> duplicate_pdf_documents) { bool alternator = false; foreach (PDFDocument duplicate_pdf_document in duplicate_pdf_documents) { TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(duplicate_pdf_document, ref alternator, Features.DuplicateDetection_OpenDoc); DocsPanel.Children.Add(text_doc); } // If the panel is empty, put NONE if (0 == DocsPanel.Children.Count) { DocsPanel.Visibility = Visibility.Collapsed; } else { DocsPanel.Visibility = Visibility.Visible; } }
private void ReSearch(PDFDocument doc, string query) { int MAX_DOCUMENTS = 20; if (null == doc) { return; } if (!String.IsNullOrEmpty(query)) { List <IndexResult> matches = doc.LibraryRef.Xlibrary.LibraryIndex.GetFingerprintsForQuery(query); WPFDoEvents.InvokeInUIThread(() => { List <TextBlock> text_blocks = new List <TextBlock>(); bool alternator = false; for (int i = 0; i < MAX_DOCUMENTS && i < matches.Count; ++i) { PDFDocument pdf_document = doc.LibraryRef.Xlibrary.GetDocumentByFingerprint(matches[i].fingerprint); if (null == pdf_document || pdf_document.Deleted) { continue; } string prefix = String.Format("{0:0%} - ", matches[i].score); TextBlock text_block = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, null, MouseButtonEventHandler, prefix, null); text_blocks.Add(text_block); } ObjPDFDocuments.ItemsSource = text_blocks; if (0 < text_blocks.Count) { ObjPDFDocuments.SelectedIndex = 0; } }); } }
void ExpeditionPaperSimilarsControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { // Clear the old ObjPapers.Children.Clear(); TxtPleaseRunExpedition.Visibility = Visibility.Visible; AugmentedBindable <PDFDocument> pdf_document_bindable = DataContext as AugmentedBindable <PDFDocument>; if (null == pdf_document_bindable) { return; } PDFDocument pdf_document = pdf_document_bindable.Underlying; List <ExpeditionPaperSuggestions.Result> results = ExpeditionPaperSuggestions.GetRelevantOthers(pdf_document, NumberOfRelevantPapersToDisplay); foreach (ExpeditionPaperSuggestions.Result result in results) { // Do we have specific event handling logic? MouseButtonEventHandler mouse_down_event_handler = null; if (null != PDFDocumentSelected) { mouse_down_event_handler = DocumentDocumentPressed_MouseButtonEventHandler; } string doc_percentage = String.Format("{0:N0}%", 100 * result.relevance); bool alternator = false; TextBlock text_doc = ShowRelevancePercentage ? ListFormattingTools.GetDocumentTextBlock(result.pdf_document, ref alternator, Features.Expedition_TopicDocument, mouse_down_event_handler, doc_percentage + " - ") : ListFormattingTools.GetDocumentTextBlock(result.pdf_document, ref alternator, Features.Expedition_TopicDocument, mouse_down_event_handler, null); ObjPapers.Children.Add(text_doc); } TxtPleaseRunExpedition.Visibility = Visibility.Collapsed; }
internal static void PopulatePanelWithCitations(StackPanel panel, PDFDocument parent_pdf_document, List <Citation> citations, Feature feature, string prefix = "", bool should_add_none_indicator = true) { string fingerprint_parent = parent_pdf_document.Fingerprint; WebLibraryDetail web_library_detail = parent_pdf_document.LibraryRef; panel.Children.Clear(); List <PDFDocument> pdf_documents = new List <PDFDocument>(); foreach (var citation in citations) { string fingerprint = null; if (0 != fingerprint_parent.CompareTo(citation.fingerprint_inbound)) { fingerprint = citation.fingerprint_inbound; } if (0 != fingerprint_parent.CompareTo(citation.fingerprint_outbound)) { fingerprint = citation.fingerprint_outbound; } if (null == fingerprint) { continue; } PDFDocument pdf_document = web_library_detail.Xlibrary.GetDocumentByFingerprint(fingerprint); if (null == pdf_document) { continue; } if (pdf_document.Deleted) { continue; } pdf_documents.Add(pdf_document); } List <PDFDocument> pdf_documents_sorted = new List <PDFDocument>(pdf_documents.OrderBy(x => x.YearCombined)); bool alternator = false; foreach (PDFDocument pdf_document in pdf_documents_sorted) { TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, Features.Citations_OpenDoc, null, prefix); panel.Children.Add(text_doc); } // If the panel is empty, put NONE if (should_add_none_indicator) { if (0 == pdf_documents_sorted.Count) { TextBlock text_doc = new TextBlock(); text_doc.Text = "(none)"; panel.Children.Add(text_doc); } } }
private void PopulateDetail(bool detailed_mode) { // Clear the old ObjHeader.Header = null; ObjHeader.ToolTip = null; ObjPapers.Children.Clear(); // Try to get the context TopicOverviewData tod = DataContext as TopicOverviewData; if (null == tod) { return; } // Quick refs ExpeditionDataSource eds = tod.web_library_detail.Xlibrary?.ExpeditionManager?.ExpeditionDataSource; if (null != eds) { LDAAnalysis lda_analysis = eds.LDAAnalysis; // First the terms header { string header = eds.GetDescriptionForTopic(tod.topic); ObjHeader.Header = header; ObjHeader.ToolTip = header; ObjHeader.HeaderBackground = new SolidColorBrush(eds.Colours[tod.topic]); } // Then the docs { int NUM_DOCS = Math.Min(detailed_mode ? 50 : 10, lda_analysis.NUM_DOCS); ASSERT.Test(tod.topic >= 0); ASSERT.Test(tod.topic < lda_analysis.NUM_TOPICS); for (int d = 0; d < NUM_DOCS && d < eds.docs.Count; ++d) { DocProbability[] docs = lda_analysis.DensityOfDocsInTopicsSorted[tod.topic]; ASSERT.Test(docs != null); ASSERT.Test(docs.Length == lda_analysis.NUM_DOCS); DocProbability lda_elem = docs[d]; ASSERT.Test(lda_elem != null); PDFDocument pdf_document = tod.web_library_detail.Xlibrary.GetDocumentByFingerprint(eds.docs[lda_elem.doc]); string doc_percentage = String.Format("{0:N0}%", 100 * lda_elem.prob); bool alternator = false; TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, Features.Expedition_TopicDocument, TopicDocumentPressed_MouseButtonEventHandler, doc_percentage + " - "); ObjPapers.Children.Add(text_doc); } // The MORE button if (!detailed_mode && NUM_DOCS < eds.docs.Count) { AugmentedButton button_more = new AugmentedButton(); button_more.Caption = "Show me more"; button_more.Click += button_more_Click; ObjPapers.Children.Add(button_more); } // The BRAINSTORM button { AugmentedButton button_brainstorm = new AugmentedButton(); button_brainstorm.Caption = "Show me in Brainstorm"; button_brainstorm.Click += button_brainstorm_Click; button_brainstorm.Tag = tod; ObjPapers.Children.Add(button_brainstorm); } } } }