public void Save() { try { // Give a slight preference to USB keys, though if they used a different directory last time, we favor that. if (string.IsNullOrEmpty(_lastDirectory) || !Directory.Exists(_lastDirectory)) { var drives = Palaso.UsbDrive.UsbDriveInfo.GetDrives(); if (drives != null && drives.Count > 0) { _lastDirectory = drives[0].RootDirectory.FullName; } } using (var dlg = new SaveFileDialog()) { if (!string.IsNullOrEmpty(_lastDirectory) && Directory.Exists(_lastDirectory)) { dlg.InitialDirectory = _lastDirectory; } var portion = ""; switch (BookletPortion) { case BookletPortions.AllPagesNoBooklet: portion = "Pages"; break; case BookletPortions.BookletCover: portion = "Cover"; break; case BookletPortions.BookletPages: portion = "Inside"; break; default: throw new ArgumentOutOfRangeException(); } string suggestedName = string.Format("{0}-{1}-{2}.pdf", Path.GetFileName(_currentlyLoadedBook.FolderPath), _collectionSettings.GetLanguage1Name("en"), portion); dlg.FileName = suggestedName; dlg.Filter = "PDF|*.pdf"; if (DialogResult.OK == dlg.ShowDialog()) { _lastDirectory = Path.GetDirectoryName(dlg.FileName); File.Copy(PdfFilePath, dlg.FileName, true); Analytics.Track("Save PDF", new Dictionary <string, string>() { { "Portion", Enum.GetName(typeof(BookletPortions), BookletPortion) }, { "Layout", PageLayout.ToString() } }); } } } catch (Exception err) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem("Bloom was not able to save the PDF. {0}", err.Message); } }
internal void SaveAsEpub() { using (var dlg = new DialogAdapters.SaveFileDialogAdapter()) { if (!string.IsNullOrEmpty(_lastDirectory) && Directory.Exists(_lastDirectory)) { dlg.InitialDirectory = _lastDirectory; } string suggestedName = string.Format("{0}-{1}.epub", Path.GetFileName(BookSelection.CurrentSelection.FolderPath), _collectionSettings.GetLanguage1Name("en")); dlg.FileName = suggestedName; dlg.Filter = "EPUB|*.epub"; if (DialogResult.OK == dlg.ShowDialog()) { _lastDirectory = Path.GetDirectoryName(dlg.FileName); EpubMaker.FinishEpub(dlg.FileName); ReportAnalytics("Save ePUB"); } } }