This class replaces the AdobeReaderControl in the PublishView when the Upload To BloomLibrary.org option is selected.
Inheritance: System.Windows.Forms.UserControl
Esempio n. 1
0
        public void SetDisplayMode(PublishModel.DisplayModes displayMode)
        {
            if (displayMode != PublishModel.DisplayModes.Upload && _publishControl != null)
            {
                Controls.Remove(_publishControl);
                _publishControl    = null;
                _pdfViewer.Visible = true;
            }
            switch (displayMode)
            {
            case PublishModel.DisplayModes.WaitForUserToChooseSomething:
                _printButton.Enabled = _saveButton.Enabled = false;
                Cursor = Cursors.Default;
                _workingIndicator.Visible = false;
                _pdfViewer.Visible        = false;
                break;

            case PublishModel.DisplayModes.Working:
                _printButton.Enabled     = _saveButton.Enabled = false;
                _workingIndicator.Cursor = Cursors.WaitCursor;
                Cursor = Cursors.WaitCursor;
                _workingIndicator.Visible = true;
                break;

            case PublishModel.DisplayModes.ShowPdf:
                if (File.Exists(_model.PdfFilePath))
                {
                    _pdfViewer.Visible        = true;
                    _workingIndicator.Visible = false;
                    Cursor = Cursors.Default;
                    _saveButton.Enabled  = true;
                    _printButton.Enabled = _pdfViewer.ShowPdf(_model.PdfFilePath);
                }
                break;

            case PublishModel.DisplayModes.Upload:
            {
                _workingIndicator.Visible = false;                         // If we haven't finished creating the PDF, we will indicate that in the progress window.
                _saveButton.Enabled       = _printButton.Enabled = false;  // Can't print or save in this mode...wouldn't be obvious what would be saved.
                _pdfViewer.Visible        = false;
                Cursor = Cursors.Default;

                if (_publishControl == null)
                {
                    SetupPublishControl();
                }

                break;
            }
            }
        }
Esempio n. 2
0
        private void SetupPublishControl()
        {
            if (_publishControl != null)
            {
                //we currently rebuild it to update contents, as currently the constructor is where setup logic happens (we could change that)
                Controls.Remove(_publishControl);;
            }

            _publishControl = new BloomLibraryPublishControl(this, _bookTransferrer, _loginDialog,
                                                             _model.BookSelection.CurrentSelection);
            _publishControl.SetBounds(_pdfViewer.Left, _pdfViewer.Top,
                                      _pdfViewer.Width, _pdfViewer.Height);
            _publishControl.Dock   = _pdfViewer.Dock;
            _publishControl.Anchor = _pdfViewer.Anchor;
            var saveBackColor = _publishControl.BackColor;

            Controls.Add(_publishControl);             // somehow this changes the backcolor
            _publishControl.BackColor = saveBackColor; // Need a normal back color for this so links and text can be seen
            // Typically this control is dock.fill. It has to be in front of tableLayoutPanel1 (which is Left) for Fill to work.
            _publishControl.BringToFront();
        }
