Profile Picture

Problem of adding a NPointPort to a NCustomShape

Posted By Wilhelm Vortisch 14 Years Ago
Author
Message
Wilhelm Vortisch
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 13 Years Ago
Posts: 14, Visits: 1
Hi Nevron support,

thank you for the good tip. It works now.

Regards

Wilhelm

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
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
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 13 Years Ago
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



Similar Topics


Reading This Topic