public void Navigate(string url, bool cleanupFileAfterNavigating) { _url = url; //TODO: fix up this hack. We found that deleting the pdf while we're still showing it is a bad idea. if (cleanupFileAfterNavigating && !_url.EndsWith(".pdf")) { SetNewTempFile(TempFile.TrackExisting(url)); } UpdateDisplay(); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (_tempHtmlFile != null) { _tempHtmlFile.Dispose(); _tempHtmlFile = null; } if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); _disposed = true; }
private void SetNewTempFile(TempFile tempFile) { if (_tempHtmlFile != null) { try { _tempHtmlFile.Dispose(); } catch (Exception) { //not worth talking to the user about it. Just abandon it in the Temp directory. #if DEBUG throw; #endif } } _tempHtmlFile = tempFile; }
//NB: make sure the <base> is set correctly, 'cause you don't know where this method will //save the file before navigating to it. public void Navigate(XmlDocument dom) { _pageDom = (XmlDocument)dom; //.CloneNode(true); //clone because we want to modify it a bit /* This doesn't work for the 1st book shown, or when you change book sizes. * But it's still worth doing, becuase without it, we have this annoying re-zoom every time we look at different page. */ XmlElement body = (XmlElement)_pageDom.GetElementsByTagName("body")[0]; var scale = GetScaleToShowWholeWidthOfPage(); if (scale > 0f) { body.SetAttribute("style", GetZoomCSS(scale)); } XmlHtmlConverter.MakeXmlishTagsSafeForInterpretationAsHtml(dom); SetNewTempFile(TempFile.CreateHtm5FromXml(dom)); _url = _tempHtmlFile.Path; UpdateDisplay(); }
private void SetNewTempFile(TempFile tempFile) { if(_tempHtmlFile!=null) { try { _tempHtmlFile.Dispose(); } catch(Exception) { //not worth talking to the user about it. Just abandon it in the Temp directory. #if DEBUG throw; #endif } } _tempHtmlFile = tempFile; }