示例#1
0
        /// <summary>
        /// Test to see if the given point is inside of the current bounds
        /// </summary>
        /// <returns><c>true</c>, if in bounds, <c>false</c> otherwise.</returns>
        /// <param name="point">Point.</param>
        public virtual bool PointInBound(SKPoint point)
        {
            // Clear hit handle and test point
            HitHandle = null;
            var inBounds = (ValueBetween(point.X, Left, Right) && ValueBetween(point.Y, Top, Bottom));

            // Test all handles to see if they have been hit
            if (TopLeftHandle != null && TopLeftHandle.PointInBound(point))
            {
                HitHandle = TopLeftHandle;
                inBounds  = true;
            }
            else if (TopHandle != null && TopHandle.PointInBound(point))
            {
                HitHandle = TopHandle;
                inBounds  = true;
            }
            else if (TopRightHandle != null && TopRightHandle.PointInBound(point))
            {
                HitHandle = TopRightHandle;
                inBounds  = true;
            }
            else if (RightHandle != null && RightHandle.PointInBound(point))
            {
                HitHandle = RightHandle;
                inBounds  = true;
            }
            else if (BottomRightHandle != null && BottomRightHandle.PointInBound(point))
            {
                HitHandle = BottomRightHandle;
                inBounds  = true;
            }
            else if (BottomHandle != null && BottomHandle.PointInBound(point))
            {
                HitHandle = BottomHandle;
                inBounds  = true;
            }
            else if (BottomLeftHandle != null && BottomLeftHandle.PointInBound(point))
            {
                HitHandle = BottomLeftHandle;
                inBounds  = true;
            }
            else if (LeftHandle != null && LeftHandle.PointInBound(point))
            {
                HitHandle = LeftHandle;
                inBounds  = true;
            }
            else if (inBounds)
            {
                // See if we are in bounds
                HitOffset = new SKPoint((Left > Right) ? point.X - Right : point.X - Left, (Top > Bottom) ? point.Y - Bottom : point.Y - Top);
            }

            return(inBounds);
        }