Welcome to MSDN Blogs Sign in | Join | Help

A Deep Zoom Blog

Tales of Deep Zoom, creating interesting apps in Silverlight with Deep Zoom, cool new ways to present information
Zooming with constraints

My first blog post will be a small but useful little tip. One of the things that's not built into deep zoom is the ability to specify at which level to stop zooming out, and at which level to stop zooming in.

Check out the following example (which I will use in future blog posts for more examples). Please note that there is a bug in the mousehandler here where the browser still captures the wheel (not just the app), something I intend to fix in a future post.

Launch in a separate window

This example is a very deep sparse image - it is a collection of vacation pictures I took while I was in Europe last summer. I laid them out nicely for a pleasant browsing experience.

One of the issues with simply checking the zoom level and resetting it when the zoom level passes a certain point is that Deep Zoom uses its own animations for zooming to a certain level. So simply checking the current zoom level when a user flicks the mouse wheel and  ensuring that a certain level of zoom isn't passed doesn't do the trick - at the time you set the new zoom level, Deep Zoom only initiates the animation, but the current zoom level will not have changed. You need to instead anticipate what the zoom level will be after you zoom, and make sure to adjust the target zoom rate appropriately.

The way this is done here is to keep track of my own zoom level, check how deep I've zoomed in or how far I've zoomed out at any given time.

Another thing that's been done here is to open the XML file for the image, and check for the extents of the image and not let the user zoom any further than 2x the maximum resolution of the image. This was done using the LINQ library in Silverlight. Note that you also have to take into account the namespace in the Deep Zoom image XML file, which is something for which I haven't seen any examples on the web, but it's part of the project below:

 Zooming with Constraints Sample

Note: I didn't include the image in the sample because it's too big (167 megs). When you build and run the app, you won't see the content, though the concepts are all there.


Posted: Tuesday, August 05, 2008 10:23 PM by lutzg
Filed under:

Comments

Doug said:

This is good stuff.

How would you modify it to work with a canvas instead?

# August 6, 2008 9:08 AM

Vikram Pendse said:

Nice Stuff..I have similar on my blog..I really appreciate "Buttons" which you created for zooming, I done this using DeepZoom Composer..Nice one!

# August 6, 2008 9:17 PM

Donn said:

Cool Stuff indeed. I noticed when scrolling that the screen "jiggs" with each roll of the mouse, is there a way to stop that?

# August 8, 2008 12:52 PM

Donn said:

Oops nevermind! Somehow I missed that section about it grabbing the browser. :)

# August 8, 2008 1:00 PM

Community Blogs said:

Bill Reiss on Embedding fonts, .net Curry on hosting SL Content, Corrina Barber updated another SL2 skin

# August 13, 2008 10:00 AM

Ivan Monteiro said:

Nice work =)

I noticed 100% cpu usage... is there any workaround on this? You can contact me with ivanmonteiro_@hotmail.com.

# October 19, 2009 5:33 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker