Exemplo n.º 1
0
        /// <summary>
        /// Invalidates the specified region of the canvas (adds it to the canvas's update region,
        /// which is the area that will be repainted at the next paint operation), and causes a paint
        /// message to be sent to the canvas.
        /// </summary>
        /// <param name="bounds">A rectangle object that represents the region to invalidate.</param>
        public virtual void InvalidateBounds(RectangleF bounds)
        {
            PDebug.ProcessInvalidate();

            if (regionManagement)
            {
                // Hack: Invalidate the bounds of the previously invalidated rectangle
                // and the current rectangle, since invalidating lots of small rectangles
                // causes a performance hit.
                if (invalidatedBounds.IsEmpty)
                {
                    invalidatedBounds = bounds;
                }
                else
                {
                    invalidatedBounds = RectangleF.Union(invalidatedBounds, bounds);
                }

                RectangleF insetRect = new RectangleF(invalidatedBounds.X - 1, invalidatedBounds.Y - 1,
                                                      invalidatedBounds.Width + 2, invalidatedBounds.Height + 2);

                int x      = (int)Math.Floor(insetRect.X);
                int y      = (int)Math.Floor(insetRect.Y);
                int width  = (int)Math.Ceiling(insetRect.Right - x);
                int height = (int)Math.Ceiling(insetRect.Bottom - y);
                Invalidate(new Rectangle(x, y, width, height));
            }
            else
            {
                Invalidate();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invalidates the specified region of the canvas (adds it to the canvas's update region,
        /// which is the area that will be repainted at the next paint operation), and causes a paint
        /// message to be sent to the canvas.
        /// </summary>
        /// <param name="bounds">A rectangle object that represents the region to invalidate.</param>
        public void InvalidateBounds(RectangleF bounds)
        {
            PDebug.ProcessInvalidate();

            Rectangle insetRect = new Rectangle((int)Math.Floor(bounds.X) - 1, (int)Math.Floor(bounds.Y) - 1,
                                                (int)Math.Ceiling(bounds.Width) + 2, (int)Math.Ceiling(bounds.Height) + 2);

            Invalidate(insetRect);
        }