Nevron Forum

Regarding Ports on a shape

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

By Pramod Sreekanthan - Wednesday, December 29, 2010

Hi,
I have an issue. When i try to increase the width of a shape on the diagram. the ports location also change.
I want the ports to remain static and not move with the shape width.

Thanks,

Pramod

By Nevron Support - Tuesday, January 4, 2011

Hi Pramod,

Different port types use different strategies to determine their location in document scene coordinates.

The NRotatedBoundsPort for example computes its location by first generating a point defined in percents of the anchor model - model bounds and transforming this point to scene coordinates using the anchor model SceneTransform. The following code snippet is the implementation of the NRotatedBoundsPort GetLocation method override:

///
/// Overiden to obtain an aligned point relative to the anchor model rotated bounds
/// and apply the current offset to it.
///

///
protected override NPointF GetLocation()
{
if (Shape != null && Shape.IsCollapsed())
return Shape.GetRootCollapsedShape().GetCollapsedPortLocation(this);

NModel model = GetAnchorModel(AnchorUniqueId);
if (model == null)
return NPointF.Empty;

NPointF point = Alignment.GetAlignPoint(model.ModelBounds);
point = model.SceneTransform.TransformPoint(point);

point.X += Offset.Width;
point.Y += Offset.Height;

return point;
}

So naturally when the anchor model model bounds have changed, the location of the port also changes, because it is defined relatively to the anchor model bounds.
In general any custom port location can be achieved by creating a custom port. What is the behavior that you want to achieve?


By Pramod Sreekanthan - Friday, January 7, 2011

Hi,

Actually iam increasing the width of a shape having ports.

When the width increases, the ports are not fixed and move along with the shape's width

I want the location of the ports to be same and according to the diagram co-ordiantes.

They should not change according to the diagram co-ordinates.

 

Thanks

Pramod