This is a migrated thread and some comments may be shown as answers.

Zoom in and then zoom out to original position by CODE

3 Answers 210 Views
Diagram, DiagramRibbonBar, DiagramToolBox
This is a migrated thread and some comments may be shown as answers.
Iñaki
Top achievements
Rank 1
Iñaki asked on 23 May 2019, 11:21 AM

Good day,

I want to get the zoom back to the original zoom and position after the radDiagram being zoomed.

Sometimes it is difficult to keep the zoom in good position. Thus I would like to put it again in the default zoom and point when pushing a button.

The RadDiagram making code, creating the RadDiagram:

    Telerik.Windows.Diagrams.Core.DiagramConstants.MinimumZoom = 0.1
    Telerik.Windows.Diagrams.Core.DiagramConstants.MaximumZoom = 10
    MyRadDiagram.Zoom = 0.1
    MyRadDiagram.IsSettingsPaneEnabled = False
    MyRadDiagram.DiagramElement.IsBackgroundSurfaceVisible = False
 
    MyRadDiagram.BackgroundGrid.Visibility = False
    MyRadDiagram.BackgroundPageGrid.Visibility = Telerik.WinControls.ElementVisibility.Hidden
    MyRadDiagram.BackgroundImageLayout = ImageLayout.None
    MyRadDiagram.BackgroundImage = Nothing
    posCentral = MyRadDiagram.Position

The code I use to get back to original zoom:

Private posCenter As New Telerik.Windows.Diagrams.Core.Point(0, 0)
Private Sub bCenterZoom_Click(sender As Object, e As EventArgs) Handles bCenterZoom.Click
    loading = True
    MyRadDiagram.Position = posCentral
    MyRadDiagram.Zoom = 0.1
    loading = False
End Sub

 

 

3 Answers, 1 is accepted

Sort by
0
Iñaki
Top achievements
Rank 1
answered on 23 May 2019, 11:24 AM

Well it just posted without me ending it, I see that when I click in the button it doesn't really get me to original point and it does consume a lot of memory if I try to do it around 5-6 times.

I do not know if there is something wrong with the control or in my approach.

Thanks in advance.

Regards, Xabier / Zitu

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 May 2019, 12:03 PM
Hello, IƱaki,    

In order to save the current state of a RadDiagram and keep the zoom factor and position offset, you can use the following code snippet. Thus, you can save the current position and restore it at a later moment. The attached gif file illustrates the obtained behavior:

Dim zoom As double
Dim offset As SizeF
Private Sub RadButton1_Click( sender As Object,  e As EventArgs) Handles RadButton1.Click
    zoom= Me.RadDiagram1.Zoom
    offset = Me.RadDiagram1.DiagramElement.MainPanel.PositionOffset 
End Sub
 
Private Sub RadButton2_Click( sender As Object,  e As EventArgs) Handles RadButton2.Click
    Me.RadDiagram1.Zoom=zoom
    Me.RadDiagram1.DiagramElement.MainPanel.PositionOffset  = offset
End Sub

As to the memory consumption, I haven't noticed any unreleased memory. I have attached my sample project. Could you please give it a try and see how it works on your end. Feel free to modify it in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

I am looking forward to your reply. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Iñaki
Top achievements
Rank 1
answered on 27 May 2019, 03:34 PM

Thanks a lot for the answer.

It is what we were looking for. Didn't see the mainPanel PositionOffset.

Regards,

Xabier/Zitu

Tags
Diagram, DiagramRibbonBar, DiagramToolBox
Asked by
Iñaki
Top achievements
Rank 1
Answers by
Iñaki
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or