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();
}