/// <summary>
        ///
        /// </summary>
        /// <param name="rectangle"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestRectangle(XRectangle rectangle, Rect2 rect, ISet <BaseShape> selected, double dx, double dy)
        {
            if (RectangleBounds.GetRectangleBounds(rectangle, dx, dy).IntersectsWith(rect))
            {
                if (selected != null)
                {
                    selected.Add(rectangle);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rectangle"></param>
        /// <param name="v"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static BaseShape HitTestRectangle(XRectangle rectangle, Vector2 v, double threshold, double dx, double dy)
        {
            if (RectangleBounds.GetPointBounds(rectangle.TopLeft, threshold, dx, dy).Contains(v))
            {
                return(rectangle.TopLeft);
            }

            if (RectangleBounds.GetPointBounds(rectangle.BottomRight, threshold, dx, dy).Contains(v))
            {
                return(rectangle.BottomRight);
            }

            if (RectangleBounds.GetRectangleBounds(rectangle, dx, dy).Contains(v))
            {
                return(rectangle);
            }

            return(null);
        }