This is my code.
I am able to zoom the picturebox but not at a point.
How to zoom to a mouse point when i rotate the mouse wheel?
The variables are:-
private double m_dZoomscale = 1.0; //THIS IS THE ZOOM SCALE TO WHICH EACH OBJECT
//ARE ZOOMED IN THE CANVAS
public static double s_dScrollValue = .01;
//scale factor value for mouse scroll zooming
The paint code is:-
private void m_Picturebox_Canvas_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.ScaleTransform((float)m_dZoomscale, (float)m_dZoomscale);
}
The main code is:-
protected override void OnMouseWheel(MouseEventArgs mea)
{
m_Picturebox_Canvas.Focus();
if (m_Picturebox_Canvas.Focused == true)
{
if (mea.Delta > 0)
{
ZoomInScroll();
}
else if (mea.Delta < 0)
{
ZoomOutScroll();
}
}
}
The sub functions are as follows:-
//FUNCTION FOR MOUSE SCROL ZOOM-IN
private void ZoomInScroll()
{
m_dZoomscale = m_dZoomscale + s_dScrollValue;
m_Picturebox_Canvas.Invalidate();
}
//FUNCTION FOR MOUSE SCROL ZOOM-IN
private void ZoomOutScroll()
{
m_dZoomscale = m_dZoomscale - s_dScrollValue;
m_Picturebox_Canvas.Invalidate();
}