Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Improved the zoom setting of Diagram (Read 3712 times)
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Improved the zoom setting of Diagram
Apr 9th, 2020 at 5:04pm
Print Post  
Hi ALL,

I have currently created a ShapeNode in the diagram. In the Diagram.MouseWheel event, the zoom setting has been set, and the minimum value of the zooming-out has been set to the size of the ShapeNode. When zooming-out reaches the minimum, it will cause ShapeNode to cover the Diagram.

When zooming-out reaches the minimum, I want to prevent ShapeNode from covering the Diagram. Where does the code need to be changed?

           var zoomRect = diagram.Viewport;
           var zoomStep = 10;
           if (e.Delta < 0)
            {
                zoomRect = new Rect
                (
                    Math.Max(ShapeBounds.X, zoomRect.X - zoomStep / 2),
                    Math.Max(ShapeBounds.Y, zoomRect.Y - zoomStep / 2),
                    Math.Min(ShapeBounds.Width, zoomRect.Width + zoomStep),
                    Math.Min(ShapeBounds.Height, zoomRect.Height + zoomStep)
                );
            }

Any assistance would be appreciated.

Cheers,

Jack
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Improved the zoom setting of Diagram
Reply #1 - Apr 10th, 2020 at 5:43am
Print Post  
Hello,

From the code you posted, the limit of the zoom out operation is set on the ShapeBounds instance bounds, so it will "cover" the viewport - that is the maximum extent of the zoom out operation. If you need to zoom out further, you need to use a larger bounding rectangle instead of ShapeBounds - for example, ShapeBounds.Inflate(20, 20); will enlarge the rectangle.

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


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Improved the zoom setting of Diagram
Reply #2 - Apr 10th, 2020 at 8:47am
Print Post  
Yes, you are right. But I thought of another better. Is it possible to limit the maximum multiple of zoom-out operation under the condition of if (e.Delta <0), and the maximum multiple of zoom-in operation under the condition of if (e.Delta> 0). Is there sample code for my reference?
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Improved the zoom setting of Diagram
Reply #3 - Apr 10th, 2020 at 9:01am
Print Post  
Hello,

Try the code from here: https://mindfusion.eu/Forum/YaBB.pl?num=1586448877/3#3

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


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Improved the zoom setting of Diagram
Reply #4 - Apr 10th, 2020 at 9:37am
Print Post  
Yes, the code you gave me is zooming in and out at the center of the view, which is really nice.
For now I want to do this: I just told you to disable the ShapeNode from overwriting the view without changing the size of the original ShapdeNode.So I tried a new value for zoomOutMax: imageNode. Inflate (20, 20). Bounds. The results suggest imageNode does not contain the Inflate method.
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Improved the zoom setting of Diagram
Reply #5 - Apr 10th, 2020 at 10:13am
Print Post  
Inflate is a method on the Rect class, not ShapeNode.

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


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Improved the zoom setting of Diagram
Reply #6 - Apr 10th, 2020 at 12:45pm
Print Post  
Smiley Smiley Smiley Smiley Smiley Smiley Smiley
Thanks to you, Lyubo. I did everything you said.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint