Q: How can I implement zooming on current mouse position over a picturebox, something like zooming in Google Maps?
I am designing a simple GIS / ma
the code below zoomed and stretched the pictureBox on the current mouse position
pictureBox1.Width = (int)(pictureBox1.Width * zoomratio );
pictureBox1.Height = (int)(pictureBox1.Height * zoomratio );
pictureBox1.Top = (int)(e.Y - zoomratio * (e.Y - pictureBox1.Top));
pictureBox1.Left = (int)(e.X - zoomratio * (e.X - pictureBox1.Left));
I managed to tweak the calculation of the location in this line of code. It's working fine, it is zooming just the way I need it.
pbxMapa.Location = new Point(pbxMapa.Location.X + (int)(((pbxMapa.Location.X - mouseXPbx) / 10) * zoomRatio), pbxMapa.Location.Y + (int)(((pbxMapa.Location.Y - mouseYPbx) / 10) * zoomRatio));