Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 /// <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;
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        //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();
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
 /// <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;
 }