Implementing a Legend for my org chart

Walter,

I know you are getting sick of me, but this question is a simple one…I think.

I want to put a Legend in the org chart I have implemented. So, for every different shape that is in the org chart (different types of organizations, or job positions have different shapes), I would like to have one example in a “legend” off to the side of the chart.

I was planning on just having a rectangular box that would contain, for instance, 1 rectangle, 1 rounded rectangle, and 1 trapezoid.

My question is, what is the best way to implement this? Should I create a seperate layer, and put the containing rectangle in it? Then I could create another layer and put the rectangle, rounded rect, and trapezoid in that layer, positioned to appear over or “inside” the containing rectangle?

I have experimented with just creating the containing rectangle (the “Legend” box) and ADDING the rect, rounded rect, and trapezoid to it. Then adding the containing rectangle to the document. But, that has not been working as I thought it might.

( I am implementing the shapes as Basic Nodes with the various shapes defined for them)

Thanks for your infinite patience, and your advice.
Roger

I would use a GoGroup to hold a bunch of GoShapes and GoTexts.

In fact, you might want to use GoListGroup as your group, and have each pair of shape/descriptions be another GoListGroup with Orientation=Horizontal. Demo1 has a bunch of examples of this, although all (?) of them are implementing nodes, rather than just being a group of objects.
Something like:
[code] private GoObject MakeLegendItem(GoShape shape, Color color, String text) {
GoListGroup item = new GoListGroup();
item.Selectable = false;
item.Orientation = Orientation.Horizontal;
item.Alignment = GoObject.Middle;
item.Spacing = 3;
shape.Selectable = false;
shape.Size = new SizeF(40, 30);
shape.Brush = new SolidBrush(color);
item.Add(shape);

GoText lab = new GoText();
lab.Selectable = false;
lab.Text = text;
item.Add(lab);

return item;
}[/code]
used to create the whole legend:
[code] GoListGroup lg = new GoListGroup();
lg.Resizable = false;
lg.BorderPen = Pens.Black;
lg.Add(MakeLegendItem(new GoRectangle(), Color.LightBlue, "Rectangle"));
lg.Add(MakeLegendItem(new GoEllipse(), Color.LightGreen, "Ellipse"));
lg.Add(MakeLegendItem(new GoDiamond(), Color.Pink, "Diamond"));
doc.Add(lg);[/code]
produces:
Then you can choose whether you want to put this legend in its own layer or not. That would be most useful in keeping it either behind or in front of everything else, or to disable certain functionality, such as GoLayer.AllowDelete and GoLayer.AllowCopy. Although the latter you could do on a particular legend object by setting GoObject.Deletable or GoObject.Copyable to false.

That works beautifully.

I am glad I asked for your advice. I was implementing some code that was pretty ugly.

Thanks for the millionth time.
Roger