Hi Stoyan,
1. It seems weird that Anchoring.Keep changes the anchor points, but now at least I know it
.
3. & 4. That was the problem. I got the jumping problem almost solved using LinkValidationEventArgs directly.
I also had to use e.ChangingOrigin & e.ChangingDestination to set linkX.
A) You suggested me that I don't use e.ChangingOrigin before... Is this advice still valid? If so, what can I use instead?
B) There is still a problem. When I create a link from the left anchor point, everything is fine. There is no jump possible to the right one as it should.
However, when I create a link from the right anchor point, it immediately jumps to the left one. Of course, after that my code prevents it from going back to the right anchorPt. Why can't my code catch the first jump and how can I fix this? There is no problem in regards to destination points.
Thanks a lot!
Marie
N.B. This is the code I've got so far:
void diagram_ValidateAnchorPoint(object sender, LinkValidationEventArgs e)
{
try
{
TableNode node = e.Node as TableNode;
AnchorPoint originAnchorPt = node.Rows[e.TableRow].AnchorPattern.Points[e.AnchorIndex];
float linkX;
if (e.ChangingOrigin)
linkX = e.Link.ControlPoints[0].X;
else if (e.ChangingDestination)
{
PointCollection ptColl = e.Link.ControlPoints;
linkX = ptColl[ptColl.Count - 1].X;
}
else
return;
float nodeMiddleHorizontalPt = node.Bounds.Width / 2 + node.Bounds.X;
if ((int)originAnchorPt.Tag == ANCHOR_LEFT && linkX > nodeMiddleHorizontalPt)
e.Cancel = true;
else if ((int)originAnchorPt.Tag == ANCHOR_RIGHT && linkX < nodeMiddleHorizontalPt)
e.Cancel = true;
}
catch (System.Exception) { }
}