Add link to NewLinkLayer

Hi there<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I need to control the adding of the links so

1. I use SepareteLayer for Links by add this line to constructor of myGoDocument

this.LinksLayer = this.Layers.CreateNewLayerAfter(this.Layers.Default);

2.I inheret from BpmnLinkingTool and override the DoNewLink as follow

public override void DoNewLink(IGoPort from, IGoPort to)



IMyObject SourceNode = from.Node as IMyObject ;

IMyObject DestinationNode = to.Node as IMyObject ;

IGoLink l = MainForm.App.CurrentView.CreateLink(((GoNode)SourceNode).Por t ,(GoNode) DestinationNode).Port);

if (l != null)



///getLinkingContainer return subgraph if source and destination are in the same subgraph else it return the Linking layer


IGoCollection myGroup = getLinkingContainer(SourceNode,DestinationNode);

myGroup.Add (l.GoObject);



MainForm.App.CurrentView.FinishTransaction ("Add Link");


My problems are mainly is in

1. The undo of the link never happen in this case ! the link still seen in the GoView even after undo adding the nodes

2. when link a node out the subgraph to node in the subgraph then collapse the subgraph the link seem to be floating ( seems to link to hidden node the same old position of the node before collapse. so how can i change this to temporary to link to the subgraph bounders ( my subgraph already has a port) then when when expand return the links to the nodes (I think to use PrepareCollapse and PrepareExpand but I’m not sure if it’s the best way).

  1. StartNewLink and StartRelink call StartTransaction, and Stop calls StopTransaction, so you don’t need to. You do need to set the TransactionResult property, either to null or to the name of the transaction; this property is used by StopTransaction to call either AbortTransaction or FinishTransaction.
    The reason for this convention is that there can be multiple ways in which a tool ends, so it’s cleaner/simpler to specify the result declaratively in that TransactionResult property.
  2. The external links ought to be pointing to the hidden nodes not at their old positions, but at the new positions. Are you sure that Collapse() causes all the child nodes to be positioned properly inside the collapsed subgraph?
    But yes, reconnecting links in PrepareCollapse sounds right.
    However, I suspect that doing all this work with GoSubGraph might not be the best implementation strategy for you, judging from your other post.