Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to get node ID (Read 2817 times)
RunMan
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Sep 24th, 2015
How to get node ID
Nov 11th, 2015 at 9:54am
Print Post  
Hi,

we have created a diagram by using custom nodes (derived from ShapeNode). The diagram is saved to xml and i can see in the xml file under "Nodes" the single "Node" with attribute "Id".
But when i want to read out this id within the code it is null. Maybe it is not the same?
How can i get the unique ID of a diagram node?

Thanks
RunMan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get node ID
Reply #1 - Nov 11th, 2015 at 10:11am
Print Post  
Hi,

The id attribute in XML files is generated only when saving files and used for deserialization purposes, to identify related items such as link's origin and destination nodes. If you need unique identifiers in runtime, you could assign them to the Id or Tag properties of items. E.g. you could keep an integer counter and assign its value to each new item added to the diagram if values should be unique for the diagram only, or Guid.NewGuid result if values should be unique across all your diagrams.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
RunMan
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Sep 24th, 2015
Re: How to get node ID
Reply #2 - Nov 11th, 2015 at 10:47am
Print Post  
Hi Stoyan,

yes, that helps me.
We want to iterate through a logic diagram and therefore we have to know the connected nodes of a node. First we try to do this by above mentioned ID without success Smiley. I think it will be possible in the xml data via the links.
Now we try it in code by iterating through the incoming and outgoing links and their origins. Hope this will working.

Thank you
RunMan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get node ID
Reply #3 - Nov 11th, 2015 at 11:57am
Print Post  
Hi,

Right, you can access neighbor nodes via IncomingLinks and OutgoingLinks collections, for example using LINQ extensions:

Code
Select All
var neighbors =
	node.IncomingLinks.Select(l => l.Origin).Concat(
	node.OutgoingLinks.Select(l => l.Destination));

foreach (var n in neighbors)
	n.Brush = Brushes.Red; 



I hope that helps,
Stoyan
« Last Edit: Nov 11th, 2015 at 1:33pm by Stoyo »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint