Ejemplo n.º 1
0
        /// <summary>
        /// Init.
        /// </summary>
        protected RGraphics(RAdapter adapter, RRect initialClip)
        {
            ArgChecker.AssertArgNotNull(adapter, "global");

            _adapter = adapter;
            _clipStack.Push(initialClip);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Paints the fragment
        /// </summary>
        /// <param name="g">the device to draw to</param>
        protected override void PaintImp(RGraphics g)
        {
            var offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : RPoint.Empty;
            var rect = new RRect(Bounds.X + offset.X, Bounds.Y + offset.Y, Bounds.Width, Bounds.Height);

            if (rect.Height > 2 && RenderUtils.IsColorVisible(ActualBackgroundColor))
            {
                g.DrawRectangle(g.GetSolidBrush(ActualBackgroundColor), rect.X, rect.Y, rect.Width, rect.Height);
            }

            var b1 = g.GetSolidBrush(ActualBorderTopColor);
            BordersDrawHandler.DrawBorder(Border.Top, g, this, b1, rect);

            if (rect.Height > 1)
            {
                var b2 = g.GetSolidBrush(ActualBorderLeftColor);
                BordersDrawHandler.DrawBorder(Border.Left, g, this, b2, rect);

                var b3 = g.GetSolidBrush(ActualBorderRightColor);
                BordersDrawHandler.DrawBorder(Border.Right, g, this, b3, rect);

                var b4 = g.GetSolidBrush(ActualBorderBottomColor);
                BordersDrawHandler.DrawBorder(Border.Bottom, g, this, b4, rect);
            }
        }
        /// <summary>
        /// Draw the background image of the given box in the given rectangle.<br/>
        /// Handle background-repeat and background-position values.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="box">the box to draw its background image</param>
        /// <param name="imageLoadHandler">the handler that loads image to draw</param>
        /// <param name="rectangle">the rectangle to draw image in</param>
        public static void DrawBackgroundImage(RGraphics g, CssBox box, ImageLoadHandler imageLoadHandler, RRect rectangle)
        {
            // image size depends if specific rectangle given in image loader
            var imgSize = new RSize(imageLoadHandler.Rectangle == RRect.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
                imageLoadHandler.Rectangle == RRect.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);

            // get the location by BackgroundPosition value
            var location = GetLocation(box.BackgroundPosition, rectangle, imgSize);

            var srcRect = imageLoadHandler.Rectangle == RRect.Empty
                ? new RRect(0, 0, imgSize.Width, imgSize.Height)
                : new RRect(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);

            // initial image destination rectangle
            var destRect = new RRect(location, imgSize);

            // need to clip so repeated image will be cut on rectangle
            var lRectangle = rectangle;
            lRectangle.Intersect(g.GetClip());
            g.PushClip(lRectangle);

            switch (box.BackgroundRepeat)
            {
                case "no-repeat":
                    g.DrawImage(imageLoadHandler.Image, destRect, srcRect);
                    break;
                case "repeat-x":
                    DrawRepeatX(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
                case "repeat-y":
                    DrawRepeatY(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
                default:
                    DrawRepeat(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
            }

            g.PopClip();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Draws all the border of the box with respect to style, width, etc.
 /// </summary>
 /// <param name="g">the device to draw into</param>
 /// <param name="box">the box to draw borders for</param>
 /// <param name="rect">the bounding rectangle to draw in</param>
 /// <param name="isFirst">is it the first rectangle of the element</param>
 /// <param name="isLast">is it the last rectangle of the element</param>
 public static void DrawBoxBorders(RGraphics g, CssBox box, RRect rect, bool isFirst, bool isLast)
 {
     if (rect.Width > 0 && rect.Height > 0)
     {
         if (!(string.IsNullOrEmpty(box.BorderTopStyle) || box.BorderTopStyle == CssConstants.None || box.BorderTopStyle == CssConstants.Hidden) && box.ActualBorderTopWidth > 0)
         {
             DrawBorder(Border.Top, box, g, rect, isFirst, isLast);
         }
         if (isFirst && !(string.IsNullOrEmpty(box.BorderLeftStyle) || box.BorderLeftStyle == CssConstants.None || box.BorderLeftStyle == CssConstants.Hidden) && box.ActualBorderLeftWidth > 0)
         {
             DrawBorder(Border.Left, box, g, rect, true, isLast);
         }
         if (!(string.IsNullOrEmpty(box.BorderBottomStyle) || box.BorderBottomStyle == CssConstants.None || box.BorderBottomStyle == CssConstants.Hidden) && box.ActualBorderBottomWidth > 0)
         {
             DrawBorder(Border.Bottom, box, g, rect, isFirst, isLast);
         }
         if (isLast && !(string.IsNullOrEmpty(box.BorderRightStyle) || box.BorderRightStyle == CssConstants.None || box.BorderRightStyle == CssConstants.Hidden) && box.ActualBorderRightWidth > 0)
         {
             DrawBorder(Border.Right, box, g, rect, isFirst, true);
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Draw video title on top of the iframe if found.
        /// </summary>
        private void DrawTitle(RGraphics g, RRect rect)
        {
            if (_videoTitle != null && _imageWord.Width > 40 && _imageWord.Height > 40)
            {
                var font = HtmlContainer.Adapter.GetFont("Arial", 9f, RFontStyle.Regular);
                g.DrawRectangle(g.GetSolidBrush(RColor.FromArgb(160, 0, 0, 0)), rect.Left, rect.Top, rect.Width, ActualFont.Height + 7);

                var titleRect = new RRect(rect.Left + 3, rect.Top + 3, rect.Width - 6, rect.Height - 6);
                g.DrawString(_videoTitle, font, RColor.WhiteSmoke, titleRect.Location, RSize.Empty, false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draw video image over the iframe if found.
        /// </summary>
        private void DrawImage(RGraphics g, RPoint offset, RRect rect)
        {
            if (_imageWord.Image != null)
            {
                if (rect.Width > 0 && rect.Height > 0)
                {
                    if (_imageWord.ImageRectangle == RRect.Empty)
                        g.DrawImage(_imageWord.Image, rect);
                    else
                        g.DrawImage(_imageWord.Image, rect, _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 (_isVideo && !_imageLoadingComplete)
            {
                RenderUtils.DrawImageLoadingIcon(g, HtmlContainer, rect);
                if (rect.Width > 19 && rect.Height > 19)
                {
                    g.DrawRectangle(g.GetPen(RColor.LightGray), rect.X, rect.Y, rect.Width, rect.Height);
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Get linear gradient color brush from <paramref name="color1"/> to <paramref name="color2"/>.
 /// </summary>
 /// <param name="rect">the rectangle to get the brush for</param>
 /// <param name="color1">the start color of the gradient</param>
 /// <param name="color2">the end color of the gradient</param>
 /// <param name="angle">the angle to move the gradient from start color to end color in the rectangle</param>
 /// <returns>linear gradient color brush instance</returns>
 public RBrush GetLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
 {
     return CreateLinearGradientBrush(rect, color1, color2, angle);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Push the clipping region of this Graphics to interception of current clipping rectangle and the given rectangle.
 /// </summary>
 /// <param name="rect">Rectangle to clip to.</param>
 public abstract void PushClip(RRect rect);
Ejemplo n.º 9
0
 /// <summary>
 ///     Determines if this rectangle intersects with <paramref name="rect" />.
 /// </summary>
 /// <returns>
 ///     This method returns true if there is any intersection.
 /// </returns>
 /// <param name="rect">The rectangle to test. </param>
 public bool IntersectsWith(RRect rect)
 {
     if (rect.X < X + Width && X < rect.X + rect.Width && rect.Y < Y + Height)
         return Y < rect.Y + rect.Height;
     return false;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Paint all the words in the box.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="offset">the current scroll offset to offset the words</param>
        private void PaintWords(RGraphics g, RPoint offset)
        {
            if (Width.Length > 0)
            {
                var isRtl = Direction == CssConstants.Rtl;
                foreach (var word in Words)
                {
                    if (!word.IsLineBreak)
                    {
                        var wordPoint = new RPoint(word.Left + offset.X, word.Top + offset.Y);
                        if (word.Selected)
                        {
                            // handle paint selected word background and with partial word selection
                            var wordLine = DomUtils.GetCssLineBoxByWord(word);
                            var left = word.SelectedStartOffset > -1 ? word.SelectedStartOffset : (wordLine.Words[0] != word && word.HasSpaceBefore ? -ActualWordSpacing : 0);
                            var padWordRight = word.HasSpaceAfter && !wordLine.IsLastSelectedWord(word);
                            var width = word.SelectedEndOffset > -1 ? word.SelectedEndOffset : word.Width + (padWordRight ? ActualWordSpacing : 0);
                            var rect = new RRect(word.Left + offset.X + left, word.Top + offset.Y, width - left, wordLine.LineHeight);

                            g.DrawRectangle(GetSelectionBackBrush(g, false), rect.X, rect.Y, rect.Width, rect.Height);

                            if (HtmlContainer.SelectionForeColor != RColor.Empty && (word.SelectedStartOffset > 0 || word.SelectedEndIndexOffset > -1))
                            {
                                g.PushClipExclude(rect);
                                g.DrawString(word.Text, ActualFont, ActualColor, wordPoint, new RSize(word.Width, word.Height), isRtl);
                                g.PopClip();
                                g.PushClip(rect);
                                g.DrawString(word.Text, ActualFont, GetSelectionForeBrush(), wordPoint, new RSize(word.Width, word.Height), isRtl);
                                g.PopClip();
                            }
                            else
                            {
                                g.DrawString(word.Text, ActualFont, GetSelectionForeBrush(), wordPoint, new RSize(word.Width, word.Height), isRtl);
                            }
                        }
                        else
                        {
                            //                            g.DrawRectangle(HtmlContainer.Adapter.GetPen(RColor.Black), wordPoint.X, wordPoint.Y, word.Width - 1, word.Height - 1);
                            g.DrawString(word.Text, ActualFont, ActualColor, wordPoint, new RSize(word.Width, word.Height), isRtl);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// On image load process complete with image request refresh for it to be painted.
 /// </summary>
 /// <param name="image">the image loaded or null if failed</param>
 /// <param name="rectangle">the source rectangle to draw in the image (empty - draw everything)</param>
 /// <param name="async">is the callback was called async to load image call</param>
 private void OnImageLoadComplete(RImage image, RRect rectangle, bool async)
 {
     if (image != null && async)
         HtmlContainer.RequestRefresh(false);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// On image load process is complete with image or without update the image box.
        /// </summary>
        /// <param name="image">the image loaded or null if failed</param>
        /// <param name="rectangle">the source rectangle to draw in the image (empty - draw everything)</param>
        /// <param name="async">is the callback was called async to load image call</param>
        private void OnLoadImageComplete(RImage image, RRect rectangle, bool async)
        {
            _imageWord.Image = image;
            _imageWord.ImageRectangle = rectangle;
            _imageLoadingComplete = true;
            _wordsSizeMeasured = false;

            if (_imageLoadingComplete && image == null)
            {
                SetErrorBorder();
            }

            if (!HtmlContainer.AvoidImagesLateLoading || async)
            {
                var width = new CssLength(Width);
                var height = new CssLength(Height);
                var layout = (width.Number <= 0 || width.Unit != CssUnit.Pixels) || (height.Number <= 0 || height.Unit != CssUnit.Pixels);
                HtmlContainer.RequestRefresh(layout);
            }
        }
Ejemplo n.º 13
0
 public override void PushClipExclude(RRect rect)
 {
     ReleaseHdc();
     _clipStack.Push(_clipStack.Peek());
     _g.SetClip(Utils.Convert(rect), CombineMode.Exclude);
 }
Ejemplo n.º 14
0
 public override void PushClip(RRect rect)
 {
     ReleaseHdc();
     _clipStack.Push(rect);
     _g.SetClip(Utils.Convert(rect), CombineMode.Replace);
 }
Ejemplo n.º 15
0
 public override RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation)
 {
     var brush = new TextureBrush(((ImageAdapter)image).Image, Utils.Convert(dstRect));
     brush.TranslateTransform((float)translateTransformLocation.X, (float)translateTransformLocation.Y);
     return new BrushAdapter(brush, true);
 }
Ejemplo n.º 16
0
 /// <summary>
 ///     Determines if the rectangular region represented by <paramref name="rect" /> is entirely contained within this
 ///     <see cref="RRect" />
 ///     structure.
 /// </summary>
 /// <returns>
 ///     This method returns true if the rectangular region represented by <paramref name="rect" /> is entirely contained within the rectangular region represented by this
 ///     <see cref="RRect" />
 ///     ; otherwise false.
 /// </returns>
 /// <param name="rect">
 ///     The <see cref="RRect" /> to test.
 /// </param>
 public bool Contains(RRect rect)
 {
     if (X <= rect.X && rect.X + rect.Width <= X + Width && Y <= rect.Y)
         return rect.Y + rect.Height <= Y + Height;
     return false;
 }
Ejemplo n.º 17
0
 /// <summary>
 ///     Replaces this <see cref="RRect" /> structure with the intersection of itself and the specified
 ///     <see
 ///         cref="RRect" />
 ///     structure.
 /// </summary>
 /// <param name="rect">The rectangle to intersect. </param>
 public void Intersect(RRect rect)
 {
     RRect rectangleF = Intersect(rect, this);
     X = rectangleF.X;
     Y = rectangleF.Y;
     Width = rectangleF.Width;
     Height = rectangleF.Height;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Offsets the rectangle of the specified linebox by the specified gap,
 /// and goes deep for rectangles of children in that linebox.
 /// </summary>
 /// <param name="lineBox"></param>
 /// <param name="gap"></param>
 internal void OffsetRectangle(CssLineBox lineBox, double gap)
 {
     if (Rectangles.ContainsKey(lineBox))
     {
         var r = Rectangles[lineBox];
         Rectangles[lineBox] = new RRect(r.X, r.Y + gap, r.Width, r.Height);
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Get TextureBrush object that uses the specified image and bounding rectangle.
 /// </summary>
 /// <param name="image">The Image object with which this TextureBrush object fills interiors.</param>
 /// <param name="dstRect">A Rectangle structure that represents the bounding rectangle for this TextureBrush object.</param>
 /// <param name="translateTransformLocation">The dimension by which to translate the transformation</param>
 public abstract RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation);
Ejemplo n.º 20
0
        /// <summary>
        /// Deeply offsets the top of the box and its contents
        /// </summary>
        /// <param name="amount"></param>
        internal void OffsetTop(double amount)
        {
            List<CssLineBox> lines = new List<CssLineBox>();
            foreach (CssLineBox line in Rectangles.Keys)
                lines.Add(line);

            foreach (CssLineBox line in lines)
            {
                RRect r = Rectangles[line];
                Rectangles[line] = new RRect(r.X, r.Y + amount, r.Width, r.Height);
            }

            foreach (CssRect word in Words)
            {
                word.Top += amount;
            }

            foreach (CssBox b in Boxes)
            {
                b.OffsetTop(amount);
            }

            if (_listItemBox != null)
                _listItemBox.OffsetTop(amount);

            Location = new RPoint(Location.X, Location.Y + amount);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Push the clipping region of this Graphics to exclude the given rectangle from the current clipping rectangle.
 /// </summary>
 /// <param name="rect">Rectangle to exclude clipping in.</param>
 public abstract void PushClipExclude(RRect rect);
Ejemplo n.º 22
0
        /// <summary>
        /// Paints the background of the box
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="rect">the bounding rectangle to draw in</param>
        /// <param name="isFirst">is it the first rectangle of the element</param>
        /// <param name="isLast">is it the last rectangle of the element</param>
        protected void PaintBackground(RGraphics g, RRect rect, bool isFirst, bool isLast)
        {
            if (rect.Width > 0 && rect.Height > 0)
            {
                RBrush brush = null;

                if (BackgroundGradient != CssConstants.None)
                {
                    brush = g.GetLinearGradientBrush(rect, ActualBackgroundColor, ActualBackgroundGradient, ActualBackgroundGradientAngle);
                }
                else if (RenderUtils.IsColorVisible(ActualBackgroundColor))
                {
                    brush = g.GetSolidBrush(ActualBackgroundColor);
                }

                if (brush != null)
                {
                    // TODO:a handle it correctly (tables background)
                    // if (isLast)
                    //  rectangle.Width -= ActualWordSpacing + CssUtils.GetWordEndWhitespace(ActualFont);

                    RGraphicsPath roundrect = null;
                    if (IsRounded)
                    {
                        roundrect = RenderUtils.GetRoundRect(g, rect, ActualCornerNw, ActualCornerNe, ActualCornerSe, ActualCornerSw);
                    }

                    Object prevMode = null;
                    if (HtmlContainer != null && !HtmlContainer.AvoidGeometryAntialias && IsRounded)
                    {
                        prevMode = g.SetAntiAliasSmoothingMode();
                    }

                    if (roundrect != null)
                    {
                        g.DrawPath(brush, roundrect);
                    }
                    else
                    {
                        g.DrawRectangle(brush, Math.Ceiling(rect.X), Math.Ceiling(rect.Y), rect.Width, rect.Height);
                    }

                    g.ReturnPreviousSmoothingMode(prevMode);

                    if (roundrect != null)
                        roundrect.Dispose();
                    brush.Dispose();
                }

                if (_imageLoadHandler != null && _imageLoadHandler.Image != null && isFirst)
                {
                    BackgroundImageDrawHandler.DrawBackgroundImage(g, this, _imageLoadHandler, rect);
                }
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Draws the specified Image at the specified location and with the specified size.
 /// </summary>
 /// <param name="image">Image to draw. </param>
 /// <param name="destRect">Rectangle structure that specifies the location and size of the drawn image. </param>
 public abstract void DrawImage(RImage image, RRect destRect);
Ejemplo n.º 24
0
        /// <summary>
        /// Paints the text decoration (underline/strike-through/over-line)
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="rectangle"> </param>
        /// <param name="isFirst"> </param>
        /// <param name="isLast"> </param>
        protected void PaintDecoration(RGraphics g, RRect rectangle, bool isFirst, bool isLast)
        {
            if (string.IsNullOrEmpty(TextDecoration) || TextDecoration == CssConstants.None)
                return;

            double y = 0f;
            if (TextDecoration == CssConstants.Underline)
            {
                y = Math.Round(rectangle.Top + ActualFont.UnderlineOffset);
            }
            else if (TextDecoration == CssConstants.LineThrough)
            {
                y = rectangle.Top + rectangle.Height / 2f;
            }
            else if (TextDecoration == CssConstants.Overline)
            {
                y = rectangle.Top;
            }
            y -= ActualPaddingBottom - ActualBorderBottomWidth;

            double x1 = rectangle.X;
            if (isFirst)
                x1 += ActualPaddingLeft + ActualBorderLeftWidth;

            double x2 = rectangle.Right;
            if (isLast)
                x2 -= ActualPaddingRight + ActualBorderRightWidth;

            var pen = g.GetPen(ActualColor);
            pen.Width = 1;
            pen.DashStyle = RDashStyle.Solid;
            g.DrawLine(pen, x1, y, x2, y);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Get linear gradient color brush from <paramref name="color1"/> to <paramref name="color2"/>.
 /// </summary>
 /// <param name="rect">the rectangle to get the brush for</param>
 /// <param name="color1">the start color of the gradient</param>
 /// <param name="color2">the end color of the gradient</param>
 /// <param name="angle">the angle to move the gradient from start color to end color in the rectangle</param>
 /// <returns>linear gradient color brush instance</returns>
 protected abstract RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle);
Ejemplo n.º 26
0
 /// <summary>
 ///     Creates and returns an inflated copy of the specified <see cref="RRect" /> structure. The copy is inflated by the specified amount. The original rectangle remains unmodified.
 /// </summary>
 /// <returns>
 ///     The inflated <see cref="RRect" />.
 /// </returns>
 /// <param name="rect">
 ///     The <see cref="RRect" /> to be copied. This rectangle is not modified.
 /// </param>
 /// <param name="x">The amount to inflate the copy of the rectangle horizontally. </param>
 /// <param name="y">The amount to inflate the copy of the rectangle vertically. </param>
 public static RRect Inflate(RRect rect, double x, double y)
 {
     RRect rectangleF = rect;
     rectangleF.Inflate(x, y);
     return rectangleF;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Draw play over the iframe if we found link url.
        /// </summary>
        private void DrawPlay(RGraphics g, RRect rect)
        {
            if (_isVideo && _imageWord.Width > 70 && _imageWord.Height > 50)
            {
                var prevMode = g.SetAntiAliasSmoothingMode();

                var size = new RSize(60, 40);
                var left = rect.Left + (rect.Width - size.Width) / 2;
                var top = rect.Top + (rect.Height - size.Height) / 2;
                g.DrawRectangle(g.GetSolidBrush(RColor.FromArgb(160, 0, 0, 0)), left, top, size.Width, size.Height);

                RPoint[] points =
                {
                    new RPoint(left + size.Width / 3f + 1,top + 3 * size.Height / 4f),
                    new RPoint(left + size.Width / 3f + 1, top + size.Height / 4f),
                    new RPoint(left + 2 * size.Width / 3f + 1, top + size.Height / 2f)
                };
                g.DrawPolygon(g.GetSolidBrush(RColor.White), points);

                g.ReturnPreviousSmoothingMode(prevMode);
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 ///     Returns a <see cref="RRect" /> structure that represents the intersection of two rectangles. If there is no intersection, and empty
 ///     <see
 ///         cref="RRect" />
 ///     is returned.
 /// </summary>
 /// <returns>
 ///     A third <see cref="RRect" /> structure the size of which represents the overlapped area of the two specified rectangles.
 /// </returns>
 /// <param name="a">A rectangle to intersect. </param>
 /// <param name="b">A rectangle to intersect. </param>
 public static RRect Intersect(RRect a, RRect b)
 {
     double x = Math.Max(a.X, b.X);
     double num1 = Math.Min(a.X + a.Width, b.X + b.Width);
     double y = Math.Max(a.Y, b.Y);
     double num2 = Math.Min(a.Y + a.Height, b.Y + b.Height);
     if (num1 >= x && num2 >= y)
         return new RRect(x, y, num1 - x, num2 - y);
     return Empty;
 }
Ejemplo n.º 29
0
        /// <summary>
        /// On image load process is complete with image or without update the image box.
        /// </summary>
        /// <param name="image">the image loaded or null if failed</param>
        /// <param name="rectangle">the source rectangle to draw in the image (empty - draw everything)</param>
        /// <param name="async">is the callback was called async to load image call</param>
        private void OnLoadImageComplete(RImage image, RRect rectangle, bool async)
        {
            _imageWord.Image = image;
            _imageWord.ImageRectangle = rectangle;
            _imageLoadingComplete = true;
            _wordsSizeMeasured = false;

            if (_imageLoadingComplete && image == null)
            {
                SetErrorBorder();
            }

            if (async)
            {
                HtmlContainer.RequestRefresh(IsLayoutRequired());
            }
        }
Ejemplo n.º 30
0
 /// <summary>
 ///     Creates the smallest possible third rectangle that can contain both of two rectangles that form a union.
 /// </summary>
 /// <returns>
 ///     A third <see cref="RRect" /> structure that contains both of the two rectangles that form the union.
 /// </returns>
 /// <param name="a">A rectangle to union. </param>
 /// <param name="b">A rectangle to union. </param>
 public static RRect Union(RRect a, RRect b)
 {
     double x = Math.Min(a.X, b.X);
     double num1 = Math.Max(a.X + a.Width, b.X + b.Width);
     double y = Math.Min(a.Y, b.Y);
     double num2 = Math.Max(a.Y + a.Height, b.Y + b.Height);
     return new RRect(x, y, num1 - x, num2 - y);
 }