Hey guys, I’m sure there are already posts on this somewhere, but i was wondering if it would be possible to make the label on a labeled link sit above any other link in that layer of the document. basically make the labels draw on top of anything else in the link layer(they already show up on top of nodes). I didnt see any properties that would let me change the z order, or maybe i was just looking in the wrong spot.
The labels of a GoLabeledLink are just child objects of the link, since GoLabeledLink inherits from GoGroup. So they will always have the same Z-order as the link itself. (Although of course you can change the Z-ordering of the link’s labels with respect to each other, as you can with the children of any group, but that doesn’t help you.)
One possibility is to override GoLabeledLink.Paint to just paint its RealLink, and delay the painting of all of the other children. You could override GoView.PaintObjects to do the normal painting of a layer, followed by painting all of the other children of those links:
[Serializable] public class TestLink : GoLabeledLink { public override void Paint(Graphics g, GoView view) { this.RealLink.Paint(g, view); SpecialView special = view as SpecialView; if (special != null) special.AddDelayedPaint(this); }
public void DelayedPaint(Graphics g, GoView view) { bool printing = view.IsPrinting; GoLink reallink = this.RealLink; foreach (GoObject child in this) { if (child == reallink) continue; if (printing ? child.CanPrint() : child.CanView()) { child.Paint(g, view); } } } }
public class SpecialView : GoView { private GoCollection myDelayeds = new GoCollection();
public void AddDelayedPaint(GoObject obj) { myDelayeds.Add(obj); }
protected override void PaintObjects(bool doc, bool view, Graphics g, RectangleF clipRect) { foreach (GoLayer layer in this.Layers) { if ((doc && layer.IsInDocument) || (view && layer.IsInView)) { myDelayeds.Clear(); layer.Paint(g, this, clipRect); foreach (GoObject obj in myDelayeds) { TestLink delayed = obj as TestLink; if (delayed != null) delayed.DelayedPaint(g, this); } } } } }
that worked, but i lost all of my custom settings on those labels. i initially want them to be invisible then if certain properties are set in the nodes will they show up, and they are supposed to be repositionable and have a connecting line back to their parent link. if i cant keep the behavior the same and make the labels be on top thats fine, i was just hoping there would be a way to do it.
You’re right – in the override of GoGroup.Paint I didn’t check whether each child was visible or not. I have updated the code in the post, above.
Everything should work fine if you are using the LinkLabels from the Processor sample, that are repositionable and that draw lines back to the RealLink.