public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) { RectangleF a = RotateHelper.GetRotatedBounds(rect, Angle); float penWidth = PenWidth; GoObject.InflateRect(ref a, penWidth, penWidth); return(RectangleF.Union(rect, a)); }
/// <summary> /// A point on the ellipse that is coincident with a line drawn from /// the center of the ellipse to the given point. /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="result"></param> /// <returns></returns> public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result) { RectangleF a = Bounds; float num = PenWidth / 2f; GoObject.InflateRect(ref a, num, num); return(NearestIntersectionOnEllipse(a, p1, p2, out result)); }
/// <summary> /// Determines if the given point is inside this handle's bounds. /// </summary> /// <param name="p"> /// A <c>PointF</c> value in document coordinates. /// </param> /// <returns> /// True if the point is considered "on" the handle. /// </returns> /// <remarks> /// This assumes that handles are actually hollow when the /// <see cref="P:Northwoods.Go.GoHandle.HandleID" /> is <see cref="P:Northwoods.Go.GoHandle.GoObject" />.<c>NoHandle</c>-- /// that is, a point well inside the handle's bounds is /// not considered "on" the handle if the handle's ID is /// <see cref="P:Northwoods.Go.GoHandle.GoObject" />.<c>NoHandle</c>. This is useful for /// letting bounding handles be ignored by mouse over behavior. /// Note that this method does not take the <see cref="P:Northwoods.Go.GoHandle.Style" /> /// into account--it assumes the handle is rectangular. /// </remarks> public override bool ContainsPoint(PointF p) { RectangleF a = Bounds; float penWidth = PenWidth; GoObject.InflateRect(ref a, penWidth / 2f, penWidth / 2f); if (!GoObject.ContainsRect(a, p)) { return(false); } if (HandleID == 0) { GoObject.InflateRect(ref a, 0f - penWidth, 0f - penWidth); return(!GoObject.ContainsRect(a, p)); } return(true); }
/// <summary> /// Treat this rectangle as being hollow--the user can only pick the rectangle when close to the edge. /// </summary> /// <param name="p"></param> /// <returns></returns> public override bool ContainsPoint(PointF p) { GoView view = base.View; if (view == null) { return(false); } RectangleF a = Bounds; float num = 4f / view.DocScale; GoObject.InflateRect(ref a, num, num); if (!GoObject.ContainsRect(a, p)) { return(false); } GoObject.InflateRect(ref a, -2f * num, -2f * num); return(!GoObject.ContainsRect(a, p)); }
/// <summary> /// Position the <see cref="P:Northwoods.Go.GoBoxNode.Port" /> to be centered on the <see cref="P:Northwoods.Go.GoBoxNode.Body" />, /// but sized larger by <see cref="P:Northwoods.Go.GoBoxNode.PortBorderMargin" /> width and height on /// each side. /// </summary> /// <param name="childchanged"></param> /// <remarks> /// This method does nothing if there is no <see cref="P:Northwoods.Go.GoBoxNode.Body" />. /// </remarks> public override void LayoutChildren(GoObject childchanged) { if (base.Initializing) { return; } GoObject body = Body; if (body != null) { GoObject port = Port; if (port != null) { RectangleF a = body.Bounds; SizeF portBorderMargin = PortBorderMargin; GoObject.InflateRect(ref a, portBorderMargin.Width, portBorderMargin.Height); port.Bounds = a; } } }
/// <summary> /// Additional painted area includes part of the border giving 3D control appearance. /// </summary> /// <param name="rect"></param> /// <param name="view"></param> /// <returns></returns> public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) { GoObject.InflateRect(ref rect, 2f, 2f); return(rect); }
/// <summary> /// Find the intersection points of a pie and the infinite line p1-p2 /// that is closest to point p1. /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="result"></param> /// <returns></returns> public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result) { RectangleF a = Bounds; float num = PenWidth / 2f; GoObject.InflateRect(ref a, num, num); float num2 = a.Width / 2f; float num3 = a.Height / 2f; float num4 = a.X + num2; float num5 = a.Y + num3; float num6 = p1.X - num4; float num7 = p1.Y - num5; float startAngle = StartAngle; float sweepAngle = SweepAngle; float num8 = startAngle + sweepAngle; if (num8 > 360f) { num8 -= 360f; } bool result2 = false; float num9 = 1E+21f; result = default(PointF); if (-0.01f < num6 && num6 < 0.01f) { num6 = 0.01f; } if (-0.01f < num7 && num7 < 0.01f) { num7 = 0.01f; } PointF result3; if (sweepAngle >= 360f) { if (GoEllipse.NearestIntersectionOnEllipse(a, p1, p2, out result3)) { float num10 = (p1.X - result3.X) * (p1.X - result3.X) + (p1.Y - result3.Y) * (p1.Y - result3.Y); if (num10 < num9) { result2 = true; result = result3; num9 = num10; } } } else if (sweepAngle + startAngle > 360f) { if (GoEllipse.NearestIntersectionOnArc(a, p1, p2, out result3, startAngle, 360f - startAngle)) { float num11 = (p1.X - result3.X) * (p1.X - result3.X) + (p1.Y - result3.Y) * (p1.Y - result3.Y); if (num11 < num9) { result2 = true; result = result3; num9 = num11; } } if (GoEllipse.NearestIntersectionOnArc(a, p1, p2, out result3, 0f, sweepAngle - (360f - startAngle))) { float num12 = (p1.X - result3.X) * (p1.X - result3.X) + (p1.Y - result3.Y) * (p1.Y - result3.Y); if (num12 < num9) { result2 = true; result = result3; num9 = num12; } } } else if (GoEllipse.NearestIntersectionOnArc(a, p1, p2, out result3, startAngle, sweepAngle)) { float num13 = (p1.X - result3.X) * (p1.X - result3.X) + (p1.Y - result3.Y) * (p1.Y - result3.Y); if (num13 < num9) { result2 = true; result = result3; num9 = num13; } } PointF pointAtAngle = GetPointAtAngle(startAngle); if (GoStroke.NearestIntersectionOnLine(new PointF(num4, num5), pointAtAngle, p1, p2, out result3)) { float num14 = (p1.X - result3.X) * (p1.X - result3.X) + (p1.Y - result3.Y) * (p1.Y - result3.Y); if (num14 < num9) { result2 = true; result = result3; num9 = num14; } } PointF pointAtAngle2 = GetPointAtAngle(num8); if (GoStroke.NearestIntersectionOnLine(new PointF(num4, num5), pointAtAngle2, p1, p2, out result3)) { float num15 = (p1.X - result3.X) * (p1.X - result3.X) + (p1.Y - result3.Y) * (p1.Y - result3.Y); if (num15 < num9) { result2 = true; result = result3; num9 = num15; } } return(result2); }