Esempio n. 3
0
        public void SetDisplayMode(PublishModel.DisplayModes displayMode)
        {
            // This is only supposed to be active in one mode of PublishView.
            Browser.SuppressJavaScriptErrors = false;

            if (displayMode != PublishModel.DisplayModes.Upload && _publishControl != null)
            {
                Controls.Remove(_publishControl);
                _publishControl = null;
            }
            if (displayMode != PublishModel.DisplayModes.EPUB && _epubPreviewControl != null && Controls.Contains(_epubPreviewControl))
            {
                Controls.Remove(_epubPreviewControl);
            }
            if (displayMode != PublishModel.DisplayModes.Android && _androidControl != null && Controls.Contains(_androidControl))
            {
                Controls.Remove(_androidControl);

                // disposal of the browser is good but it hides a multitude of sins that we'd rather catch and fix during development. E.g. BL-4901
                if (!ApplicationUpdateSupport.IsDevOrAlpha)
                {
                    _androidControl.Dispose();
                    _androidControl = null;
                }
            }
            if (displayMode != PublishModel.DisplayModes.Upload && displayMode != PublishModel.DisplayModes.EPUB && displayMode != PublishModel.DisplayModes.Android)
            {
                _pdfViewer.Visible = true;
            }
            switch (displayMode)
            {
            case PublishModel.DisplayModes.WaitForUserToChooseSomething:
                _printButton.Enabled = _saveButton.Enabled = false;
                Cursor = Cursors.Default;
                _workingIndicator.Visible = false;
                _pdfViewer.Visible        = false;
                break;

            case PublishModel.DisplayModes.Working:
                _printButton.Enabled     = _saveButton.Enabled = false;
                _workingIndicator.Cursor = Cursors.WaitCursor;
                Cursor = Cursors.WaitCursor;
                _workingIndicator.Visible = true;
                _pdfViewer.Visible        = false;
                break;

            case PublishModel.DisplayModes.ShowPdf:
                Logger.WriteEvent("Entering Publish PDF Screen");
                if (RobustFile.Exists(_model.PdfFilePath))
                {
                    _pdfViewer.Visible        = true;
                    _workingIndicator.Visible = false;
                    Cursor = Cursors.Default;
                    _saveButton.Enabled  = true;
                    _printButton.Enabled = _pdfViewer.ShowPdf(_model.PdfFilePath);
                }
                break;

            case PublishModel.DisplayModes.Printing:
                _simpleAllPagesRadio.Enabled = false;
                _bookletCoverRadio.Enabled   = false;
                _bookletBodyRadio.Enabled    = false;
                _printButton.Enabled         = _saveButton.Enabled = false;
                _workingIndicator.Cursor     = Cursors.WaitCursor;
                Cursor = Cursors.WaitCursor;
                _workingIndicator.Visible = true;
                break;

            case PublishModel.DisplayModes.ResumeAfterPrint:
                _simpleAllPagesRadio.Enabled = true;
                _pdfViewer.Visible           = true;
                _workingIndicator.Visible    = false;
                Cursor = Cursors.Default;
                _saveButton.Enabled  = true;
                _printButton.Enabled = true;
                break;

            case PublishModel.DisplayModes.Upload:
            {
                Logger.WriteEvent("Entering Publish Upload Screen");
                _workingIndicator.Visible = false;                         // If we haven't finished creating the PDF, we will indicate that in the progress window.
                _saveButton.Enabled       = _printButton.Enabled = false;  // Can't print or save in this mode...wouldn't be obvious what would be saved.
                _pdfViewer.Visible        = false;
                Cursor = Cursors.Default;

                if (_publishControl == null)
                {
                    SetupPublishControl();
                }

                break;
            }

            case PublishModel.DisplayModes.EPUB:
            {
                Logger.WriteEvent("Entering Publish Epub Screen");
                // We may reuse this for the process of generating the ePUB staging files. For now, skip it.
                _workingIndicator.Visible = false;
                _printButton.Enabled      = false;                    // don't know how to print an ePUB
                _pdfViewer.Visible        = false;
                Cursor = Cursors.WaitCursor;
                _epubPreviewControl = ElectronicPublishView.SetupEpubControl(_epubPreviewControl, _isolator, () => _saveButton.Enabled = _model.EpubMaker.ReadyToSave());
                _epubPreviewControl.SetBounds(_pdfViewer.Left, _pdfViewer.Top,
                                              _pdfViewer.Width, _pdfViewer.Height);
                _epubPreviewControl.Dock   = _pdfViewer.Dock;
                _epubPreviewControl.Anchor = _pdfViewer.Anchor;
                var saveBackGround = _epubPreviewControl.BackColor;                     // changed to match parent during next statement
                Controls.Add(_epubPreviewControl);
                _epubPreviewControl.BackColor = saveBackGround;                         // keep own color.
                // Typically this control is dock.fill. It has to be in front of tableLayoutPanel1 (which is Left) for Fill to work.
                _epubPreviewControl.BringToFront();
                Cursor = Cursors.Default;

                // We rather mangled the Readium code in the process of cutting away its own navigation
                // and other controls. It produces all kinds of JavaScript errors, but it seems to do
                // what we want. So just suppress the toasts for all of them.
                Browser.SuppressJavaScriptErrors = true;
                break;
            }

            case PublishModel.DisplayModes.Android:
            {
                Logger.WriteEvent("Entering Publish Android Screen");
                _workingIndicator.Visible = false;
                _printButton.Enabled      = false;
                _pdfViewer.Visible        = false;
                Cursor          = Cursors.WaitCursor;
                _androidControl = new AndroidView(_isolator);
                _androidControl.SetBounds(_pdfViewer.Left, _pdfViewer.Top,
                                          _pdfViewer.Width, _pdfViewer.Height);
                _androidControl.Dock   = _pdfViewer.Dock;
                _androidControl.Anchor = _pdfViewer.Anchor;
                var saveBackGround = _androidControl.BackColor;                     // changed to match parent during next statement
                Controls.Add(_androidControl);
                _androidControl.BackColor = saveBackGround;                         // keep own color.
                // Typically this control is dock.fill. It has to be in front of tableLayoutPanel1 (which is Left) for Fill to work.
                _androidControl.BringToFront();
                Cursor = Cursors.Default;

                break;
            }
            }
            UpdateSaveButton();
        }
