Bring focus to Node inside a Diagram inside a DashboardLayoutPanel

Hi,
Lets say I have a large hierarchical diagram. Now I would like to have a dropdown associated with that diagram so that when I am looking for someone specifically I could bring the focus  to that person node inside that diagram.


So far I have tried the following method (it is called via the dropdown):

public async Task FocusNode(ChangeEventArgs<string, EmployeeData> args)

    {

        if (args != null && args.Value != null)

        {

            var rect = diagramProjectOther.Nodes.Where(x => x.Data.ToString().Contains(args.Value)).FirstOrDefault();


            if (rect != null)

            {

                System.Drawing.Rectangle Bounds = new System.Drawing.Rectangle()

                {

                    X = (int)(rect.OffsetX - (rect.Width / 2)),

                    Y = (int)(rect.OffsetX - (rect.Height / 2)),

                    Height = (int)rect.Height,

                    Width = (int)rect.Width

                };


                await diagramProjectOther.BringIntoView(Bounds);

            }

        }

    }

 I would have thought that it would work, but all it does is that it centers the diagram, not on the node.

It might be because the diagram itself is contained within a DashboardLayoutPanel ?

Regards,

--Nicolas


3 Replies 1 reply marked as answer

SS Sivakumar Sekar Syncfusion Team December 1, 2021 12:06 PM UTC

Hi Nicolas,


We have added the sample link and a video link to demonstrate how to bring the node to the center of the diagram. To bring the node to the center of the diagram, we suggest you use a diagram.BringToCenter method instead of the diagram.BringToView method. In the diagram.BringToCenter method pass the node bounds. Please refer to the below code snippet and sample.


diagram.BringToCenter(new Area()
{
x = diagram.Nodes[1].OffsetX - (diagram.Nodes[1].Width/2),
y = diagram.Nodes[1].OffsetY - (diagram.Nodes[1].Height/2),
width = diagram.Nodes[1].Width,
height = diagram.Nodes[1].Height
});


Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BringTocenter95676390

Video link:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/170832-426382559

Regards,
Sivakumar



Marked as answer

NN Nicolas Navier December 1, 2021 03:49 PM UTC

Thanks that works well.

Regards,


--Nicolas




SS Sivakumar Sekar Syncfusion Team December 2, 2021 08:06 AM UTC

Hi Nicolas, 

Thanks for your update. 

Regards,  
Sivakumar    



Loader.
Up arrow icon