Modifying model programmatically

I’m trying to modify my Diagram model from code behind.

What I’m trying to do is to remove the link between the LabelNode 22 and the other LabelNode on the cold stream. So the Diagram should be simular to the picture below

So, if we only focused on the hot stream, here is what I’m doing:

  • Remove 22
  • Remove 2
  • Remove 3
  • Remove link from 1 to 2
  • Remove link from 3 to 4
  • Create a new LabelNode

And here is the code for updating the model after removing items:

        streamLink = New GoXam.StreamLink(stream)
        streamLink.LabelNode = exchangerConnector.GUID
        _GridDiagramModel.SetLinkFromPort(streamLink, stream.FromConnector, "")
        _GridDiagramModel.SetLinkToPort(streamLink, stream.ToConnector, "")
        _GridDiagramModel.AddOrUpdateNode(New GoXam.ExchangerNode(exchangerConnector))
        _GridDiagramModel.SetLinkLabelKey(streamLink, exchangerConnector.GUID)

And here is what I obtained for the Hot Stream

I tried to see what was the result of these methods (FindLabelNodeKeyFor, FindFromNodeKeyForLink, FindToNodeKeyForLink) and everything seems to be OK…

Any idea???

It seems to me that for the hot stream you should just remove nodes 2 and 3 and then add a link from 1 to 4 and add a LabelNode to that new link. And then do the same for the cold stream.

Yeah, well I found my mistake. It was a stupid mistake from myself. Thanks you Walter