/// <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); }
/// <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); }