Guys,
Do you have an example of how the UserObject of a GoBasicNode can be bound to an XML attribute using the GoXmlBindingTransformer?
I have tried the following:
//Sample node in the XML
<node id=“733A02B8-CED7-4FC9-8DE5-6324A5E62572” label=“002 ASSEMBLY” parent=“7DF3DB0F-21A8-4C80-A275-5451136A18B5” type=“1” userobject=“733A02B8-CED7-4FC9-8DE5-6324A5E62572” />
//default node and binding code
GoBasicNode n = new GoBasicNode();
n.Shape = new GoRectangle();
n.LabelSpot = GoObject.Middle;
n.Text = “”;
n.Label.FontSize = 6;
n.Shape.BrushStyle = GoBrushStyle.Solid;
n.AutoResizes = true;
GoXmlBindingTransformer tr = new GoXmlBindingTransformer(“node”, n);
tr.IdAttributeUsedForSharedObjects = true;
tr.TreeLinkPrototype = l;
tr.TreeLinksToChildren = true;
tr.AddBinding(“label”, “Label.Text”);
tr.AddBinding(“parent”, “TreeParentNode”);
tr.AddBinding(“type”, “UserFlags”);
tr.AddBinding(“userobject”, “ToolTipText”);
tr.AddBinding(“userobject”, “UserObject”);
tr.AddBinding(“userobject”, “PartID”);
I attempt to retrieve the values at runtime through a click event:
private void govBOM_ObjectDoubleClicked(object sender, Northwoods.Go.GoObjectEventArgs e)
{
GoObject oBOM = e.GoObject;
GoBasicNode n = oBOM.TopLevelObject as GoBasicNode;
if (n != null)
{
MessageBox.Show(n.ToolTipText.ToString());
MessageBox.Show(n.PartID.ToString());
MessageBox.Show(n.UserObject.ToString());
}
}
Now, when I access the node at runtime, I get the GUID from n.ToolTipText, a “-1” from n.PartID and a GoBasicNode object equal n as n.UserObject.
Am I missing something elementary in setting up the document, the template node or the transformation?