Persisting Connector Link to a single Port

Aug 16, 2010 at 9:24 AM

I want to start by saying that you have done a marvelous job with this project.

 

The problem I'm facing currently is when I connect one end of a Connector to a specific Port in a Shape, then if I move it enough around that other side of the shape, the Connector no longer connects to the same Port. Is there a way to persist a Connector's link to a single Port so that no matter where I move the connector it continues the link to the same Port? 

Thanks a lot. 

Abdul

Developer
Dec 20, 2011 at 1:02 PM

Abdul I hope this is timely,

If am to rephrase your question you would like to create like a unary relationship i.e Create a line from one shape to the same shape--If so

Create two ports and add them to the Ports collection of that shape


Port pt1 = new Port(PortOrientation.Left);
Port pt2 = new Port(PortOrientation.Bottom);

Shape TestShape= new Shape();
TestShape.Ports.Add(pt1);
TestShape.Ports.Add(pt2);

Connector Con= new Connector(pt1,pt2);

That way you will have a line running from one shape to the same shape.

 

If you want to have a line run from one shape to another ..I would suggest you use a The connector's constructor that takes two shapes

i.e

            Shape shape = new Shape();
            shape.Location = new PointF(320, 320);
            shape.BorderColor = Color.Green;
            model.Shapes.Add(shape);

            Shape shape2 = new Shape();
            shape2.Location = new PointF(20, 20);
            shape2.BorderColor = Color.Blue;
            model.Shapes.Add(shape2);

            Link link = new Link(shape,shape2);
            model.Lines.Add(link);

This link should  always move with respect to the moving shape.

Hope that helps