Set Zoom Value

6 posts, 0 answers
  1. Ralf
    Ralf avatar
    8 posts
    Member since:
    May 2012

    Posted 26 Aug 2014 Link to this post

    How can i set the Zoom Value by code
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Aug 2014 Link to this post

    Hi Ralf,

    I am afraid I do not understand your requirement. Can you please elaborate and can you share what do you mean with "zoom value"?

    I am looking forward to your reply.

    Regards,
    Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ralf
    Ralf avatar
    8 posts
    Member since:
    May 2012

    Posted 26 Aug 2014 in reply to Stefan Link to this post

    Hi Stefan,

    sorry for my short descroption:

    With the Property "EnableZooming" i can enable the zoom functionality. With the mouse i can Change the Zoom at runtime. How can i set this zoom factor.

    Greetings from Germany - Ralf
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Aug 2014 Link to this post

    Hello Ralf,

    Thank you for the clarification.

    The zoom factor is internally calculated and there is no way for one to change it. However, you can disabled the embedded zooming functionality and implement it yourself. Here is how to do it on MouseWheel:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        InitializeComponent();
     
        AddPanorama();
     
        radPanorama1.EnableZooming = false;
        radPanorama1.MouseWheel += radPanorama1_MouseWheel;
    }
     
    bool zoomedIn = false;
    void radPanorama1_MouseWheel(object sender, MouseEventArgs e)
    {
        if (e.Delta < 0 && this.zoomedIn)
        {
            ZoomOut();
        }
        else if (e.Delta > 0 && !this.zoomedIn)
        {
            ZoomIn(e.Location);
        }
    }
     
    public void ZoomOut()
    {
        if (!zoomedIn)
        {
            return;
        }
     
        radPanorama1.PanoramaElement.ScrollService.Stop();
        radPanorama1.PanoramaElement.Capture = false;
     
        LayoutPanel currentLayout = this.GetCurrentLayout();
     
        SizeF scale = new SizeF((float)this.Bounds.Width / currentLayout.Bounds.Width,
                                (float)this.Bounds.Width / currentLayout.Bounds.Width);
        AnimatedPropertySetting scaleSetting = new AnimatedPropertySetting(
            RadElement.ScaleTransformProperty, new SizeF(1, 1), scale, 5, 20);
        scaleSetting.ApplyValue(currentLayout);
     
        SizeF offset = new SizeF(0, (this.Bounds.Height - currentLayout.Bounds.Height * scale.Height) / 2.0F);
        AnimatedPropertySetting offsetSetting = new AnimatedPropertySetting(
            RadElement.PositionOffsetProperty, currentLayout.PositionOffset, offset, 5, 20);
        offsetSetting.ApplyValue(currentLayout);
     
        this.zoomedIn = false;
         
    }
     
    public void ZoomIn(Point location)
    {
        if (zoomedIn)
        {
            return;
        }
     
        LayoutPanel currentLayout = this.GetCurrentLayout();
        int offset = (int)(-location.X * 1.0F / currentLayout.ScaleTransform.Width + location.X);
     
        AnimatedPropertySetting scaleSetting = new AnimatedPropertySetting(
            RadElement.ScaleTransformProperty, currentLayout.ScaleTransform, new SizeF(1, 1), 5, 20);
        scaleSetting.RemoveAfterApply = true;
        scaleSetting.ApplyValue(currentLayout);
     
        AnimatedPropertySetting offsetSetting = new AnimatedPropertySetting(
            RadElement.PositionOffsetProperty, currentLayout.PositionOffset, new SizeF(offset, 0), 5, 20);
        offsetSetting.RemoveAfterApply = true;
        offsetSetting.AnimationFinished += new AnimationFinishedEventHandler(zoomInOffset_AnimationFinished);
        offsetSetting.ApplyValue(currentLayout);
     
        this.zoomedIn = true;
    }
     
    void zoomInOffset_AnimationFinished(object sender, AnimationStatusEventArgs e)
    {
        AnimatedPropertySetting setting = sender as AnimatedPropertySetting;
        if (setting != null)
        {
            radPanorama1.PanoramaElement.ScrollView((int)((SizeF)setting.EndValue).Width);
        }
    }
     
    private LayoutPanel GetCurrentLayout()
    {
        if (radPanorama1.PanoramaElement.ShowGroups)
        {
            return radPanorama1.PanoramaElement.GroupLayout;
        }
     
        return radPanorama1.PanoramaElement.TileLayout;
    }

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Ralf
    Ralf avatar
    8 posts
    Member since:
    May 2012

    Posted 27 Aug 2014 in reply to Stefan Link to this post

    Hi Stefan,

    thank you for your quick and detailed answer. How can i translate the Linie

    offsetSetting.AnimationFinished += New AnimationFinishedEventHandler(AddressOf zoomInOffset_AnimationFinished)

    to vb.net?
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 29 Aug 2014 Link to this post

    Hi Ralf,

    Please refer to the following MSDN article, which explains how to subscribe to events in VB.NET: http://msdn.microsoft.com/en-us/library/7taxzxka.aspx.

    In addition you can use our free online converter for conversion between C# and VB.NET.

    Regards,
    Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready