public static void SaveDesktop() { List <string> restore_settings = new List <string>(); // Get the remembrances List <FrameworkElement> framework_elements = MainWindowServiceDispatcher.Instance.MainWindow.DockingManager.GetAllFrameworkElements(); foreach (FrameworkElement framework_element in framework_elements) { { LibraryControl library_control = framework_element as LibraryControl; if (null != library_control) { Logging.Info("Remembering a library control {0}", library_control.LibraryRef.Id); restore_settings.Add(String.Format("PDF_LIBRARY,{0}", library_control.LibraryRef.Id)); } } { PDFReadingControl pdf_reading_control = framework_element as PDFReadingControl; if (null != pdf_reading_control) { PDFDocument pdf_document = pdf_reading_control.GetPDFDocument(); ASSERT.Test(pdf_document != null); if (pdf_document != null) { Logging.Info("Remembering a PDF reader {0}", pdf_document.Fingerprint); restore_settings.Add(String.Format("PDF_DOCUMENT,{0},{1}", pdf_document.LibraryRef.Id, pdf_document.Fingerprint)); } } } } // Store the remembrances File.WriteAllLines(Filename, restore_settings); }
public JumpToSectionPopup(PDFReadingControl pdf_reading_control) { InitializeComponent(); this.pdf_reading_control = pdf_reading_control; popup = new AugmentedPopup(this); // Add the bit explaining how to use bookmarks { TextBlock tb = new TextBlock(); tb.FontWeight = FontWeights.Bold; tb.Text = "Bookmarks:"; Children.Add(tb); } { { MenuItem mi = new MenuItem(); mi.Header = "" + "You can create up to 9 bookmarks while reading a PDF by\n" + "holding down CTRL+SHIFT and pressing a number from 1 to 9."; Children.Add(mi); } { MenuItem mi = new MenuItem(); mi.Header = "" + "You can later jump to a remembered bookmark by\n" + "holding down CTRL and pressing a number from 1 to 9."; Children.Add(mi); } } Children.Add(new AugmentedSpacer()); // Then add the sections { TextBlock tb = new TextBlock(); tb.FontWeight = FontWeights.Bold; tb.Text = "Sections:"; Children.Add(tb); } // If there are not enough bookmarks, go the OCR route PDFDocument pdf_document = pdf_reading_control.GetPDFDocument(); ASSERT.Test(pdf_document != null); // First try from the PDF if (pdf_document != null) { BuildPopupFromPDF build_popup_from_pdf = new BuildPopupFromPDF(this, pdf_document); build_popup_from_pdf.BuildMenu(); } if (pdf_document != null /* && pdf_document.PDFRenderer.PageCount < 100 -- plenty thesis papers out there with more than 100 pages... removed this arbitrary heuristic */) { BuildPopupFromOCR build_popup_from_ocr = new BuildPopupFromOCR(this, pdf_document); build_popup_from_ocr.BuildMenu(); } //Unloaded += JumpToSectionPopup_Unloaded; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }