GeometryExtensions
Methods related to planar geometry.
Definition
Namespace:Telerik.WinControls.UI.Diagrams
Assembly:Telerik.WinControls.RadDiagram.dll
Syntax:
public static class GeometryExtensions
Inheritance: objectGeometryExtensions
Methods
Adds the given PathSegment to the path figure and sets the starting point at the same time.
public static PathFigure Add(this PathFigure pathFigure, PathSegment segment, Point startPoint)
The path figure.
segmentPathSegmentThe segment.
startPointPointThe start point.
Returns:The augmented path figure.
Adds the given PathSegment to the path figure.
public static PathFigure Add(this PathFigure pathFigure, PathSegment segment)
The path figure.
segmentPathSegmentThe segment.
Returns:The augmented path figure.
Adds the given figure to the geometry.
public static PathGeometry Add(this PathGeometry pathGeometry, PathFigure pathFigure)
The path geometry.
pathFigurePathFigureThe path figure.
Returns:The resulting path geometry.
Adds an arc to the path figure.
public static void AddArc(this PathFigure pathFigure, double x, double y, double width, double height, double startAngle, double sweep, bool startPoint)
The figure.
xdoubleThe x-coordinate of the bounding rectangle.
ydoubleThe y-coordinate of the bounding rectangle.
widthdoubleThe width of the bounding rectangle.
heightdoubleThe height of the bounding rectangle.
startAngledoubleThe start angle.
sweepdoubleThe sweeping angle of the arc.
startPointboolIf set to true the starting point will be set.
Adds a bezier segment to the path.
public static void AddBezier(this PathFigure pathFigure, double[] points)
The path.
pointsdouble[]The eight values specifying the eight coordinates of the four Bezier points.
Adds a bezier segment to the path.
public static void AddBeziers(this PathFigure pathFigure, Point[] points)
The figure.
pointsPoint[]The points defining the Bezier segment.
Adds a line to the path.
public static PathFigure AddLine(this PathFigure pathFigure, double x1, double y1, double x2, double y2)
The path figure.
x1doubleThe x-coordinate of the start point.
y1doubleThe y-coordinate of the start point.
x2doubleThe x-coordinate of the end point.
y2doubleThe y-coordinate of the end point.
Returns:Adds a line to the path.
public static PathFigure AddLine(this PathFigure pathFigure, Point point1, Point point2)
The path figure.
point1PointThe start point of the line.
point2PointThe end point of the line.
Returns:The augmented path figure.
Adds a polyline to the figure.
public static void AddPolyLine(this PathFigure pathFigure, IEnumerable<Point> points)
The figure.
pointsIEnumerable<Point>The points defining the polyline.
Adds a polyline to the figure.
public static void AddPolyLine(this PathFigure pathFigure, PointCollection collection)
The figure.
collectionPointCollectionThe points defining the polyline.
Creates a line geometry based on the given specifications.
public static PathGeometry CreateBaseLineGeometry(LineSpecification specs)
The specs.
Returns:- This method will create the base line of a connection. This line will including possible bridges but no end caps.
- All coordinates handled in this method are local positions.
Creates a bezier geometry.
public static Geometry CreateBezier(Point startPoint, Point endPoint, Point startBezierPoint, Point endBezierPoint, double tension = 1)
The start point.
endPointPointThe end point.
startBezierPointPointThe start bezier point.
endBezierPointPointThe end bezier point.
tensiondoubleThe tension of the Bezier curve.
Returns:This method is called by the connection update process to create a geometry which is then plugged into the Path in the XAML template of the connection.
public static Geometry CreateConnectionGeometry(IConnection connection, BridgeType connectionBridge, bool connectionRoundedCorners)
The connection for which to create a geometry.
connectionBridgeBridgeTypeWhat type of bridging should be applied to the line.
connectionRoundedCornersboolWhether the corners of the line should be rounded.
Returns:The geometry of the connection path.
- The method essentially dispatches first a calculation of the route, if required, and then hands over a specification to the CreateLineGeometry(PolylineSpecification) method.
- The points defined by the given connection and the routing service are global positions, they are converted internally to local coordinates.
Creates the polyline.
public static Geometry CreateLineGeometry(Point startPoint, Point endPoint, bool roundedCorners = false, params Point[] points)
The start point.
endPointPointThe end point.
roundedCornersboolIf set to true the corners of the polyline will be rounded.
The points.
Returns:Creates a line geometry based on the given specifications.
public static Geometry CreateLineGeometry(PolylineSpecification specs)
- This method will create a polyline or Bezier line including possibly the end caps and the crossings.
- This method decouples between the method called by the connection (CreateConnectionGeometry(IConnection, BridgeType, bool)) on the one hand and the more specific methods for a polyline (CreatePolylineLineFigure(PolylineSpecification)) or a Bezier line () on the other.
- All coordinates handled in this method are local positions.
Creates a geometry.
public static Geometry CreatePathGeometry(Point startPoint, IList<PathSegment> pathSegments)
The start point.
pathSegmentsIList<PathSegment>The path segments.
Returns:Gets the polyline figure.
public static PathGeometry CreatePolylineLineFigure(PolylineSpecification specs)
The polyline specifications.
Returns:Adds rounded corners to the existing polyline figure.
public static void CreateRoundedPolyline(PathFigure figure, IList<Point> points, bool addLastLine)
The figure which will be incremented with corner arcs.
pointsIList<Point>The points of the polyline.
addLastLineboolIf set to true the last line segment will be added.
The corner radius is set in the ConnectionCornerRadius and has default 5.0 pixels.
Creates a canonical spline figure.
public static IList<PathFigure> CreateSplineFigures(IList<Point> points, double tension = 0.5, bool isClosed = false, bool isFilled = false)
The points defining the spline. These should be in local coordinates and include the endpoints.
tensiondoubleThe tension of the spline. A tension or zero will result in a polyline, a tension between 0.5 and 0.8 is pleasing, other values lead to wild curves.
isClosedboolIf set to true the curve will be closed.
If set to true the shape will be filled .
IList<PathFigure>
Based on the code in http://www.charlespetzold.com/blog/2009/01/canonical-splines-in-wpf-and-silverlight.html.
Finds the intersection.
public static Point FindIntersection(Point sourcePoint, Point targetPoint, Geometry geometry, double edgeThick, bool isArrow)
The source point.
targetPointPointThe target point.
geometryGeometryThe geometry.
edgeThickdoubleThe edge thick.
isArrowboolIf set to true [is arrow].
public static GraphicsPath GetGeometry(PathGeometry geometry)
Gets the tangents of the spline figure.
public static void GetSplineFigureTangents(IList<Point> points, out Point startTangentPoint, out Point endTangentPoint, double tension = 0.5, bool isClosed = false)
The points of the connection.
startTangentPointPointThe start tangent point.
endTangentPointPointThe end tangent point.
tensiondoubleThe tension.
isClosedboolIf set to true [is closed].