Middle segment

I have a problem with midlabel of a Golabelledlink.



I tried this:



Dim textLabel As GoTextNode = New GoTextNode

textLabel.Label.Text = msReponse

textLabel.Label.TextColor = Color.Black

textLabel.Brush = Brushes.White

textLabel.Pen = Pens.Transparent

textLabel.Label.TransparentBackground = False

textLabel.Selectable = False

myDoc.IsAvoidable(textLabel)

Me.MidLabelCentered = True

Me.MidLabel = textLabel



But the text appear not in the middle segment of my link but in the first segment how could I resolve it.









Thanks for your help.

You can override GoLabeledLink.LayoutMidLabel to position the MidLabel whereever you want. By default it does choose the middle segment – however the middle segment might not be near the geometric middle of the bounds of the whole link.

On on unrelated note -- are you intentionally choosing to use a node with four ports as the object that is the GoLabeledLink.MidLabel? If you don't want there to be links connected from/to this "label", it would be much more efficient to use a simple GoText object instead of a GoTextNode.

I tried to use a Gotext it was the same problem.



And concerning the geometric middle I think that it is not what happens because my link goes to the bottom of gotextnode to the top of the other and there are 2 segments in my link and it took the first.



When I override LayoutMidLabel I tried to set at the middle segment of my link but there was no childs in my link and i don’t know how to get the middle segment of any link in my goview.



Can you help me?



This probably doesn't do what you want, since the label will not necessarily be positioned near a link segment. But at least it gives you a simple example of how to override GoLabeledLink.LayoutMidLabel:
[code] protected override void LayoutMidLabel(GoObject childchanged) {
GoLink link = this.RealLink;
GoObject lab = this.MidLabel;
if (lab != null && link != null && link.PointsCount >= 2) {
lab.Center = link.Center;
}
}
[/code]