internal static void Export(List <PDFDocument> pdf_documents)
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Library_BibTexExport);

            string initial_directory = null;

            if (null == initial_directory)
            {
                initial_directory = Path.GetDirectoryName(ConfigurationManager.Instance.ConfigurationRecord.System_LastBibTexExportFile);
            }
            if (null == initial_directory)
            {
                initial_directory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            }

            string initial_filename = null;

            if (null == initial_filename)
            {
                initial_filename = Path.GetFileName(ConfigurationManager.Instance.ConfigurationRecord.System_LastBibTexExportFile);
            }
            if (null == initial_filename)
            {
                initial_filename = "Qiqqa2BibTexExport.bib";
            }

            using (SaveFileDialog dlg = new SaveFileDialog
            {
                CheckFileExists = false,
                CheckPathExists = false,
                Filter = "BibTex Files|*.bib|All Files|*.*",
                InitialDirectory = initial_directory,
                FileName = initial_filename,
                Title = "Where would you like to save your exported BibTex file?"
            })
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    // Remember the filename for next time
                    string filename = dlg.FileName;
                    ConfigurationManager.Instance.ConfigurationRecord.System_LastBibTexExportFile = filename;
                    ConfigurationManager.Instance.ConfigurationRecord_Bindable.NotifyPropertyChanged(() => ConfigurationManager.Instance.ConfigurationRecord.System_LastBibTexExportFile);

                    LibraryExporter_BibTeX.ExportBibTeX(pdf_documents, filename, false);
                }
            }
        }
Esempio n. 2
0
        public static void Export(Library library, List <PDFDocument> pdf_documents, string base_path)
        {
            try
            {
                int MAX_STEPS = 8;

                // Build the directory structure
                StatusManager.Instance.ClearCancelled("LibraryExport");

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Starting library export", 0, MAX_STEPS, true);
                Directory.CreateDirectory(base_path);
                Dictionary <string, PDFDocumentExportItem> pdf_document_export_items = Export_Docs(library, pdf_documents, base_path);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting BibTeX", 1, MAX_STEPS, true);
                LibraryExporter_BibTeX.Export(library, pdf_documents, base_path, pdf_document_export_items, true);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting html", 2, MAX_STEPS, true);
                LibraryExporter_HTML.Export(library, base_path, pdf_document_export_items);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting tabs", 3, MAX_STEPS, true);
                LibraryExporter_Tabs.Export(library, pdf_documents, base_path, pdf_document_export_items);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting BibTeX tabs", 4, MAX_STEPS, true);
                LibraryExporter_BibTeXTabs.Export(library, pdf_documents, base_path, pdf_document_export_items);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting directories", 5, MAX_STEPS, true);
                LibraryExporter_Directories.Export(library, base_path, pdf_document_export_items);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting PDF content", 6, MAX_STEPS, true);
                LibraryExporter_PDFs.Export(library, base_path, pdf_document_export_items);

                if (StatusManager.Instance.IsCancelled("LibraryExport"))
                {
                    return;
                }
                StatusManager.Instance.UpdateStatus("LibraryExport", "Exporting PDF text", 7, MAX_STEPS, true);
                LibraryExporter_PDFText.Export(library, base_path, pdf_document_export_items);

                StatusManager.Instance.UpdateStatus("LibraryExport", "Finished library export");
                Process.Start(base_path);
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem while exporting your library.");
            }
        }