Welcome to Atalasoft Community Sign in | Join | Help

Slick Ajax Magnifier

magnifier screenshotRecently we had a customer ask if we had anything like our WinForms Magnifier MouseTool available on the WebForms side of things.  We get this question somewhat frequently, and it's always one of those features that seems to fall off the end of the development cycle to higher priority features.  The answer to this question has always been: "It's not inherantly supported, but you could probably make your own by floating another WebImageViewer over the mouse position."

I spent a little of my free time on it, and I've been able to confirm that this works.  Here are the steps that you need to take to get it to work:

  1. Create a WebForm with two WebImageViewer controls on it, one as the main viewer, and one as the magnifier.
  2. Wrap the magnifier WebImageViewer in a div tag, give the div tag an ID, and set the style to display:none.
  3. Attach a JavaScript MouseDownLeft event to the main viewer.
  4. In the MouseDownLeft event, attach JavaScript MouseMove and MouseUp events to both of the viewers, and set the style of the magnifier div to display:none.
  5. In the MouseMove events, set the position of the magnifier div to the position of the mouse - half the size of the magnifier.
  6. In the MouseUp event, detach the MouseMove and MouseUp events (by setting them to a blank function) and set the magnifier div style to display:none.
  7. The final step is to load the same image into both of the WebImageViewer controls, BestFit the main viewer, and keep the magnifier at zoom level 1.

I have attached a VS 2005 demo solution that shows how all of this is put together. This is a file system based web application with dll.refresh files pointing to the install location of DotImage.  If you do not have DotImage installed at that location, you will need to remove and re-add your references to the Atalasoft dll's.

Published Tuesday, May 15, 2007 3:25 PM by David Cilley
Filed under: , ,

Attachment(s): MagnifierDemo.zip

Comments

Friday, April 11, 2008 4:23 PM by TAZ

# re: Slick Ajax Magnifier

I have implemented a magnifier following your example here.  It is really cool.  My magnifier is always visible in a pre-determined area and the user can move it.  I would like to change the cursor to a hand when they are over the div tag that holds the magnifier, but that is not working.  You can only see the hand when you are right on the edge.  Is there a property or method for changing the cursor type (or some little trick)?  Thanks.

Friday, April 11, 2008 4:42 PM by David Cilley

# re: Slick Ajax Magnifier

I'm glad you like the magnifier!

You could probably change the WebImageViewer's Left MouseTool to "Center" (in the HTML):

MouseTool-LeftButton="Center"

This doesn't really do anything form me in my demo, but since your magnifier is already visible, it should show the hand while you're over the magnifier.

Monday, April 14, 2008 9:50 AM by TAZ

# re: Slick Ajax Magnifier

That did the trick.  Thank you.

Monday, April 14, 2008 10:21 AM by TAZ

# re: Slick Ajax Magnifier

Another question.  Is there a way to get a custom cursor?  We would like to see the full hand (with all fingers displayed).

Wednesday, April 16, 2008 10:24 AM by David Cilley

# re: Slick Ajax Magnifier

You could probably float your own div over the viewer, and use that to handle your mouse events as well as your custom cursor.

Anonymous comments are disabled