Automatic position A GoImage with a GoIconicNode

I have added a extra image to the GoIconicNode which is hidden or visible depending on application settings.
When the GoImage is created it is positioned on (0,0) relative to the GoIconicNode.

But when I call the PerformLayout member function of GoLayoutLayeredDigraph the GoImage is not repositioned. What am I doing wrong?

GoLayoutLayeredDigraph lays out nodes and links. But for laying out the parts within a Node, you need to override LayoutChildren.
In Demo1, DecoratedTextNode is similar to what you are doing. (It adds an image to GoTextNode instead of GoIconicNode, but is going to be pretty much the same other than that.)

I am using GoDiagram Win 2.4.1 and cannot find the DecoratedTextNode class in the demo1 project.

Here it is. (I clipped a second unrelated class out of the end of this... I think I have the {brackets} right.)
[code]
/*
* Copyright © Northwoods Software Corporation, 1998-2006. All Rights
* Reserved.
*
* Restricted Rights: Use, duplication, or disclosure by the U.S.
* Government is subject to restrictions as set forth in subparagraph
* (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR
* 52.227-14 Alt. III, as applicable.
*/
using System;
using System.Drawing;
using Northwoods.Go;
namespace Demo1 {
// A GoTextNode with a decoration near the top right corner,
// showing an image "behind" the Background shape and some text
// centered on the image.
[Serializable]
public class DecoratedTextNode : GoTextNode {
public DecoratedTextNode() {
// create the decoration
TextNodeDecoration decoration = new TextNodeDecoration();
myDecoration = decoration;
// put the decoration behind the Background shape
InsertBefore(this.Background, decoration);
// initialize this node...
this.Text = "DecoratedTextNode";
}
// this field keeps track of this group's decoration
private TextNodeDecoration myDecoration = null;
// update the field to refer to the copied decoration if the node is copied
protected override void CopyChildren(GoGroup newgroup, GoCopyDictionary env) {
base.CopyChildren(newgroup, env);
DecoratedTextNode node = (DecoratedTextNode)newgroup;
node.myDecoration = (TextNodeDecoration)env[myDecoration];
}
// this property is for convenience in accessing the decoration
public TextNodeDecoration Decoration {
get { return myDecoration; }
}
// these two properties are for convenience, if you want to get or set their values
public String DecorationImageName {
get {
TextNodeDecoration dec = this.Decoration;
if (dec != null)
return dec.ImageName;
else
return "";
}
set {
TextNodeDecoration dec = this.Decoration;
if (dec != null)
dec.ImageName = value;
}
}
public String DecorationText {
get {
TextNodeDecoration dec = this.Decoration;
if (dec != null)
return dec.Text;
else
return "";
}
set {
TextNodeDecoration dec = this.Decoration;
if (dec != null)
dec.Text = value;
}
}
// position the BottomRight of the decoration's Label to be just
// above this node's Background, aligned with the right edge of this node's Label
public override void LayoutChildren(GoObject childchanged) {
base.LayoutChildren(childchanged);
TextNodeDecoration dec = this.Decoration;
if (dec != null && this.Background != null && this.Label != null) {
PointF pt = new PointF(this.Label.Right, this.Background.Top);
dec.Label.SetSpotLocation(BottomRight, pt);
}
}
}
}
[/code]