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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Make relations between symbols

Thread ID:

Created:

Updated:

Platform:

Replies:

116017 Mar 18,2014 03:25 AM UTC Mar 20,2014 05:38 AM UTC WinForms 1
loading
Tags: Diagram
Malik Said
Asked On March 18, 2014 03:25 AM UTC

Good day

I want to create a program where the user can build the diagram by dragging the shapes from paletteview. To this level, I used the symbol designer. And the user can build the diagram.

However, I want to do calculations based on the diagram which was built by the user. Therefore, I want to know how to do the following:

1.       When the user drag the same symbol from the palette to the diagram more than one time, how can I define those symbols differently?

2.       How can I get which symbol is connected to whom? And how to identify which link is entering or leaving the symbol?

3.        From question number 2, I want to make relations between symbols. Who can I do this? For example, I want a certain property (in propertybag) to be equal. Or for a certain property, the sum of property of entering links equal to the sum of property of the leaving links. How to do this?

I’m using Visual studio Ultimate 2012. Please I need the code in VB to implement it easily.

 

Thanks and Regards

Malik


Amsath Ali M [Syncfusion]
Replied On March 20, 2014 05:38 AM UTC

Hi Malik,

 

Thanks for your interest in Syncfusion products.

 

1.       When the user drag the same symbol from the palette to the diagram more than one time, how can I define those symbols differently?

We suggest you to use the Diagram’s ‘DragDrop/Model.Eventsink.NodeCollectionChanged’ changed events to check whether the dropped node is present already on the diagram.

 

Here is the code:

[VB]

Private Sub diagram1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)

                     Dim dataObj As IDataObject = e.Data

                     If dataObj.GetDataPresent(GetType(DragDropData)) Then

                           Dim dragDropData As DragDropData = CType(dataObj.GetData(GetType(DragDropData)), DragDropData)

                           Dim node As Node = dragDropData.Nodes(0)

                           If Not(addedNodes.Contains(node.Name)) Then

                                  addedNodes.Add(node.Name, node)

                           Else

                                  MessageBox.Show("Node already present in diagram")

                                  dragDropData.Nodes.Clear()

                           End If

                     End If

              End Sub

2.       How can I get which symbol is connected to whom? And how to identify which link is entering or leaving the symbol?

 

3.        From question number 2, I want to make relations between symbols. Who can I do this? For example, I want a certain property (in propertybag) to be equal. Or for a certain property, the sum of property of entering links equal to the sum of property of the leaving links. How to do this?

We suggest you to use the Node’s ‘Edges, EdgesEntering and EdgesLeaving’ properties to get the connections connected to a node and use the connector’s ‘FromNode and ToNode’ properties to get the nodes connected to that connector.

 

Here is the code:

[VB]

 

If diagram1.View.SelectionList.Count > 0 Then

                           For Each node As Node In diagram1.View.SelectionList

                                  If TypeOf node Is ConnectorBase Then

                                         Dim conn As ConnectorBase = TryCast(node, ConnectorBase)

                                         listBox1.Items.Add("Connector: " & conn.Name)

                                         If conn.FromNode IsNot Nothing Then

                                                listBox1.Items.Add("ParentNode: " & (CType(conn.FromNode, Node)).Name)

                                         End If

                                         If conn.ToNode IsNot Nothing Then

                                                listBox1.Items.Add("ChildNode: " & (CType(conn.ToNode, Node)).Name)

                                         End If

                                  Else

                                         listBox1.Items.Add("Edges: " & node.Edges.Count.ToString())

                                         listBox1.Items.Add("EdgesEntering: " & node.EdgesEntering.Count.ToString())

                                         listBox1.Items.Add("EdgesLeaving: " & node.EdgesLeaving.Count.ToString())

                                  End If

                           Next node

                     End If

 

Please try the attached sample and let us know if you have any queries.

 

Regards,

Amsath Ali. M


Attachment: 116017_353280c7.zip

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon

;