For each node you can define one or more points to which links dock upon linking to that node. Such points are represented by instances of the AnchorPoint class. The position of an anchor point relative to node's bounding rectangle is specified through the X and Y properties. Their values are expressed as percent of the node's width and height to accommodate for moving and resizing. The final location of an anchor point is determined by this simple calculation:
C# Copy Code |
---|
return new PointF( |
Visual Basic Copy Code |
---|
Return New PointF( _ |
The AllowIncoming and AllowOutgoing properties control whether an anchor point accepts incoming or outgoing links or both. When a link is drawn, its ends are aligned to the nearest anchors allowing docking of the respective end type. Another way to control whether links can be linked to an ancor point is to handle the ValidateAnchorPoint event.
An AnchorPattern instance defines a set of anchor points to be used together. When creating an anchor pattern, pass to its constructor an array of AnchorPoint objects. The AnchorPattern class exposes several predefined patterns as static properties. An existing pattern can be assigned as a single entity to the AnchorPattern property of nodes. The following VB.NET example creates a pattern of four anchor points:
C# Copy Code |
---|
apat1 = new AnchorPattern(new AnchorPoint() { _ |
Visual Basic Copy Code |
---|
apat1 = new AnchorPattern(new AnchorPoint() { _ |
The points are located at the middles of bounding rectangle sides of nodes to which the pattern is assigned. All four points accept both incoming and outgoing links.
Anchor points can be hidden, always visible on the screen, or displayed automatically, as set in ShowAnchors. The appearance of anchor point marks can be customized by their MarkStyle and Color properties.
A distinct anchor pattern can be assigned to every row of a table. When a link is connected to a row, the respective end of the link is aligned to the nearest AnchorPoint assigned to that row. If a row does not have associated anchor points of the appropriate type (incoming/outgoing), the link will be linked to the nearest row that has such anchors defined. If none of the rows of a table has an associated anchor pattern, links are connected to the middle of the left or right side of the pointed row.