|
Group: Forum Members
Posts: 71,
Visits: 1
|
I don't have a simple project to send you. I am working in a big project, it will take time for me to create a simple one, but here is an example code.
NLineShape lineShape = new NLineShape(0, 0, 400, 0);
lineShape.CreateShapeElements(ShapeElementsMask.Ports);
//add only one port
NPointPort port = new NPointPort(); lineShape.Ports.AddChild(port); port.Location = new NPointF(0, 0); port.Tag = new NPointF(0, 0);
lineShape.Name = "myLine";
//now add it to the library NMaster myMaster = new NMaster(lineShape, NGraphicsUnit.Pixel, "line", "line"); nLibraryDocument1.AddChild(myMaster);
Then in the event sink I have
private void EventSinkService_NodeBoundsChanged(NNodeEventArgs args) { NShape myLine = args.Node as NShape;
if (myLine== null) { return; } else if (myLine.Name == "myLine") { foreach (NPort port in myLine.Ports) { if (port.Tag != null && port.Tag is NPointF) { port.Location = (NPointF)port.Tag; } } } }
All you need to do now, just drop the line from the library to the drawing are, you will see that point is not on the line. The only way to put it on the line, you have to drag it at location 0, 0.
|