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

Set Zoom Value

5 Answers 125 Views
Panorama
This is a migrated thread and some comments may be shown as answers.
Ralf
Top achievements
Rank 2
Ralf asked on 26 Aug 2014, 10:55 AM
How can i set the Zoom Value by code

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 26 Aug 2014, 11:29 AM
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.
 
0
Ralf
Top achievements
Rank 2
answered on 26 Aug 2014, 11:42 AM
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
0
Stefan
Telerik team
answered on 26 Aug 2014, 03:20 PM
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.
 
0
Ralf
Top achievements
Rank 2
answered on 27 Aug 2014, 08:20 PM
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?
0
Stefan
Telerik team
answered on 29 Aug 2014, 07:48 AM
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.
 
Tags
Panorama
Asked by
Ralf
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Ralf
Top achievements
Rank 2
Share this question
or