The Diagram Expander Sample code has a bug.
How to reproduce:
- Start the demo
- Set LayoutDirection to "RightToLeft"
- Collapse the topmost node, this is the upper one of the two children of the root node, you should now see 8 remaining nodes
- Try to collapse the lowest node (it has two children)
Result:
The node does not react on collapse/expand mouse clicks
Cause:
The Form1.diagram1_MouseMove() method uses the controller's GetNodeAtPoint method to find the node under the mouse cursor. Since some of the nodes are hidden, the method will return node 10 (one of the collapsed ones), not node 5, the one we intended.
Solution:
The code should look like this:
var nodesAtPoint = diagram1.Controller.GetNodesAtPoint( diagram1.Controller.ConvertToModelCoordinates( e.Location ) );
foreach( var n in nodesAtPoint )
{
var no = n as ExpanderNode;
if( no != null )
{
if( no.Visible )
{
no.MouseMove( diagram1.Controller.ConvertToModelCoordinates( e.Location ) );
break;
}
}
}
This iterates over all nodes at the give point and picks the first one that is visible.
Hope this helps somebody :-)