Exemplo n.º 1
0
 public void UpdateThumbnailAsync(Book.Book book, HtmlThumbNailer.ThumbnailOptions thumbnailOptions, Action <Book.BookInfo, Image> callback, Action <Book.BookInfo, Exception> errorCallback)
 {
     if (!(book is ErrorBook))
     {
         _thumbNailer.RebuildThumbNailAsync(book, thumbnailOptions, callback, errorCallback);
     }
 }
Exemplo n.º 2
0
        public void GetThumbnailAsync(int width, int height, HtmlDom dom, Action <Image> onReady, Action <Exception> onError)
        {
            var thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
            {
                BackgroundColor  = Color.White,
                DrawBorderDashed = false,
                CenterImageUsingTransparentPadding = false
            };

            _htmlThumbNailer.GetThumbnailAsync(String.Empty, string.Empty, dom.RawDom, thumbnailOptions, onReady, onError);
        }
Exemplo n.º 3
0
        public void UpdateThumbnailAsync(IPage page)
        {
            XmlDocument pageDom          = page.Book.GetPreviewXmlDocumentForPage(page).RawDom;
            var         thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
            {
                BackgroundColor  = Palette.TextAgainstDarkBackground,
                DrawBorderDashed = false,
                CenterImageUsingTransparentPadding = true
            };

            Thumbnailer.GetThumbnailAsync(String.Empty, page.Id, pageDom, thumbnailOptions, image => RefreshOneThumbnailCallback(page, image),
                                          error => HandleThumbnailerError(page, error));
        }
Exemplo n.º 4
0
        public void GetThumbnailAsync(int width, int height, HtmlDom dom, Action <Image> onReady, Action <Exception> onError)
        {
            var thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
            {
                BackgroundColor = Color.White,
                BorderStyle     = HtmlThumbNailer.ThumbnailOptions.BorderStyles.None,
                CenterImageUsingTransparentPadding = false,
                Height = height,
                Width  = width
            };

            dom.UseOriginalImages = true;             // apparently these thumbnails can be big...anyway we want printable images.
            _thumbNailer.HtmlThumbNailer.GetThumbnailAsync(String.Empty, string.Empty, dom, thumbnailOptions, onReady, onError);
        }
Exemplo n.º 5
0
        void MakeThumbnail(Book.Book book, int height, Control invokeTarget)
        {
            bool   done  = false;
            string error = null;

            HtmlThumbNailer.ThumbnailOptions options = new HtmlThumbNailer.ThumbnailOptions()
            {
                CenterImageUsingTransparentPadding = false,
                //since this is destined for HTML, it's much easier to handle if there is no pre-padding

                Height   = height,
                Width    = -1,
                FileName = "thumbnail-" + height + ".png"
            };

            book.RebuildThumbNailAsync(options, (info, image) => done = true,
                                       (info, ex) =>
            {
                done = true;
                throw ex;
            });
            var giveUpTime = DateTime.Now.AddSeconds(15);

            while (!done && DateTime.Now < giveUpTime)
            {
                Thread.Sleep(100);
                Application.DoEvents();
                // In the context of bulk upload, when a model dialog is the only window, apparently Application.Idle is never invoked.
                // So we need a trick to allow the thumbnailer to actually make some progress, since it usually works while idle.
                this._htmlThumbnailer.Advance(invokeTarget);
            }
            if (!done)
            {
                throw new ApplicationException(string.Format("Gave up waiting for the {0} to be created. This usually means Bloom is busy making thumbnails for other things. Wait a bit, and try again.", options.FileName));
            }
        }
Exemplo n.º 6
0
 public void GetThumbnailAsync(int width, int height, HtmlDom dom,Action<Image> onReady ,Action<Exception> onError)
 {
     var thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
     {
         BackgroundColor = Color.White,
         BorderStyle = HtmlThumbNailer.ThumbnailOptions.BorderStyles.None,
         CenterImageUsingTransparentPadding = false,
         Height = height,
         Width = width
     };
     dom.UseOriginalImages = true; // apparently these thumbnails can be big...anyway we want printable images.
     _thumbNailer.HtmlThumbNailer.GetThumbnailAsync(String.Empty, string.Empty, dom, thumbnailOptions,onReady, onError);
 }
Exemplo n.º 7
0
 public override void GetThumbNailOfBookCoverAsync(HtmlThumbNailer.ThumbnailOptions thumbnailOptions, Action <Image> callback, Action <Exception> errorCallback)
 {
     callback(Resources.Error70x70);
 }
Exemplo n.º 8
0
 public void UpdateThumbnailAsync(IPage page)
 {
     var pageDom = page.Book.GetPreviewXmlDocumentForPage(page);
     var thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
     {
         BackgroundColor = Palette.TextAgainstDarkBackground,
         BorderStyle = HtmlThumbNailer.ThumbnailOptions.BorderStyles.Solid,
         CenterImageUsingTransparentPadding = true
     };
     Thumbnailer.GetThumbnailAsync(String.Empty, page.Id, pageDom, thumbnailOptions, image => RefreshOneThumbnailCallback(page, image),
                                               error=> HandleThumbnailerError(page, error));
 }