/// <summary>
        /// called after we've safely navigated the browser to about:blank
        /// to avoid the situation where we try to over-write but can't
        /// </summary>
        private void ContinueConversionAndNavigation()
        {
            if (IsAlreadyOpenElsewhere(_incomingPath))
            {
                ErrorReport.NotifyUserOfProblem("That file appears to be open. First close it, then try again.");
            }

            _pathToCurrentlyDisplayedPdf = Path.Combine(Path.GetTempPath(),
                                                        Path.GetFileNameWithoutExtension(_incomingPath) +
                                                        "-booklet.pdf");
            //                _pathToCurrentlyDisplayedPdf = Path.Combine(Path.GetDirectoryName(_incomingPath), Path.GetFileNameWithoutExtension(_incomingPath) + "-booklet.pdf");

            if (!DeleteFileThatMayBeInUse(_pathToCurrentlyDisplayedPdf))
            {
                ErrorReport.NotifyUserOfProblem("For some reason that file is stuck... please try that again.");
            }


            try
            {
                SelectedMethod.Layout(_inputPdf, _incomingPath, _pathToCurrentlyDisplayedPdf, PaperTarget, Settings.Default.RightToLeft, Settings.Default.ShowCropMarks);
                _view.Navigate(_pathToCurrentlyDisplayedPdf);
            }
            catch (Exception error)
            {
                ErrorReport.NotifyUserOfProblem(error, "PdfBooklet was unable to convert that file.");
            }
            _view.UpdateDisplay();
        }
Esempio n. 2
0
//        public void Print()
//        {
//            try
//            {
//                PdfSharp.Pdf.PdfDocument x;
//                PdfFilePrinter y = new PdfFilePrinter(_pathToCurrentlyDisplayedPdf);
//                PdfFilePrinter.AdobeReaderPath =
//                y.Print();
//            }
//            catch(Exception e)
//            {
//                ErrorReport.NotifyUserOfProblem(e, "Could not print");
//            }
//        }

        public void SetLayoutMethod(LayoutMethod method)
        {
            SelectedMethod = method;
            if (HaveIncomingPdf)
            {
                if (method is NullLayoutMethod)
                {
                    _pathToCurrentlyDisplayedPdf = _incomingPath;
                    _view.ClearThenContinue(() => _view.Navigate(_incomingPath));
                }
                else
                {
                    _view.ClearThenContinue(ContinueConversionAndNavigation);
                }
            }
            if (!string.IsNullOrEmpty(_incomingPath) && Settings.Default.PreviousIncomingPath != _incomingPath)
            {
                Settings.Default.PreviousIncomingPath = _incomingPath;
                Settings.Default.Save();
            }
            _view.UpdateDisplay();
        }