Bezier Line

Hi,
I have a bezier line that has a midlable that derives from GoLabeledLink, what I want to do is ONLY move the icon to shape the bezier line that I want to keep behind that line
At the moment I have to resize par of the bezier line, but the I only want this to happen via moving the icon
Any Idea?
Thanks
Phil

You can get rid of resize handles by setting RealLink.Reshapable to false. You might also want to set HighlightWhenSelected to true and set HighlightPen to a wide Pen, so that there is something to decorate the link when it is selected.
I think you can override GoLabeledLink.LayoutMidLabel to modify the RealLink’s points when the childchanged argument is the MidLabel itself. But you may find computing the desired control points for the Bezier curve to be challenging. Here’s something simple that might work for your purposes:
protected override void LayoutMidLabel(GoObject childchanged) {
if (childchanged == this.MidLabel) {
this.Initializing = true;
GoStroke s = this.RealLink;
s.SetPoint(1, childchanged.Center);
s.SetPoint(2, childchanged.Center);
childchanged.Center = BezierMidPoint(s.GetPoint(0), s.GetPoint(1), s.GetPoint(2), s.GetPoint(3));
this.Initializing = false;
} else {
base.LayoutMidLabel(childchanged);
}
}
internal static PointF BezierMidPoint(PointF b0, PointF b1, PointF b2, PointF b3) {
PointF c1 = new PointF((b0.X+b1.X)/2, (b0.Y+b1.Y)/2);
PointF c2 = new PointF((b1.X+b2.X)/2, (b1.Y+b2.Y)/2);
PointF c3 = new PointF((b2.X+b3.X)/2, (b2.Y+b3.Y)/2);
PointF v = new PointF((c1.X+c2.X)/2, (c1.Y+c2.Y)/2);
PointF w = new PointF((c2.X+c3.X)/2, (c2.Y+c3.Y)/2);
return new PointF((v.X+w.X)/2, (v.Y+w.Y)/2);
}

Wow that is brillant works straight off and what I needed!
Is it possible to see the result of the changes as I drag the lines as well though?

finally
I thought I would post on the back of this post because you get the complete picture
I have implemented that change as you said
In the mid label i have a GoGroup, that I want to move as one item, but I move these items alternatly
i thought there should be someone of only moving the group and I have looked on the properties and sadly I havent found one
Thanks
Phil

Did you want to turn on GoView.DragsRealtime? But that will change all dragging to be “realtime”, not just dragging your MidLabel object.
Perhaps the children of the GoGroup that is your GoLabeledLink.MidLabel should not be Selectable.
But of course your group needs to be Selectable and Movable in order for users to drag it. You might want to turn off Copyable and Deletable on that group, if you don’t want users to copy or delete that MidLabel object by itself.

yeah that works a dream…
the last thing needed is when i move one of the icons all the other links are changed that are connected to a node, where I want those links to remain
Im thinking LayoutMidLabel, if you can point me to a class that I need that would be great
Thanks,
Phil

I suppose in that method you could go about modifying the other links that are connected to one or both nodes. But you need to watch out for unintended “feedback loops” – i.e. changing another link might cause a change to the original link, etc.

Well thats the thing…
I dont want to affect anything around it, I want all the links to stay as they are.
So if I move a node then everyother links connected to it stays where they are…
Proving to be a tough one
Thanks
Phil

I guess I don’t understand what the situation is and what you want. Could you please be more specific and precise?

Sorry,
Ok imagine this, I have two icons, a and b, and i link a line between these two nodes, then I move the icon, and so the link still “goes through” my midlabel
Now when I move icon a or b the line that was once curvey is now a straight line and lost all formatting that I want to keep
Is that ok?
thanks
Phil

Oh, I think I understand. Your mixing of the terms “icon” and “node” and “link” and “line” makes it hard, though, so I might be wrong.
I suggest you set GoLink.AdjustingStyle to be a value other than default GoLinkAdjustingStyle.Calculate.

your on the money, thats great