示例#1
0
 private void ProcessPdfFurtherAndSave(ProcessPdfWithGhostscript.OutputType type, string outputPath)
 {
     if (type == ProcessPdfWithGhostscript.OutputType.Printshop &&
         !Bloom.Properties.Settings.Default.AdobeColorProfileEula2003Accepted)
     {
         var prolog = L10NSharp.LocalizationManager.GetString(@"PublishTab.PrologToAdobeEula",
                                                              "Bloom uses Adobe color profiles to convert PDF files from using RGB color to using CMYK color.  This is part of preparing a \"PDF for a print shop\".  You must agree to the following license in order to perform this task in Bloom.",
                                                              @"Brief explanation of what this license is and why the user needs to agree to it");
         using (var dlg = new Bloom.Registration.LicenseDialog("AdobeColorProfileEULA.htm", prolog))
         {
             dlg.Text = L10NSharp.LocalizationManager.GetString(@"PublishTab.AdobeEulaTitle",
                                                                "Adobe Color Profile License Agreement", @"dialog title for license agreement");
             if (dlg.ShowDialog() != DialogResult.OK)
             {
                 var msg = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfNotSavedWhy",
                                                                   "The PDF file has not been saved because you chose not to allow producing a \"PDF for print shop\".",
                                                                   @"explanation that file was not saved displayed in a message box");
                 var heading = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfNotSaved",
                                                                       "PDF Not Saved", @"title for the message box");
                 MessageBox.Show(msg, heading, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return;
             }
         }
         Bloom.Properties.Settings.Default.AdobeColorProfileEula2003Accepted = true;
         Bloom.Properties.Settings.Default.Save();
     }
     using (var progress = new SIL.Windows.Forms.Progress.ProgressDialog())
     {
         progress.ProgressRangeMinimum = 0;
         progress.ProgressRangeMaximum = 100;
         progress.Overview             = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.Saving",
                                                                                 "Saving PDF...",
                                                                                 @"Message displayed in a progress report dialog box");
         progress.BackgroundWorker         = new BackgroundWorker();
         progress.BackgroundWorker.DoWork += (object sender, DoWorkEventArgs e) => {
             var pdfProcess = new ProcessPdfWithGhostscript(type, sender as BackgroundWorker);
             pdfProcess.ProcessPdfFile(PdfFilePath, outputPath, false);
         };
         progress.BackgroundWorker.ProgressChanged += (object sender, ProgressChangedEventArgs e) => {
             progress.Progress = e.ProgressPercentage;
             var status = e.UserState as string;
             if (!String.IsNullOrWhiteSpace(status))
             {
                 progress.StatusText = status;
             }
         };
         progress.ShowDialog();                  // will start the background process when loaded/showing
         if (progress.ProgressStateResult != null && progress.ProgressStateResult.ExceptionThatWasEncountered != null)
         {
             string shortMsg = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.ErrorSaving",
                                                                       "Error compressing or recoloring the PDF file",
                                                                       @"Message briefly displayed to the user in a toast");
             var longMsg = String.Format("Exception encountered processing the PDF file: {0}", progress.ProgressStateResult.ExceptionThatWasEncountered);
             NonFatalProblem.Report(ModalIf.None, PassiveIf.All, shortMsg, longMsg, progress.ProgressStateResult.ExceptionThatWasEncountered);
         }
     }
 }
示例#2
0
        public void MakeBooklet()
        {
            if (IsMakingPdf)
            {
                // Can't start again until this one finishes
                return;
            }
            _model.PdfGenerationSucceeded = false;             // and so it stays unless we generate it successfully.
            if (_uploadRadio.Checked)
            {
                // We aren't going to display it, so don't bother generating it unless the user actually uploads.
                // Unfortunately, the completion of the generation process is normally responsible for putting us into
                // the right display mode for what we generated (or failed to), after this routine puts us into the
                // mode that shows generation is pending. For the upload button case, we want to go straight to the Upload
                // mode, so the upload control appears. This is a bizarre place to do it, but I can't find a better one.
                SetDisplayMode(PublishModel.DisplayModes.Upload);
                return;
            }
            if (_epubRadio.Checked)
            {
                // We aren't going to display it, so don't bother generating it.
                // Unfortunately, the completion of the generation process is normally responsible for putting us into
                // the right display mode for what we generated (or failed to), after this routine puts us into the
                // mode that shows generation is pending. For the ePUB button case, we want to go straight to the ePUB preview.
                SetDisplayMode(PublishModel.DisplayModes.EPUB);
                return;
            }

            SetDisplayMode(PublishModel.DisplayModes.Working);

            using (_progress = new SIL.Windows.Forms.Progress.ProgressDialog())
            {
                _progress.Overview = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.Creating",
                                                                             "Creating PDF...",
                                                                             @"Message displayed in a progress report dialog box");
                _progress.BackgroundWorker = _makePdfBackgroundWorker;
                _makePdfBackgroundWorker.ProgressChanged += UpdateProgress;
                _progress.ShowDialog();                 // will start the background process when loaded/showing
                _makePdfBackgroundWorker.ProgressChanged -= UpdateProgress;
                _progress.BackgroundWorker = null;
                if (_progress.ProgressStateResult != null && _progress.ProgressStateResult.ExceptionThatWasEncountered != null)
                {
                    string shortMsg = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.ErrorProcessing",
                                                                              "Error creating, compressing, or recoloring the PDF file",
                                                                              @"Message briefly displayed to the user in a toast");
                    var longMsg = String.Format("Exception encountered processing the PDF file: {0}", _progress.ProgressStateResult.ExceptionThatWasEncountered);
                    NonFatalProblem.Report(ModalIf.None, PassiveIf.All, shortMsg, longMsg, _progress.ProgressStateResult.ExceptionThatWasEncountered);
                }
            }
            _progress = null;
        }