Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic List of nodes on Diagram ordered by their location ?? (Read 2092 times)
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
List of nodes on Diagram ordered by their location ??
May 20th, 2013 at 8:30am
Print Post  
Hi,

We're using various different ways to search through our nodes based on their parent or their children or the level that they sit on in the flow etc. We have a need to have a tree-like structure which would mean no 2 nodes share the same y coordinate; from this, we need to use the "level" that they sit on to automatically select an entry in a list (i.e. the user selects the node at position 7 and entry 7 of a list is selected)...

The complication here is that our users are free to place nodes whereever they like, so, if you have 10 nodes on the canvas and they drop a new one onto node 4 then it'll create a tree within the tree, thus changing the locations of every other node.

Is there a simple command that gets a list of nodes which is ordered on their y or x location on the Diagram ?? I'm sure i can do this manually but i have a feeling it'll be very fiddly so i thought i'd check to see if there's one already there first!

I hope that all makes sense Smiley

Regards,
Rich
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: List of nodes on Diagram ordered by their location ??
Reply #1 - May 20th, 2013 at 10:25am
Print Post  
Hi,

Try this:

Code
Select All
var nodesByX = new List<DiagramNode>(diagram.Nodes);
nodesByX.Sort((node1, node2) =>
	node1.Bounds.X.CompareTo(node2.Bounds.X)); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: List of nodes on Diagram ordered by their location ??
Reply #2 - May 20th, 2013 at 10:54am
Print Post  
Hi Stoyan.

Brilliant. Works a treat!

Thanks very much Smiley

Regards,
Rich
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint