public static Point FindClosestPoint(XCaseJunction junction, Point point, out int segmentNumber) { segmentNumber = 0; if (junction.Points.Count < 2) { return(new Point(0, 0)); } double min = double.MaxValue; Point result = new Point(); for (int segmentIndex = 0; segmentIndex < junction.Points.Count - 1; segmentIndex++) { Point p1 = junction.Points[segmentIndex].CanvasPosition; Point p2 = junction.Points[segmentIndex + 1].CanvasPosition; Point segmentCenter = new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2); Vector v = segmentCenter - point; if (v.Length < min) { segmentNumber = segmentIndex; min = v.Length; result = segmentCenter; } } return(result); }
public static Point FindClosestPoint(XCaseJunction junction, Point point) { int dummy; return(FindClosestPoint(junction, point, out dummy)); }
public static Rect GetLastElementBounds(XCaseJunction junction) { return(junction.TargetElement != null ? ((IConnectable)junction.TargetElement).GetBounds() : junction.EndPoint.GetBounds()); }
public static Rect GetLastButOneElementBounds(XCaseJunction junction) { return(junction.Points.Count <= 2 ? GetFirstElementBounds(junction) : junction.Points[junction.Points.Count - 2].GetBounds()); }
public static Rect GetFirstElementBounds(XCaseJunction junction) { return(((IConnectable)junction.SourceElement).GetBounds()); }
public JunctionGeometryData(XCaseJunction junction) { Junction = junction; }