« on: November 29, 2012 »
I've just checked my old code and it does indeed use LeadTools, which is a third party imaging suite.
If I were to do something like this in standard C#, using GDI+, I would likely try the following:
1. Add a panel to the form and dock it to 'fill'.
2. Add a picturebox control within the panel and set its dimensions so that it matches the panel. Set the SizeMode of the picturebox to "zoom", this will cause the image to stretch to the dimensions of the picturebox, while maintaining the aspect ratio. You probably don't want the picturebox docked as we'll be changing the dimensions and position of it for panning/zooming.
For zooming, I would simply multiply the width and height of the picturebox by a scale/zoom factor. So if you're picturebox is 300x200, it would be scaled to 600x400 at 200% zoom. You could hook the mousewheel event over the picturebox to control the zooming. I'd also hook the mousedown event when over the picturebox and set a dragging flag (bool drag = true) while the mouse is down, also store the X/Y position of the event. When the use mouses up, set the drag flag to false.
You could use the mousemove event over the picturebox to control panning a zoomed image (as long as the dragged flag is set/active). You should be able to compare the current X/Y pos of the mouse during a mousemove event against your drag-start X/Y that you stored on mousedown. This should give you the offset X/Y to reposition the picturebox within the panel for panning.
I think that should do the job.