public static BezierLayoutInfo Layout(Point pts, Point ptd, BezierControlPoint controlPoint1, BezierControlPoint controlPoint2) { var layout = new BezierLayoutInfo(); Point cp1, cp2; if (pts == ptd) { cp1 = pts; cp2 = ptd; layout.Bounds = Rectangle.Empty; layout.Region = null; } else { cp1 = GetControlPoint(pts, layout.CP1); cp2 = GetControlPoint(ptd, layout.CP2); //Point[] controlPoints = GetControlPoints(pts, ptd); /*Shape sShape = Shape.GetShaper(From); * pts = sShape.GetBorderPoint(From.Bounds, cp1); * * Shape dShape = Shape.GetShaper(Target); * ptd = sShape.GetBorderPoint(Target.Bounds, cp2); * * GraphicsPath gp = new GraphicsPath(); * gp.AddBezier(pts, cp1, cp2, ptd); * Pen penWiden = new Pen(Color.Black, LineWidth + 5); * gp.Widen(penWiden); * * RectangleF rect = gp.GetBounds(); * rect.Inflate(LineWidth, LineWidth); * layout.Bounds = rect; * layout.Region = new Region(gp);*/ } Point ptCenter = BezierHelper.GetPoint(pts, cp1, cp2, ptd, 0.5f); Rectangle textBounds = layout.TextBounds; textBounds.X = ptCenter.X - layout.TextBounds.Width / 2; textBounds.Y = ptCenter.Y - layout.TextBounds.Height / 2; // cache layout info //layout.StartBounds = rect1; //layout.EndBounds = rect2; layout.StartPoint = pts; layout.EndPoint = ptd; layout.ControlPoint1 = cp1; layout.ControlPoint2 = cp2; layout.TextBounds = textBounds; return(layout); }