/// <summary> /// Assigns words its width and height /// </summary> /// <param name="g">the device to use</param> internal override void MeasureWordsSize(RGraphics g) { if (!_wordsSizeMeasured) { if (_imageLoadHandler == null && (HtmlContainer.AvoidAsyncImagesLoading || HtmlContainer.AvoidImagesLateLoading)) { _imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete); if (this.Content != null && this.Content != CssConstants.Normal) { _imageLoadHandler.LoadImage(this.Content, HtmlTag != null ? HtmlTag.Attributes : null); } else { _imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null); } } MeasureWordSpacing(g); _wordsSizeMeasured = true; } CssLayoutEngine.MeasureImageSize(_imageWord); }
/// <summary> /// Create image handler for downloading video image if found and release the WebClient instance used for API call. /// </summary> private void HandlePostApiCall(object sender) { try { if (_videoImageUrl != null) { _imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete); _imageLoadHandler.LoadImage(_videoImageUrl, HtmlTag != null ? HtmlTag.Attributes : null); } else { _imageLoadingComplete = true; SetErrorBorder(); } var webClient = (WebClient)sender; webClient.DownloadStringCompleted -= OnDownloadYoutubeApiCompleted; webClient.DownloadStringCompleted -= OnDownloadVimeoApiCompleted; webClient.Dispose(); HtmlContainer.RequestRefresh(IsLayoutRequired()); } catch { } }
private static FeedImageInfo CreateImageInfoFromXmlNode(XmlNode root) { FeedImageInfo result = new FeedImageInfo(); result.link = root.SelectSingleNode("link").InnerText; result.title = root.SelectSingleNode("title").InnerText; result.url = root.SelectSingleNode("url").InnerText; result.image = ImageLoadHandler.GetImage(result.url); if (result.image == null) { result.image = ImageLoadHandler.GetImage(result.link); } return(result); }
/// <summary> /// Assigns words its width and height /// </summary> /// <param name="g">the device to use</param> internal override void MeasureWordsSize(Graphics g) { if (!_wordsSizeMeasured) { if (_imageLoadHandler == null) { _imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete); _imageLoadHandler.LoadImage(HtmlContainer, GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null); } MeasureWordSpacing(g); _wordsSizeMeasured = true; } CssLayoutEngine.MeasureImageSize(_imageWord); }
/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(RGraphics g) { if (this._videoImageUrl != null && this._imageLoadHandler == null) { this._imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete); this._imageLoadHandler.LoadImage(this._videoImageUrl, HtmlTag != null ? HtmlTag.Attributes : null); } var rects = CommonUtils.GetFirstValueOrDefault(Rectangles); RPoint offset = (HtmlContainer != null && !IsFixed) ? HtmlContainer.ScrollOffset : RPoint.Empty; rects.Offset(offset); var clipped = RenderUtils.ClipGraphicsByOverflow(g, this); PaintBackground(g, rects, true, true); BordersDrawHandler.DrawBoxBorders(g, this, rects, true, true); var word = Words[0]; var tmpRect = word.Rectangle; tmpRect.Offset(offset); tmpRect.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; tmpRect.Y += ActualBorderTopWidth + ActualPaddingTop; tmpRect.X = Math.Floor(tmpRect.X); tmpRect.Y = Math.Floor(tmpRect.Y); var rect = tmpRect; DrawImage(g, offset, rect); DrawTitle(g, rect); DrawPlay(g, rect); if (clipped) { g.PopClip(); } }
/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(RGraphics g) { // load image if it is in visible rectangle if (_imageLoadHandler == null) { _imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete); _imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null); } var rect = CommonUtils.GetFirstValueOrDefault(Rectangles); RPoint offset = RPoint.Empty; if (!IsFixed) { offset = HtmlContainer.ScrollOffset; } rect.Offset(offset); var clipped = RenderUtils.ClipGraphicsByOverflow(g, this); PaintBackground(g, rect, true, true); BordersDrawHandler.DrawBoxBorders(g, this, rect, true, true); RRect r = _imageWord.Rectangle; r.Offset(offset); r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; r.Y += ActualBorderTopWidth + ActualPaddingTop; r.X = Math.Floor(r.X); r.Y = Math.Floor(r.Y); if (_imageWord.Image != null) { if (r.Width > 0 && r.Height > 0) { if (_imageWord.ImageRectangle == RRect.Empty) { g.DrawImage(_imageWord.Image, r); } else { g.DrawImage(_imageWord.Image, r, _imageWord.ImageRectangle); } if (_imageWord.Selected) { g.DrawRectangle(GetSelectionBackBrush(g, true), _imageWord.Left + offset.X, _imageWord.Top + offset.Y, _imageWord.Width + 2, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight); } } } else if (_imageLoadingComplete) { if (_imageLoadingComplete && r.Width > 19 && r.Height > 19) { RenderUtils.DrawImageErrorIcon(g, HtmlContainer, r); } } else { RenderUtils.DrawImageLoadingIcon(g, HtmlContainer, r); if (r.Width > 19 && r.Height > 19) { g.DrawRectangle(g.GetPen(RColor.LightGray), r.X, r.Y, r.Width, r.Height); } } if (clipped) { g.PopClip(); } }
/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(IGraphics g) { // load image iff it is in visible rectangle if (_imageLoadHandler == null) { _imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete); _imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null); } RectangleF rect = CommonUtils.GetFirstValueOrDefault(Rectangles); PointF offset = HtmlContainer.ScrollOffset; rect.Offset(offset); RectangleF prevClip = RenderUtils.ClipGraphicsByOverflow(g, this); PaintBackground(g, rect, true, true); BordersDrawHandler.DrawBoxBorders(g, this, rect, true, true); RectangleF r = _imageWord.Rectangle; r.Offset(offset); r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; r.Y += ActualBorderTopWidth + ActualPaddingTop; r.X = (float)Math.Floor(r.X); r.Y = (float)Math.Floor(r.Y); if (_imageWord.Image != null) { if (_imageWord.ImageRectangle == Rectangle.Empty) { g.DrawImage(_imageWord.Image, Rectangle.Round(r)); } else { g.DrawImage(_imageWord.Image, Rectangle.Round(r), _imageWord.ImageRectangle); } if (_imageWord.Selected) { g.FillRectangle(GetSelectionBackBrush(true), _imageWord.Left + offset.X, _imageWord.Top + offset.Y, _imageWord.Width + 2, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight); } } else if (_imageLoadingComplete) { if (_imageLoadingComplete && r.Width > 19 && r.Height > 19) { RenderUtils.DrawImageErrorIcon(g, r); } } else { RenderUtils.DrawImageLoadingIcon(g, r); if (r.Width > 19 && r.Height > 19) { g.DrawRectangle(Pens.LightGray, r.X, r.Y, r.Width, r.Height); } } RenderUtils.ReturnClip(g, prevClip); }