Zoomto node not working
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
SIGN IN To post a reply.
6 Replies
OL
Olivier
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.
NG
Naganathan Ganesh Babu
Syncfusion Team
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
OL
Olivier
May 2, 2017 11:57 AM UTC
Hi
Attachment: zoomto_eb3af160.7z
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
OL
Olivier
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.
OL
Olivier
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
NG
Naganathan Ganesh Babu
Syncfusion Team
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
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
OL Olivier
- Apr 29, 2017 04:00 PM UTC
- May 3, 2017 12:05 PM UTC