Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ZIndex sorting. Links always behind nodes. (Read 2328 times)
areddan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Feb 17th, 2009
ZIndex sorting. Links always behind nodes.
Apr 9th, 2009 at 1:49am
Print Post  
I'm trying to implement some behaviour such that links will always be behind nodes.

As a test, I've used the following code whenever a DiagramItem is selected:

Code
Select All
  if (a_item->GetType() == MindFusion::Diagramming::DiagramNode::typeid || a_item->GetType()->IsSubclassOf(MindFusion::Diagramming::DiagramNode::typeid))
  {
    a_item->ZTop();
  }
  else
  {
    a_item->ZIndex = Diagram->Nodes->Count - 1;
  }
 



By selecting a node, this works sure enough - but then when I select a link, it appears above the node which was just brought to the top. I checked the ZIndex after selecting the node and then after selecting the link and the node is higher - The only think I can think of is that it gets set lower in code beyond my control once the link is selected.

I have SelectionAlwaysOnTop set to false.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZIndex sorting. Links always behind nodes.
Reply #1 - Apr 9th, 2009 at 7:38am
Print Post  
This worked in my test:

Code
Select All
private void button2_Click(object sender, EventArgs e)
{
	diagram.SelectionOnTop = false;

	foreach (DiagramNode node in diagram.Nodes)
		node.ZTop();
}
 



Changing the Z order might not be possible in some contexts; in response to what event does your code run?
  
Back to top
 
IP Logged
 
luffy911
YaBB Newbies
*
Offline



Posts: 8
Joined: Sep 2nd, 2010
Re: ZIndex sorting. Links always behind nodes.
Reply #2 - Sep 13th, 2010 at 9:52pm
Print Post  
Hi,
I have a similar system in my application. I am using ZBottom to make sure some ui elements are below everything else. It works but it is slow. Are there any other way to do this ?

I am currently experimenting with the removal of all nodes and adding them in the right order but the problem with this is when a node is remove from the diagram, it detaches itself... I am looking into re attaching it after the sorting.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZIndex sorting. Links always behind nodes.
Reply #3 - Sep 14th, 2010 at 5:41am
Print Post  
Hi,

You could directly reorder the elements of Diagram.Items to set the Z order quickly. However each item keeps its own index within that collection in a private field, and unfortunately there is no public method to get these indices in sync with the new Items order. We can add such method for the next release, and for now you could try some workarounds. E.g. after reordering Diagram.Items, execute an empty CompositeCmd created using the constructor that takes a 'saveZOrder' argument, and then immediately undo it. That should update the items Z indices according to the Items order. Another possibility is to call ZTop followed by ZBottom for the first item to update the Z indices for all other items.

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



Posts: 8
Joined: Sep 2nd, 2010
Re: ZIndex sorting. Links always behind nodes.
Reply #4 - Sep 14th, 2010 at 6:57pm
Print Post  
Thank you Stoyo It works great.

I did this:

// needed since diagram.Items has no sort functions

ArrayList.Adapter((IList)diagram.Items).Sort(comp);

// Force the update of all ZIndex of the items          
if( diagramItems.Count > 0)
{
     var item = diagram.Items[0];
     item.ZTop();
     item.ZBottom();
}
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint