public virtual bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint) { try { float r = m_radius + Width / 2; RectangleF boundingrect = HitUtil.CircleBoundingRect(m_center, r); if (anyPoint) { UnitPoint lp1 = new UnitPoint(rect.Left, rect.Top); UnitPoint lp2 = new UnitPoint(rect.Left, rect.Bottom); if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rect.Left, rect.Bottom); lp2 = new UnitPoint(rect.Right, rect.Bottom); if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rect.Left, rect.Top); lp2 = new UnitPoint(rect.Right, rect.Top); if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rect.Left, rect.Top); lp2 = new UnitPoint(rect.Right, rect.Top); if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rect.Right, rect.Top); lp2 = new UnitPoint(rect.Right, rect.Bottom); if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2)) { return(true); } } return(rect.Contains(boundingrect)); } catch (Exception ex) { throw ex; } }
public bool ObjectInRectangle(RectangleF rectangle, bool anyPoint) { RectangleF rect = HitUtil.CircleBoundingRectangle(this.P1, UCCanvas.GetThresholdWidth(this.radius)); if (anyPoint) { UnitPoint lp1 = new UnitPoint(rectangle.Left, rectangle.Top); UnitPoint lp2 = new UnitPoint(rectangle.Left, rect.Bottom); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Left, rectangle.Bottom); lp2 = new UnitPoint(rectangle.Right, rectangle.Bottom); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Left, rectangle.Top); lp2 = new UnitPoint(rectangle.Right, rectangle.Top); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Left, rectangle.Top); lp2 = new UnitPoint(rectangle.Right, rectangle.Top); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Right, rectangle.Top); lp2 = new UnitPoint(rectangle.Right, rectangle.Bottom); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } } return(rectangle.Contains(rect)); }