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

Yes/No Link

I want to create a decision tree with customized condition symbols (such as expression "A>10"). I want to create a link with "Yes" or "No" label which will link two symbol together. How I can create a link with label and arrow end? Do you have any sample to refer to? TIA!

5 Replies

AD Administrator Syncfusion Team October 8, 2004 05:31 PM UTC

Hi You can add an arrow at the end of a link by setting the link.EndPoints.LastEndPointDecorator and a label can be added to a Link using AddLabel. You need to pass in the Text for the label along with value for pctalongline. The value of this property is a percentage that can range from 0 to 100. The position of the label is calculated as this percentage value along the line contained by the link. Here is a code snippet: //Custom arrow link protected Link CreateLink(PointF[] pts) { Link link = new Link(Link.Shapes.Line, pts); link.EndPoints.LastEndPointDecorator = new EndPointDecorator(EndPointVisuals.ClosedArrow); link.AddLabel("Yes",90); return link; } //Create and Register the Link Tool for the custom link Tool linkTool = this.diagram1.Controller.GetTool("LinkTool"); ((LinkTool)linkTool).LinkFactory = new LinkFactory(this.CreateLink); this.diagram1.Controller.RegisterTool(linkTool); //Activate the Link Tool this.diagram1.ActivateTool("LinkTool"); Regards, Arun


AD Administrator Syncfusion Team October 10, 2004 03:12 PM UTC

Thank you very much. It works. Now I have the decision tree. I want to click any node in the tree, color all its parent nodes and links up to the root, and all its chidren node and links. this need to loop through all its parent nodes and children nodes and their links. Do you have any sample code for this task? TIA! >Hi > >You can add an arrow at the end of a link by setting the link.EndPoints.LastEndPointDecorator and a label can be added to a Link using AddLabel. You need to pass in the Text for the label along with value for pctalongline. The value of this property is a percentage that can range from 0 to 100. The position of the label is calculated as this percentage value along the line contained by the link. > >Here is a code snippet: > >//Custom arrow link >protected Link CreateLink(PointF[] pts) >{ > Link link = new Link(Link.Shapes.Line, pts); > link.EndPoints.LastEndPointDecorator = new EndPointDecorator(EndPointVisuals.ClosedArrow); > link.AddLabel("Yes",90); > return link; > >} > >//Create and Register the Link Tool for the custom link >Tool linkTool = this.diagram1.Controller.GetTool("LinkTool"); >((LinkTool)linkTool).LinkFactory = new LinkFactory(this.CreateLink); >this.diagram1.Controller.RegisterTool(linkTool); > >//Activate the Link Tool >this.diagram1.ActivateTool("LinkTool"); > >Regards, >Arun >


AD Administrator Syncfusion Team October 11, 2004 05:48 PM UTC

Hi In Essential Diagram the concept of hierachy is within composite nodes like Models, Symbols and Groups. Essential Diagram does not offer any pre-packaged iterators that allows traversal of nodes as it makes no attempt to maintain a hierarchical architecture. Since this is specific to your application, you will have to to implement this within your application. In your application you can build a separate tree that reflects your Diagram''s layout as and when changes are made to it to do what you are looking for. Regards Arun


PO Pony August 18, 2008 11:27 AM UTC

Hi

I can't found LinkFactory function in 6.303.0.30.
Could you tell me how to implement it?

>Hi
>
>You can add an arrow at the end of a link by setting the link.EndPoints.LastEndPointDecorator and a label can be added to a Link using AddLabel. You need to pass in the Text for the label along with value for pctalongline. The value of this property is a percentage that can range from 0 to 100. The position of the label is calculated as this percentage value along the line contained by the link.
>
>Here is a code snippet:
>
>//Custom arrow link
>protected Link CreateLink(PointF[] pts)
>{
> Link link = new Link(Link.Shapes.Line, pts);
> link.EndPoints.LastEndPointDecorator = new EndPointDecorator(EndPointVisuals.ClosedArrow);
> link.AddLabel("Yes",90);
> return link;
>
>}
>
>//Create and Register the Link Tool for the custom link
>Tool linkTool = this.diagram1.Controller.GetTool("LinkTool");
>((LinkTool)linkTool).LinkFactory = new LinkFactory(this.CreateLink);
>this.diagram1.Controller.RegisterTool(linkTool);
>
>//Activate the Link Tool
>this.diagram1.ActivateTool("LinkTool");
>
>Regards,
>Arun
>



J. J.Nagarajan Syncfusion Team August 19, 2008 09:06 AM UTC

Hi Daniel ,

LinkFactory class is no longer valid in v6.3.0.30. You can add the label to the connector when you draw the link. You have to handle NodeCollectionChanging event of the DocumentEventSink. Please refer to the below code snippet.

this.diagram1.Model.EventSink.NodeCollectionChanging += new CollectionExEventHandler(EventSink_NodeCollectionChanging);
void EventSink_NodeCollectionChanging(CollectionExEventArgs evtArgs)
{
if (evtArgs.ChangeType == CollectionExChangeType.Insert && evtArgs.Element is OrthogonalConnector)
{
OrthogonalConnector m_connector = evtArgs.Element as OrthogonalConnector;
Label m_lbl = new Label();
m_lbl.Text = "Yes";
m_lbl.FontStyle.Family = "Cambria";
m_lbl.FontStyle.Bold = true;
m_lbl.FontStyle.Italic = true;
m_lbl.FontStyle.Size = 12;
m_lbl.Position = Position.Center;
m_connector.Labels.Add(m_lbl);
}
}

//To activate the OrthogonalLinkTool
this.diagram1.Controller.ActivateTool("OrthogonalLinkTool");

Here is the working sample.

http://websamples.syncfusion.com/samples/Diagram.Windows/F20040/main.htm

In this sample you can activate the OrthogonalLinkTool by using Tools->OrthogonalLinkTool menu item.

Please let me know if this helps.

Thanks,
Nagaraj



Loader.
Up arrow icon