Table Entity Object


#1

Walter et. al.
I’ve futzed around with GoDiagram for a few months now and I’m looking for advice on making something similar to the RecordNode object in the Demo1 app.
I need to add some image affordances to some of the text nodes in a MultiTextNode object. I need to indicate things like primary/foreign keys and indexes. Is there a reasonable way to create a composite version of a TextNode where there is an image property for each item?
Thanks
-DO


#2

I think the best way to go is to have each item in the RecordNode be a group consisting of a GoImage and a GoText, instead of each item just being a GoText. This means you won’t be able to use the “String” methods of GoMultiTextNode, but only the “Item” methods. (AddString, for example, just calls AddItem anyway.)
I have extended the RecordNode (Demo1) sample in the next version of GoDiagram by adding a RecordItem class that implements this group. I haven’t tried this with the current version (2.1), but I don’t have any reason to believe it requires any new 2.2 features, so you can download the new RecordNode.cs file from:
[EDIT: zip file no longer available; source code is included with regular kit]
An example use of RecordNode and RecordItem, constructing a RecordNode whose first item is just a string and whose second item shows a GIF along with a string:
RecordNode recn = new RecordNode();
recn.Position = new PointF(170, 540);
recn.AddString(“first”);
RecordItem reci = new RecordItem();
reci.Init(“star.gif”, “second”);
recn.AddItem(reci, null, recn.CreatePort(false, recn.Count));
doc.Add(recn);
You may find you have different needs regarding the ports, of course.


#3

Thanks Walter!
That’s perfect. It was the way I was heading after re-reading the documentation. Since simple text is all I need for the nodes, this makes sense.
Too bad you don’t have a GoTextwithImageNode class!
-DO


#4

Well, if you were looking for a “node”, i.e. a group that has a port as well as other stuff, then you could use GoIconicNode.
The disadvantage of having all these basic objects is that there are lots of ways of putting them together.
The advantage of having all these basic objects is that there are lots of ways of putting them together.
GoDiagram tries to have it both ways, where you can just use the standard node classes and set some properties on them, or where you can construct whatever you want by inheriting from GoGroup or from GoNode or from one of the standard node classes.