Ok Volvick,
The easiest way to maintain the position of the port is to set the point you want it on to its Tag property and then constantly set it to its Location property each time a NodeBoundsChanged event occurs.
Here’s an example:
1. Create the port:
NPointPort port = new NPointPort();
line.Ports.AddChild(port);
port.Location = new NPointF(100, 100);
port.Tag = new NPointF(100, 100);
2. Subscribe to the NodeBoundsChanged event of the document’s event sink service:
document.EventSinkService.NodeBoundsChanged += new NodeEventHandler(EventSinkService_NodeBoundsChanged);
3. Use the following code in the event handler:
private void EventSinkService_NodeBoundsChanged(NNodeEventArgs args)
{
NShape shape = args.Node as NShape;
if(shape == null)
return;
foreach (NPort port in shape.Ports)
{
if (port.Tag != null && port.Tag is NPointF)
{
port.Location = (NPointF)port.Tag;
}
}
}
Best Regards,
Nevron Support Team