public void SetDisplayMode(PublishModel.DisplayModes displayMode) { switch (displayMode) { case PublishModel.DisplayModes.NoBook: _printButton.Enabled = _saveButton.Enabled = false; Cursor = Cursors.Default; _workingIndicator.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)) { _saveButton.Enabled = true; _workingIndicator.Visible = false; Cursor = Cursors.Default; _printButton.Enabled = _adobeReaderControl.ShowPdf(_model.PdfFilePath); } break; } }
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; } } }
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(); }
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(); }
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(); }