Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1300
How to check if a NetworkNodeNode is in view and if not how to scroll it into view?
posted

Hi,

How do we check if a NetworkNodeNode in a XamNetworknode is in view?

How to scroll the node into view if it is not in the the current viewing area?

Any suggestions please.

Thanks,

Prasad

Parents
  • 17475
    Offline posted

    Hello Prasad,

    You can get a node coordinates using it’s Location property. Then add it in the selected nodes collection and compare the coordinates with the visible world rectangle area. If the node meets your criteria, ZoomSelectedNodes method should be called to bring the node into view. Here is a code snippet you can use as basis:
    xnn.SelectedNodes.Clear();   
                NetworkNodeNode node1 = xnn.Search((NodeModel item) => item.Label.StartsWith((listBox1.SelectedItem as NodeModel).Label)).FirstOrDefault();
                xnn.SelectedNodes.Add(node1);
                if ((node1.Location.X > xnn.WorldRect.Left) && (node1.Location.X < xnn.WindowRect.Right) && (node1.Location.Y > xnn.WindowRect.Top) && (node1.Location.Y < xnn.WorldRect.Bottom))
                {
                    MessageBox.Show("Node is in view");
                }
                else
                {
                    xnn.ZoomSelectedNodes();
                }
    I hope this will be helpful for you.

Reply Children