Esempio n. 4
0
        private void SetupPublishControl()
        {
            if (_publishControl != null)
            {
                //we currently rebuild it to update contents, as currently the constructor is where setup logic happens (we could change that)
                Controls.Remove(_publishControl); ;
            }

            _publishControl = new BloomLibraryPublishControl(this, _bookTransferrer, _loginDialog,
                _model.BookSelection.CurrentSelection);
            _publishControl.SetBounds(_pdfViewer.Left, _pdfViewer.Top,
                _pdfViewer.Width, _pdfViewer.Height);
            _publishControl.Dock = _pdfViewer.Dock;
            _publishControl.Anchor = _pdfViewer.Anchor;
            var saveBackColor = _publishControl.BackColor;
            Controls.Add(_publishControl); // somehow this changes the backcolor
            _publishControl.BackColor = saveBackColor; // Need a normal back color for this so links and text can be seen
            // Typically this control is dock.fill. It has to be in front of tableLayoutPanel1 (which is Left) for Fill to work.
            _publishControl.BringToFront();
        }
Esempio n. 5
0
        public void SetDisplayMode(PublishModel.DisplayModes displayMode)
        {
            if (displayMode != PublishModel.DisplayModes.Upload && _publishControl != null)
            {
                Controls.Remove(_publishControl);
                _publishControl = null;
            }
            if (displayMode != PublishModel.DisplayModes.EPUB && _epubPreviewControl != null && Controls.Contains(_epubPreviewControl))
            {
                Controls.Remove(_epubPreviewControl);
            }
            if (displayMode != PublishModel.DisplayModes.Upload && displayMode != PublishModel.DisplayModes.EPUB)
                _pdfViewer.Visible = true;
            switch (displayMode)
            {
                case PublishModel.DisplayModes.WaitForUserToChooseSomething:
                    _printButton.Enabled = _saveButton.Enabled = false;
                    Cursor = Cursors.Default;
                    _workingIndicator.Visible = false;
                    _pdfViewer.Visible = false;
                    break;
                case PublishModel.DisplayModes.Working:
                    _printButton.Enabled = _saveButton.Enabled = false;
                    _workingIndicator.Cursor = Cursors.WaitCursor;
                    Cursor = Cursors.WaitCursor;
                    _workingIndicator.Visible = true;
                    break;
                case PublishModel.DisplayModes.ShowPdf:
                    if (RobustFile.Exists(_model.PdfFilePath))
                    {
                        _pdfViewer.Visible = true;
                        _workingIndicator.Visible = false;
                        Cursor = Cursors.Default;
                        _saveButton.Enabled = true;
                        _printButton.Enabled = _pdfViewer.ShowPdf(_model.PdfFilePath);
                    }
                    break;
                case PublishModel.DisplayModes.Printing:
                    _simpleAllPagesRadio.Enabled = false;
                    _bookletCoverRadio.Enabled = false;
                    _bookletBodyRadio.Enabled = false;
                    _printButton.Enabled = _saveButton.Enabled = false;
                    _workingIndicator.Cursor = Cursors.WaitCursor;
                    Cursor = Cursors.WaitCursor;
                    _workingIndicator.Visible = true;
                    break;
                case PublishModel.DisplayModes.ResumeAfterPrint:
                    _simpleAllPagesRadio.Enabled = true;
                    _pdfViewer.Visible = true;
                    _workingIndicator.Visible = false;
                    Cursor = Cursors.Default;
                    _saveButton.Enabled = true;
                    _printButton.Enabled = true;
                    break;
                case PublishModel.DisplayModes.Upload:
                {
                    _workingIndicator.Visible = false; // If we haven't finished creating the PDF, we will indicate that in the progress window.
                    _saveButton.Enabled = _printButton.Enabled = false; // Can't print or save in this mode...wouldn't be obvious what would be saved.
                    _pdfViewer.Visible = false;
                    Cursor = Cursors.Default;

                    if (_publishControl == null)
                    {
                        SetupPublishControl();
                    }

                    break;
                }
                case PublishModel.DisplayModes.EPUB:
                {
                    // We may reuse this for the process of generating the ePUB staging files. For now, skip it.
                    _workingIndicator.Visible = false;
                    _printButton.Enabled = false; // don't know how to print an ePUB
                    _saveButton.Enabled = true; // lets us save it to an actual ePUB
                    _pdfViewer.Visible = false;
                    Cursor = Cursors.Default;

                    SetupEpubControl();

                    break;
                }
            }
            UpdateSaveButton();
        }
Esempio n. 6
0
        public void SetDisplayMode(PublishModel.DisplayModes displayMode)
        {
            if (displayMode != PublishModel.DisplayModes.Upload && _publishControl != null)
            {
                Controls.Remove(_publishControl);
                _publishControl = null;
            }
            if (displayMode != PublishModel.DisplayModes.EPUB && _epubPreviewControl != null && Controls.Contains(_epubPreviewControl))
            {
                Controls.Remove(_epubPreviewControl);
            }
            if (displayMode != PublishModel.DisplayModes.Upload && displayMode != PublishModel.DisplayModes.EPUB)
            {
                _pdfViewer.Visible = true;
            }
            switch (displayMode)
            {
            case PublishModel.DisplayModes.WaitForUserToChooseSomething:
                _printButton.Enabled = _saveButton.Enabled = false;
                Cursor = Cursors.Default;
                _workingIndicator.Visible = false;
                _pdfViewer.Visible        = false;
                break;

            case PublishModel.DisplayModes.Working:
                _printButton.Enabled     = _saveButton.Enabled = false;
                _workingIndicator.Cursor = Cursors.WaitCursor;
                Cursor = Cursors.WaitCursor;
                _workingIndicator.Visible = true;
                _pdfViewer.Visible        = false;
                break;

            case PublishModel.DisplayModes.ShowPdf:
                if (RobustFile.Exists(_model.PdfFilePath))
                {
                    _pdfViewer.Visible        = true;
                    _workingIndicator.Visible = false;
                    Cursor = Cursors.Default;
                    _saveButton.Enabled  = true;
                    _printButton.Enabled = _pdfViewer.ShowPdf(_model.PdfFilePath);
                }
                break;

            case PublishModel.DisplayModes.Printing:
                _simpleAllPagesRadio.Enabled = false;
                _bookletCoverRadio.Enabled   = false;
                _bookletBodyRadio.Enabled    = false;
                _printButton.Enabled         = _saveButton.Enabled = false;
                _workingIndicator.Cursor     = Cursors.WaitCursor;
                Cursor = Cursors.WaitCursor;
                _workingIndicator.Visible = true;
                break;

            case PublishModel.DisplayModes.ResumeAfterPrint:
                _simpleAllPagesRadio.Enabled = true;
                _pdfViewer.Visible           = true;
                _workingIndicator.Visible    = false;
                Cursor = Cursors.Default;
                _saveButton.Enabled  = true;
                _printButton.Enabled = true;
                break;

            case PublishModel.DisplayModes.Upload:
            {
                _workingIndicator.Visible = false;                         // If we haven't finished creating the PDF, we will indicate that in the progress window.
                _saveButton.Enabled       = _printButton.Enabled = false;  // Can't print or save in this mode...wouldn't be obvious what would be saved.
                _pdfViewer.Visible        = false;
                Cursor = Cursors.Default;

                if (_publishControl == null)
                {
                    SetupPublishControl();
                }

                break;
            }

            case PublishModel.DisplayModes.EPUB:
            {
                // We may reuse this for the process of generating the ePUB staging files. For now, skip it.
                _workingIndicator.Visible = false;
                _printButton.Enabled      = false;                    // don't know how to print an ePUB
                _pdfViewer.Visible        = false;
                Cursor = Cursors.WaitCursor;
                _epubPreviewControl = ElectronicPublishView.SetupEpubControl(_epubPreviewControl, _isolator, () => _saveButton.Enabled = _model.EpubMaker.ReadyToSave());
                _saveButton.Enabled = _model.EpubMaker.ReadyToSave();
                _epubPreviewControl.SetBounds(_pdfViewer.Left, _pdfViewer.Top,
                                              _pdfViewer.Width, _pdfViewer.Height);
                _epubPreviewControl.Dock   = _pdfViewer.Dock;
                _epubPreviewControl.Anchor = _pdfViewer.Anchor;
                var saveBackGround = _epubPreviewControl.BackColor;                     // changed to match parent during next statement
                Controls.Add(_epubPreviewControl);
                _epubPreviewControl.BackColor = saveBackGround;                         // keep own color.
                // Typically this control is dock.fill. It has to be in front of tableLayoutPanel1 (which is Left) for Fill to work.
                _epubPreviewControl.BringToFront();
                Cursor = Cursors.Default;

                break;
            }
            }
            UpdateSaveButton();
        }