Bloom.Publish.PublishModel.LoadBook C# (CSharp) Method

LoadBook() public method

public LoadBook ( BackgroundWorker worker, DoWorkEventArgs doWorkEventArgs ) : void
worker System.ComponentModel.BackgroundWorker
doWorkEventArgs System.ComponentModel.DoWorkEventArgs
return void
        public void LoadBook(BackgroundWorker worker, DoWorkEventArgs doWorkEventArgs)
        {
            _currentlyLoadedBook = BookSelection.CurrentSelection;

            try
            {
                // In case we have any new settings since the last time we were in the Edit tab (BL-3881)
                _currentlyLoadedBook.BringBookUpToDate(new NullProgress());

                using(var tempHtml = MakeFinalHtmlForPdfMaker())
                {
                    if (doWorkEventArgs.Cancel)
                        return;

                    BookletLayoutMethod layoutMethod;
                    if (this.BookletPortion == BookletPortions.AllPagesNoBooklet)
                        layoutMethod = BookletLayoutMethod.NoBooklet;
                    else
                        layoutMethod = BookSelection.CurrentSelection.GetDefaultBookletLayout();

                    // Check memory for the benefit of developers.  The user won't see anything.
                    SIL.Windows.Forms.Reporting.MemoryManagement.CheckMemory(true, "about to create PDF file", false);
                    _pdfMaker.MakePdf(tempHtml.Key, PdfFilePath, PageLayout.SizeAndOrientation.PageSizeName,
                        PageLayout.SizeAndOrientation.IsLandScape, _currentlyLoadedBook.UserPrefs.ReducePdfMemoryUse,
                        LayoutPagesForRightToLeft, layoutMethod, BookletPortion, worker, doWorkEventArgs, View);
                    // Warn the user if we're starting to use too much memory.
                    SIL.Windows.Forms.Reporting.MemoryManagement.CheckMemory(false, "finished creating PDF file", true);
                }
            }
            catch (Exception e)
            {
                //we can't safely do any ui-related work from this thread, like putting up a dialog
                doWorkEventArgs.Result = e;
                //                SIL.Reporting.ErrorReport.NotifyUserOfProblem(e, "There was a problem creating a PDF from this book.");
                //                SetDisplayMode(DisplayModes.WaitForUserToChooseSomething);
                //                return;
            }
        }

Usage Example

Example #1
0
 private void _makePdfBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     e.Result = _model.BookletPortion;             //record what our parameters were, so that if the user changes the request and we cancel, we can detect that we need to re-run
     _model.LoadBook(e);
 }