Bloom.Edit.EditingModel.SetupServerWithCurrentPageIframeContents C# (CSharp) Method

SetupServerWithCurrentPageIframeContents() public method

public SetupServerWithCurrentPageIframeContents ( ) : void
return void
        public void SetupServerWithCurrentPageIframeContents()
        {
            _domForCurrentPage = CurrentBook.GetEditableHtmlDomForPage(_pageSelection.CurrentSelection);
            CheckForBL2364("setup");
            SetPageZoom();
            XmlHtmlConverter.MakeXmlishTagsSafeForInterpretationAsHtml(_domForCurrentPage.RawDom);
            CheckForBL2364("made tags safe");
            if (_currentPage != null)
                _currentPage.Dispose();
            _currentPage = EnhancedImageServer.MakeSimulatedPageFileInBookFolder(_domForCurrentPage, true);
            CheckForBL2364("made simulated page");

            // Enhance JohnT: Can we somehow have a much simpler toolbox content until the user displays it?
            //if (_currentlyDisplayedBook.BookInfo.ToolboxIsOpen)
                _server.ToolboxContent = ToolboxView.MakeToolboxContent(_currentlyDisplayedBook);
            //else
            //	_server.ToolboxContent = "<html><head><meta charset=\"UTF-8\"/></head><body></body></html>";

            _server.AuthorMode = CanAddPages;
        }

Usage Example

Example #1
0
        public void UpdateSingleDisplayedPage(IPage page)
        {
            if (!_model.Visible)
            {
                return;
            }

            if (_model.HaveCurrentEditableBook)
            {
                _pageListView.SelectThumbnailWithoutSendingEvent(page);
                _model.SetupServerWithCurrentPageIframeContents();
                HtmlDom domForCurrentPage = _model.GetXmlDocumentForCurrentPage();
                var     dom = _model.GetXmlDocumentForEditScreenWebPage();
                _browser1.Focus();
                _browser1.Navigate(dom.RawDom, domForCurrentPage.RawDom);
                _pageListView.Focus();
                _browser1.Focus();
                // So far, the most reliable way I've found to detect that the page is fully loaded and we can call
                // initialize() is the ReadyStateChanged event (combined with checking that ReadyState is "complete").
                // This works for most pages but not all...some (e.g., the credits page in a basic book) seem to just go on
                // being "interactive". As a desperate step I tried looking for DocumentCompleted (which fires too soon and often),
                // but still, we never get one where the ready state is completed. This page just stays 'interactive'.
                // A desperate expedient would be to try running some Javascript to test whether the 'initialize' function
                // has actually loaded. If you try that, be careful...this function seems to be used in cases where that
                // never happens.
                _browser1.WebBrowser.DocumentCompleted += WebBrowser_ReadyStateChanged;
                _browser1.WebBrowser.ReadyStateChange  += WebBrowser_ReadyStateChanged;
            }
            UpdateDisplay();
        }