public override bool ObjectInRectangle(Rectangle2D2 rect, ICanvasScreenConvertable canvasProxy, bool anyPoint) { if (rect == null) { throw new ArgumentNullException(nameof(rect)); } if (Ellipse2D == null) { return(false); } //无论是否为任意选中,若包含了,则能够选中; if (rect.Contains(Ellipse2D.Center) && rect.GetLines().All(p => p.Distance(Ellipse2D.Center) >= Ellipse2D.RadiusX)) { return(true); } //若为任意点选中,矩形的四个顶点中,存在任意两点任意一点在椭圆内即可; if (anyPoint && rect.GetLines().Any(p => { var intersectPoints = Extension.IntersectWithLine(Ellipse2D, p); return((intersectPoints?.Length ?? 0) != 0); })) { return(rect.GetVertexes().Any(p => Ellipse2D.Contains(p))); } return(false); }
/// <summary> /// 绘制矩形; /// </summary> /// <param name="brush">填充颜色</param> /// <param name="pen"></param> /// <param name="rectangle"></param> public void DrawRectangle(Rectangle2D2 rectangle, Brush brush, Pen pen) { if (rectangle == null) { throw new ArgumentNullException(nameof(rectangle)); } ValidateDrawingContext(); DrawFill(rectangle.GetVertexes(), brush, pen); }
/// <summary> /// 以视图坐标为标准,绘制矩形; /// </summary> /// <param name="rectangle">以视图坐标为准的矩形</param> /// <param name="brush">填充色</param> /// <param name="pen">笔</param> public void NativeDrawRectangle(Rectangle2D2 rectangle, Brush brush, Pen pen) { if (rectangle == null) { throw new ArgumentNullException(nameof(rectangle)); } ValidateDrawingContext(); var vertexes = rectangle.GetVertexes(); NativeDrawFill( vertexes.Select(p => Vector2DAdapter.ConvertToSystemPoint(p)), BrushAdapter.ConvertToSystemBrush(brush), PenAdapter.ConverterToSystemPen(pen) ); }