Convert from GoBasicNode to MultiText

Hi there.

I am currently trying to convert a GoBasicNode Application to match the GoMultiTextNode pattern. Unfortunatly it doesn´t work the way I planned it Ouch.

The nodes are displayed as little grey boxes so I assume that also I added objects with CreateText, these objects aren´t there.

The links are also no longer displayed. Is there a standard way to convert from the BasicNode Port Method to Multitext Ports? I basically only need a port on each side and GoDiagram should use the best port option for displaying the link.

I would like to use the demo (RecordNode) multitext node class in conjunction with the datasetmapper.cs from the dataset demo.

In the datamapper I changed the Initialize Node method:

public virtual void InitializeNode(GoNode node, DataRow row) {
      node.UserObject = row;
      JobNodeAdvanced n = new JobNodeAdvanced();
      if (node != null) {
        Color statusColor = new Color();
        statusColor = Color.AntiqueWhite;

        switch (row["Status"].ToString())
        {
            case "S": statusColor = Color.Turquoise; break;
            case "E": statusColor = Color.Red; break;
            case "W": statusColor = Color.Gray; break;
        }
          
          n.CreateHeaderText(row["Title"].ToString(), statusColor);
          n.CreateText( row["line1"].ToString(), 1 );
          n.CreateText( row["line2"].ToString(), 2 );
          n.CreateText( row["line3"].ToString(), 3 );
          n.CreateText( row["line4"].ToString(), 4 );
      }
    }

as well as the InitializeLink method:

public virtual void InitializeLink(GoLink link, GoNode fromNode, GoNode toNode, DataRow row) {
      link.UserObject = row;
      if (fromNode is GoMultiTextNode)
      {
          GoMultiTextNode n = (GoMultiTextNode)fromNode;
          link.FromPort = (IGoPort) n.CreatePort(true,0);
      }
      if (toNode is GoMultiTextNode)
      {
          GoMultiTextNode n = (GoMultiTextNode)toNode;
          link.ToPort = (IGoPort) n.CreatePort(false, 0);
      }
    }

Is there an example from which I can learn on how to integrate the GoMultiTextNode? Right know it´s a little bit of a black box process for me.

Thanks.
Elmar

To construct a GoMultiTextNode, you’ll want to do something like:

[code] GoMultiTextNode n = new GoMultiTextNode();
n.AddString("first");
n.AddString("second");
n.AddString("third");
n.Position = new PointF(100, 100);
goView1.Document.Add(n);[/code]
If you want to control whether or not each item gets two ports, one on the left and one on the right, you can explicitly create the item and the port(s) and call AddItem instead.
[code] GoText t = n.CreateText("fourth", -1); // by default the second arg is ignored
GoPort p = n.CreatePort(false, -1); // create a port for the right side
n.AddItem(t, null, p); // add a GoText item with no left port[/code]
So I think your confusion is due to our not making clear enough that the GoMultiTextNode.CreateText method constructs a GoText but does not Add it to the node. The same is true for the CreatePort method.
Now, you should be using GoMultiTextNode only if you want to (possibly) associate one or two ports for each item you have in the node. If you just want a single port for the whole node, I suggest you just build a GoListGroup and make that the Body of a GoBoxNode. GoMultiTextNode uses a GoListGroup too, but it is designed to have ports (or other objects) for each item, one on each left/right side.

You are perfectly right. I am looking for GoBoxNode and a GoListGroup now Embarrassed. Thanks for clarifying this.

I will through the examples to find an actual implementation.

Thanks!
Elmar