I have changed node color using following code, But node.PartId cant return node Id. Every time return -1.
GoObject obj;
obj = MyView.Selection.Primary;
GraphNode lnode = obj as GraphNode;
if (lnode != null)
{
if (lnode.Label.Multiline)
lnode.Shape.BrushForeColor = Color.Red;
var id = lnode.PartID;
var nodeId = id;
}
From the User Guide section “Supporting Save and Load”
To simplify the generation of unique IDs for nodes and ports and links, GoDocument has a property that automatically makes sure that each node, port, or link that is added to the document has a unique PartID. Just set the GoDocument.MaintainsPartID to true. All objects that implement the IGoIdentifiablePart interface provide a PartID property; this is set by GoDocument as objects are added to the document.
When you need to refer to objects, such as to the ports of a link that you are storing, you can just pass the PartID. Upon loading, you can find the IGoIdentifiablePart in the document with
that ID by calling GoDocument.FindPart. Remember to save the LastPartID in your document too, to avoid any possible duplicate PartIDs.