Problem of adding a NPointPort to a NCustomShape


Author
Message
Wilhelm Vortisch
Wilhelm Vortisch
Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)
Group: Forum Members
Posts: 14, Visits: 1
Hi folks,

I have a problem in adding a NPointPort to a NCustomShape. The NCustomShape is in a library browser.
Always if I drop (a copy of) the master in the drawing document, the port is on position 0,0 of the drawing document and not in the shape bounds.
In the following code I create the custom shape with one port (to the fourth point):

private NCompositeShape createComplexCompositeShape()
{
NCompositeShape shape = new NCompositeShape()

NPolygonPath newElement = new NPolygonPath(new NPointF[]
{
new NPointF(0, 10),
new NPointF(0, 90),
new NPointF(50, 90),
new NPointF(50, 100),
new NPointF(50,90),
new NPointF(100, 90),
new NPointF(100, 10),
new NPointF(50, 10),
new NPointF(50, 0),
new NPointF(50,10),
});
shape.Primitives.AddChild(newElement);
shape.UpdateModelBounds();

shape.Style.FillStyle = new NColorFillStyle(Color.AliceBlue);
shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0, 0x88));

// create the shape ports
shape.CreateShapeElements(ShapeElementsMask.Ports);

NPointPort port1 = new NPointPort(shape.UniqueId, PointIndexMode.Custom, 4);
shape.Ports.AddChild(port1);

return shape;
}


Any tips?

Kind Regards

Wilhelm
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Wilhelm,

The problem with the port positioning is the anchor model that you pass to the NPointPoint constructor. A composite shape does not implement the INPoints interface and that is why the point port cannot position itself correctly - it will always return (0,0) as its scene coordinates. To fix the problem just replace:

NPointPort port1 = new NPointPort(shape.UniqueId, PointIndexMode.Custom, 4);

with

NPointPort port1 = new NPointPort(newElement.UniqueId, PointIndexMode.Custom, 4);

Best Regards,
Nevron Support Team


Wilhelm Vortisch
Wilhelm Vortisch
Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)
Group: Forum Members
Posts: 14, Visits: 1
Hi Nevron support,

thank you for the good tip. It works now.

Regards

Wilhelm
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search