Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="point"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestPoint(XPoint point, Rect2 rect, ISet <BaseShape> selected, double threshold, double dx, double dy)
        {
            if (ShapeBounds.GetPointBounds(point, threshold, dx, dy).IntersectsWith(rect))
            {
                if (selected != null)
                {
                    selected.Add(point);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ellipse"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestEllipse(XEllipse ellipse, Rect2 rect, ISet <BaseShape> selected, double dx, double dy)
        {
            if (ShapeBounds.GetEllipseBounds(ellipse, dx, dy).IntersectsWith(rect))
            {
                if (selected != null)
                {
                    selected.Add(ellipse);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestText(XText text, Rect2 rect, ISet <BaseShape> selected, double dx, double dy)
        {
            if (ShapeBounds.GetTextBounds(text, dx, dy).IntersectsWith(rect))
            {
                if (selected != null)
                {
                    selected.Add(text);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arc"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestArc(XArc arc, Rect2 rect, ISet <BaseShape> selected, double dx, double dy)
        {
            if (ShapeBounds.GetArcBounds(arc, dx, dy).IntersectsWith(rect))
            {
                if (selected != null)
                {
                    selected.Add(arc);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="quadraticBezier"></param>
        /// <param name="selection"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestQadraticBezier(XQuadraticBezier quadraticBezier, Vector2[] selection, ISet <BaseShape> selected, double dx, double dy)
        {
            var points = quadraticBezier.GetPoints().ToImmutableArray();

            if (ShapeBounds.Overlap(selection, points, dx, dy))
            {
                if (selected != null)
                {
                    selected.Add(quadraticBezier);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="line"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestLine(XLine line, Rect2 rect, ISet <BaseShape> selected, double threshold, double dx, double dy)
        {
            double x0clip, y0clip, x1clip, y1clip;

            if (ShapeBounds.GetPointBounds(line.Start, threshold, dx, dy).IntersectsWith(rect) ||
                ShapeBounds.GetPointBounds(line.End, threshold, dx, dy).IntersectsWith(rect) ||
                Line2.LineIntersectsWithRect(new Point2(line.Start.X, line.Start.Y), new Point2(line.End.X, line.End.Y), rect, out x0clip, out y0clip, out x1clip, out y1clip))
            {
                if (selected != null)
                {
                    selected.Add(line);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="selection"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestPath(XPath path, Vector2[] selection, ISet <BaseShape> selected, double dx, double dy)
        {
            if (path.Geometry != null)
            {
                var points = path.GetPoints().ToImmutableArray();
                if (ShapeBounds.Overlap(selection, points, dx, dy))
                {
                    if (selected != null)
                    {
                        selected.Add(path);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }