Port in Line


Author
Message
Volvick Derose
Volvick Derose
Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)
Group: Forum Members
Posts: 71, Visits: 1
Assume that I have a vertical or a horizontal line, I try to add couple of ports to it, but when I rotate the line or change the direction of the line, I want the ports to remain steady. Currently, the ports keep moving, I couldn't find a way to prevent them from moving.

I try something like this

NLineShape myLine = new NLineShape(0, 0, 1000, 0);

//add the ports to the line
myLine .CreateShapeElements(ShapeElementsMask.Ports);

NDynamicPort midPoint = new NDynamicPort(entityLine.UniqueId, ContentAlignment.TopCenter, DynamicPortGlueMode.GlueToContour);
myLine .Ports.AddChild(midPoint);
myLine .Ports.DefaultInwardPortUniqueId = midPoint.UniqueId;

I try both the logical line, but still gives the same problem.

I try to put a series of points on a line like this picture, but when the line is rotated or moved, I want the ports to remain on the lines without moving or changing location
Attachments
pict2.png (120 views, 13.00 KB)
Reply
Volvick Derose
Volvick Derose
Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)
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.
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