Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Double-click on the diagram to interoperate with ruler (Read 1466 times)
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Double-click on the diagram to interoperate with ruler
Mar 31st, 2020 at 5:48am
Print Post  
Hey, Lyubo. Smiley

        private void diagram_NodeDoubleClicked(object sender, NodeEventArgs e)
        {
            var node = e.Node;
            if (node.MasterGroup != null)
                node = node.MasterGroup.MainItem as DiagramNode;

            var posX = e.MousePosition.X - node.GetCenter().X;
            var posY = e.MousePosition.Y - node.GetCenter().Y;

            var newPos = new Point(
                diagram.Viewport.X + diagram.Viewport.Width / 2 - node.Bounds.Width / 2 - posX,
                diagram.Viewport.Y + diagram.Viewport.Height / 2 - node.Bounds.Height / 2 - posY);

            node.SetBounds(new Rect(newPos, node.Bounds.Size), true, true);
        }

This method currently implements that when you double-click on any point in node.MasterGroup.MainItem, the point moves to the center of the view, but the ruler does not follow. I want the ruler to follow. What changes should be made in this method?
  

3_31_2.png (Attachment deleted)
3_31_3.png (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Double-click on the diagram to interoperate with ruler
Reply #1 - Mar 31st, 2020 at 6:43am
Print Post  
Hi,

In order for the node to remain fixed to the 0,0 position, instead of moving it, you need to scroll the view instead:
Code
Select All
            diagram.NodeDoubleClicked += (sender, args) =>
            {
                var node = args.Node;

                if (node.MasterGroup != null)
                    node = node.MasterGroup.MainItem as DiagramNode;

                var posX = args.MousePosition.X - (diagram.Viewport.X + diagram.Viewport.Width / 2);
                var posY = args.MousePosition.Y - (diagram.Viewport.Y + diagram.Viewport.Height / 2);

                diagram.ScrollX += posX;
                diagram.ScrollY += posY;
            }; 



Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Double-click on the diagram to interoperate with ruler
Reply #2 - Mar 31st, 2020 at 6:54am
Print Post  
I fully understand, thank you very much for your guidance, Lyubo Wink
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint