We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Zoomto node not working

Thread ID:

Created:

Updated:

Platform:

Replies:

130228 Apr 29,2017 04:00 PM UTC May 3,2017 12:05 PM UTC WinForms 6
loading
Tags: Diagram
Olivier
Asked On April 29, 2017 04:00 PM UTC

Hi,

I'm trying to do a simple function to zoom to a node selected by its name

        private void btZoomTo_Click(object sender, EventArgs e) {
            var node = (RoundRect)diagram1.Model.Nodes.FindNodeByName("0139939");
            diagram1.View.ZoomToSelection(node.BoundingRectangle);
        }

Problem is result is a blank screen, both vertical/horizontal scrolling bars going to full bottom right.

Thanks,

Olivier

Olivier
Replied On April 30, 2017 05:53 PM UTC

I tried to replace zoomtoselection with this line :

                diagram1.View.ZoomToSelection(new RectangleF(1000, 1000, 1000, 1000));

Each time I click on the button, I get a zoom out. I expected that ZoomToSelection will always return the same view centered on this rectangle. I don' understand.

2) I do not understand either :

diagram1.View.ZoomType = ZoomType.Center

this is a property. Which command will use it to set the diagram at the center of the 

3) diagram1.View.ZoomToActual();

What view is supposed to be returned ? In my case diagram disappear I need to use scrollbars to get it back in the view.




Naganathan Ganesh Babu [Syncfusion]
Replied On May 2, 2017 08:26 AM UTC

Hi Olivier, 
 
Thanks for contacting Syncfusion support. 
 
Regarding diagram1.View.ZoomToSelection() method, 
Please note that, the ZoomSelection() method is used to zoom the selected/particular region and it shows the full view of the selected region. So, if you are trying to zoom same region again, then zooming is based on already zoomed value (i.e. diagram.view’s Magnification property value)  
 
For example: After zooming the Diagram.View’s Magnification to 300 and once again if we perform zoom operation the zooming will considered from 300(old magnification value) only not from 100. 
 
So, we suggest you to use Diagram's "ZoomTo()" method in order to achieve Zoom the Diagram based on the Node’s position and set below parameters as follows,   
    
1.      FocusPoint : Determines the point to zoom.   
2.      ZoomCommand : Determines whether ZoomIn/ZoomOut.   
3.      ZoomIncrement Determines the value to zoom.   
   
Please refer to the below code example.   
   
Code example:   
   
[C#]   
   
var node = diagram1.Model.Nodes.FindNodeByName("Rectangle1"); 
 
ZoomParameters zoom = new ZoomParameters(); 
 
zoom.FocusPoint = node.BoundingRectangle.Location; 
 
zoom.ZoomCommand = ZoomCommand.ZoomIn; 
 
zoom.ZoomIncrement = 25; 
 
diagram1.ZoomTo(zoom);   
 
Also, please refer to the below sample.   
   
Sample:   
 
 
2) I do not understand either : 
 
diagram1.View.ZoomType = ZoomType.Center 
 
The diagram document can be zoomed to the center of the current viewport by setting the ZoomType as Center.   
3) diagram1.View.ZoomToActual(); 
 
What view is supposed to be returned ? In my case diagram disappear I need to use scrollbars to get it back in the view. 
 
ZoomToActual() is used to zoom the diagram as initial/actual size (i.e. Diagram.View’s Magnification value is set as 100).  
 
 
 
Please refer to the below online documentation link. 
 
 
Regards, 
 
Naganathan K G 


Olivier
Replied On May 2, 2017 11:57 AM UTC

Hi

I tried your code but it doesn't do what I expected to get. I want to search for a node and display it at the center of the view. 

If I try the code you send : Searched node is the blue one at the top in the beforeZoomTo screen copy (see attached file). 

The first and second zoomto return blank screen. the next ones zoom into the view (that's ok ) but never to the same node and furthermore never to the one I want.

This happens when diagram1.View.ZoomType = ZoomType.Center is set.If I set it to top left, then zoom is increasing I never get my nodes into the view, only blanck screen.

I noticed that after zoomto, nodes are rejected far outside view, somewhere around bottom left. I guess may be there is a coordinates problem, perhaps in the model ?

What could be wrong ?

Thanks,Olivier        

        private void btZoomTo_Click(object sender, EventArgs e) {
            var node = diagram1.Model.Nodes.FindNodeByName("ND000000139615");
            if (node != null) {
                diagram1.View.ZoomType = ZoomType.Center;
                ZoomParameters zoom = new ZoomParameters();
                //Focus the point to zoom the diagram
                zoom.FocusPoint = node.BoundingRectangle.Location;
                //Set whether ZoomIn or ZoomOut the diagram
                zoom.ZoomCommand = ZoomCommand.ZoomIn;
                //Set zoom increment value
                zoom.ZoomIncrement = 50;
                diagram1.ZoomTo(zoom);
            }else{
                diagram1.FitDocument();
            }
        }

Attachment: zoomto_eb3af160.7z

Olivier
Replied On May 2, 2017 02:17 PM UTC

To be more precise, I add that I do not want at first to zoom into the view but want to place the searched node in ther center of the screen.,. A sort of programmatic pantool.

Olivier
Replied On May 2, 2017 06:47 PM UTC

I tried 
                this.diagram1.Controller.View.Origin=node.BoundingRectangle.Location;
and
               this.diagram1.Controller.View.ScrollToNode(node);

both "works" in a way that the node goes to the top-left screen. 

How can I then :

1) put the node in the center of the view. (I tried diagram.View.ZoomType)ZoomType.Center, no change)
2) draw the node at a given scale/zoom level (my layout is drawed very small, 1/20 of the view size. I tried this.diagram1.Controller.View.Magnification no change)
3) refresh the display automatically. So far, View is refreshed when I move the mouse from the left pane/button into the view).

Thanks 

Olivier

Naganathan Ganesh Babu [Syncfusion]
Replied On May 3, 2017 12:05 PM UTC

Hi Olivier,    
We have created a new incident for this query. Please log on to our support website to check for further updates.    
Regards,    
Naganathan K G  
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;