コード例 #1
0
        private void SetupPublishControl()
        {
            if (_uploadControl != null)
            {
                //we currently rebuild it to update contents, as currently the constructor is where setup logic happens (we could change that)
                Controls.Remove(_uploadControl);;
            }

            var libaryPublishModel = new BloomLibraryPublishModel(_bookTransferrer, _model.BookSelection.CurrentSelection, _model);

            _uploadControl      = new BloomLibraryUploadControl(this, libaryPublishModel, _loginDialog);
            _uploadControl.Dock = DockStyle.Fill;
            var saveBackColor = _uploadControl.BackColor;

            Controls.Add(_uploadControl);             // somehow this changes the backcolor
            _uploadControl.BackColor = saveBackColor; // Need a normal back color for this so links and text can be seen
            // This control is dock.fill. It has to be in front of tableLayoutPanel1 (which is Left) for Fill to work.
            _uploadControl.BringToFront();
        }
コード例 #2
0
        public void SetDisplayMode(PublishModel.DisplayModes displayMode)
        {
            // This is only supposed to be active in one mode of PublishView.
            Browser.SuppressJavaScriptErrors = false;
            Browser.ClearCache();             // try to free memory when switching
            // Abort any work we're doing to prepare a preview (at least stop it interfering with other navigation).
            PublishHelper.Cancel();

            if (displayMode != PublishModel.DisplayModes.Upload && _uploadControl != null)
            {
                Controls.Remove(_uploadControl);
                _uploadControl = null;
            }
            if ((displayMode != PublishModel.DisplayModes.Android || displayMode != PublishModel.DisplayModes.EPUB) &&
                _htmlControl != null && Controls.Contains(_htmlControl))
            {
                Controls.Remove(_htmlControl);

                // 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)
                {
                    _htmlControl.Dispose();
                    _htmlControl = null;
                }
            }

            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;
                _pdfViewer.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;
                _pdfViewer.Visible   = 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 (_uploadControl == null)
                {
                    SetupPublishControl();
                }

                break;
            }

            case PublishModel.DisplayModes.Android:
                _saveButton.Enabled = _printButton.Enabled = false;                         // Can't print or save in this mode...wouldn't be obvious what would be saved.
                BloomReaderFileMaker.ControlForInvoke = ParentForm;                         // something created on UI thread that won't go away
                ShowHtmlPanel(BloomFileLocator.GetBrowserFile(false, "publish", "ReaderPublish", "loader.html"));
                break;

            case PublishModel.DisplayModes.EPUB:
                _saveButton.Enabled = _printButton.Enabled = false;                         // Can't print or save in this mode...wouldn't be obvious what would be saved.
                // 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 in our preview. So just suppress the toasts for all of them. This is unfortunate because
                // we'll lose them for all the other JS code in this pane. But I don't have a better solution.
                // We still get them in the output window, in case we really want to look for one.
                Browser.SuppressJavaScriptErrors = true;
                PublishEpubApi.ControlForInvoke  = ParentForm;                        // something created on UI thread that won't go away
                ShowHtmlPanel(BloomFileLocator.GetBrowserFile(false, "publish", "ePUBPublish", "loader.html"));
                break;
            }
            UpdateSaveButton();
        }