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.
Unfortunately, activation email could not send to your email. Please try again.

Yes/No Link

Thread ID:

Created:

Updated:

Platform:

Replies:

20040 Oct 8,2004 05:49 AM Aug 19,2008 05:06 AM Windows Forms 5
loading
Tags: Diagram
Administrator [Syncfusion]
Asked On October 8, 2004 05:49 AM

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!

Administrator [Syncfusion]
Replied On October 8, 2004 01:31 PM

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

Administrator [Syncfusion]
Replied On October 10, 2004 11:12 AM

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 >

Administrator [Syncfusion]
Replied On October 11, 2004 01:48 PM

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

Pony
Replied On August 18, 2008 07:27 AM

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.Nagarajan [Syncfusion]
Replied On August 19, 2008 05:06 AM

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



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;