Exemplo n.º 1
0
        /// <summary>
        /// Clips the <paramref name="rect"/> to the <paramref name="container"/>.
        /// </summary>
        /// <param name="rect">The <see cref="RadRect"/> to be clipped.</param>
        /// <param name="container">The container.</param>
        /// <param name="borderOverflow">The border (stroke thickness) of the <paramref name="rect"/>.</param>
        /// <param name="dashPatternLength">The length of the dash pattern of the <see cref="RadRect"/> stroke.</param>
        /// <returns>The clipped rectangle.</returns>
        internal static RadRect ClipRectangle(RadRect rect, RadRect container, double borderOverflow, double dashPatternLength)
        {
            // extend the container with the element border
            container.X      -= borderOverflow;
            container.Y      -= borderOverflow;
            container.Width  += 2 * borderOverflow;
            container.Height += 2 * borderOverflow;

            if (!rect.IntersectsWith(container))
            {
                return(RadRect.Empty);
            }

            // calculate the clipped rectangle, extended with the element border
            double xFrom = RadMath.CoerceValue(rect.X, container.X, container.Right);
            double yFrom = RadMath.CoerceValue(rect.Y, container.Y, container.Bottom);
            double xTo   = RadMath.CoerceValue(rect.Right, container.X, container.Right);
            double yTo   = RadMath.CoerceValue(rect.Bottom, container.Y, container.Bottom);

            if (dashPatternLength == 0 || double.IsNaN(dashPatternLength) || double.IsInfinity(dashPatternLength))
            {
                dashPatternLength = 1;
            }

            // first check if "To" values are clipped, and if so, add the additional space needed by the dash array to be rendered correctly
            if (rect.Right != xTo)
            {
                xTo += (rect.Right - xTo) % dashPatternLength;
            }

            if (rect.Bottom != yTo)
            {
                yTo += (rect.Bottom - yTo) % dashPatternLength;
            }

            // check if "From" values are clipped, and if so, add the additional space needed by the dash array to be rendered correctly and change the rect coordinates
            if (rect.X != xFrom)
            {
                xFrom -= (xFrom - rect.X) % dashPatternLength;
                rect.X = xFrom;
            }

            if (rect.Y != yFrom)
            {
                yFrom -= (yFrom - rect.Y) % dashPatternLength;
                rect.Y = yFrom;
            }

            rect.Width  = xTo - xFrom;
            rect.Height = yTo - yFrom;

            return(rect);
        }
Exemplo n.º 2
0
        internal override void UpdateVisibility()
        {
            RadRect plotAreaLayoutSlot = this.chart.chartArea.plotArea.layoutSlot;

            // point is laid-out outside the clip area, skip it from visualization
            if (plotAreaLayoutSlot.IntersectsWith(this.Model.layoutSlot))
            {
                this.SetPresenterVisibility(Visibility.Visible);
            }
            else
            {
                this.SetPresenterVisibility(Visibility.Collapsed);
            }
        }
Exemplo n.º 3
0
        public void Test_InterceptsWith()
        {
            RadRect rect1 = new RadRect(10, 10, 20, 20);

            Assert.IsTrue(rect1.IntersectsWith(rect1));

            RadRect rect2 = new RadRect(15, 15, 20, 20);

            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(15, 5, 20, 20);
            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(15, 15, 10, 10);
            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(15, 5, 40, 40);
            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(5, 5, 40, 40);
            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(5, 15, 40, 40);
            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(15, 15, 10, 10);
            Assert.IsTrue(rect1.IntersectsWith(rect2));
            Assert.IsTrue(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(5, 5, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(15, 5, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(5, 15, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(5, 35, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(15, 35, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(35, 5, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(35, 15, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));

            rect2 = new RadRect(35, 35, 4, 4);
            Assert.IsFalse(rect1.IntersectsWith(rect2));
            Assert.IsFalse(rect2.IntersectsWith(rect1));
        }