Nevron Forum

How to hide shape's port.

https://www.nevron.com/Forum/Topic2573.aspx

By michal bandrowski - Thursday, August 20, 2009

Hi,

I have view, document and a few shapes on it.
I'm facing problem how to suppress adding connection between some of shapes when using NConnectorTool.
I browsed through properties, methods, I've tired to set protection ...
and still, couldn't find how to hide port?

Can I somehow hide it or make it inaccessible for NConnectorTool ?



Thanks in advance,
Michal
By Pavel Vladov - Wednesday, September 2, 2009

Hello Michal,

 

You can remove the port from the Ports collection of the shape. For example:

shape.Ports.RemoveChildAt(0);

 

I hope this helps. Let me know if you have any questions or comments.

 

Kind regards,

Pavel

By michal bandrowski - Friday, September 4, 2009

Hi,

I'm looking for another solution, becouse if I would remove a port, connections will be also lost.
I'd like to keep connections how they are, and then supress for connecting some kind of shapes be using all the time the NConnectorTool.

Mayby there is some other way (not removing ports), so I don't have to develop complex workaround ?
By Ivo Milanov - Wednesday, September 9, 2009

Hi Michal,

There are several possible solutions.

Solution 1. Override the ValidateFromPort and ValidateToPort methods of the NCreateConnectorTool. If either one of this methods returns false the connector will not be displayed (I assume that you know how to replace tools - if not - please let me know and we will help).

Solution 2. Override the CanConnectPoints method of the shapes, which should discard some connections connections. Return false if a connection between an own port and a foreign connection point cannot be established.

Best regards,
Ivo