We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Linking

Hi,

Could you help me determine how to link two ports dynamically such that all the user has to do is
a) click port a
b) click port b
c) link appears

I don't want to have to select a link tool prior to this, as per your included examaples. I'll be adding checking into this to ensure that the two ports are "compatible" so any hints on a efficient way to do this would be very much appreciated!

Thanks for your help
Rob

5 Replies

AN Anonymous November 17, 2006 08:39 PM UTC

ps...

It'd also be nice to have the blinking line indicating a link is taking place with the above example...

kind regards
Rob


AN Anonymous November 17, 2006 08:40 PM UTC

ps...

It'd also be nice to have the blinking line indicating a link is taking place with the above example...

kind regards
Rob


J. J.Nagarajan Syncfusion Team November 20, 2006 10:08 PM UTC

Hi Rob,

If your intention is to add a link dynamically then you can use LinkCmd class. Please refer to the following code snippet

LinkCmd linkcmd = new LinkCmd();
Link link = new Link(Link.Shapes.OrthogonalLine);
link.EndPoints.LastEndPointDecorator = new EndPointDecorator(EndPointVisuals.ClosedArrow);
link.EndPoints.LastEndPointDecorator.FillStyle.Color = Color.Black;
linkcmd.SourcePort = rectangle.CenterPort;
linkcmd.TargetPort = roundrect.CenterPort;
linkcmd.Link = link;
this.diagram1.Controller.ExecuteCommand(linkcmd);

Please refer to the attached sample. In this sample when you click on the "Add Symbols" button you can get 2 symbols on the diagram and click on the "AddLink" button to create a link between these two symbols.

We are currently working on to create the link as a blinking line. We will update you at the earliest.

Regards,
Nagaraj

Dynamic Link.zip



AD Administrator Syncfusion Team December 12, 2006 08:01 PM UTC

I saw your post and thought I'd share with you how we did this in our application. We have a large app with derived model, diagram and controller classes. We also have custom symbols and links. We used the following override in our controller class to do a "hit test" for a port to activate the link tool. It makes the step of activating the link tool look seamless to the user.

protected override void OnMouseDown(object sender, MouseEventArgs evtArgs)
{
if (evtArgs.Button == MouseButtons.Left)
{
// Check to see if there is a port at this location
Port port = this.View.GetPortAt(new Point evtArgs.X, evtArgs.Y), 0);

// Activate the link tool if there is a port and it is valid
if (port != null)
{
if (port.GetType() == typeof(CirclePort))
{
this.ActivateTool("LinkTool");
}
}
}

base.OnMouseDown(sender, evtArgs);
}

(We're still using 4.1, with no plans to upgrade in the near future.)

Chris C.


>Hi,

Could you help me determine how to link two ports dynamically such that all the user has to do is
a) click port a
b) click port b
c) link appears

I don't want to have to select a link tool prior to this, as per your included examaples. I'll be adding checking into this to ensure that the two ports are "compatible" so any hints on a efficient way to do this would be very much appreciated!

Thanks for your help
Rob


J. J.Nagarajan Syncfusion Team December 12, 2006 11:36 PM UTC

Hi Chris ,

We regret for the inconvenience caused. I have tested this issue in v.4.1.0.52 . I am afraid, I was not able to reproduce this issue. I have attached my test sample.

CustomOrthogonalLink_Sample.zip

Could you please check the sample and let me know whether you are able to reproduce the issue in this sample?. It would be helpful if you provide a sample or modify the sample attached to reproduce this issue.It will help us to resolve it as early as possible.

Thanks for using Essential Diagram.

Regards,
J.Nagaraj

Loader.
Live Chat Icon For mobile
Up arrow icon