Zoom in and then zoom out to original position by CODE

4 posts, 1 answers
  1. Iñaki
    Iñaki avatar
    3 posts
    Member since:
    May 2012

    Posted 23 May Link to this post

    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

     

     

  2. Iñaki
    Iñaki avatar
    3 posts
    Member since:
    May 2012

    Posted 23 May in reply to Iñaki Link to this post

    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

  3. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3476 posts

    Posted 27 May Link to this post

    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.
  4. Iñaki
    Iñaki avatar
    3 posts
    Member since:
    May 2012

    Posted 27 May in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks a lot for the answer.

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

    Regards,

    Xabier/Zitu

Back to Top