I have a custom PictureBox that can zoom in with the MouseWheel event. Now I want to add a pan function to it. I mean, when the PictureBox is in an enlarged state, if the user left the clicks and holds the click, then move the mouse, the image will pan in the image window.
Here is my code, but unfortunately it doesn't work! I donβt know where to look for more ...
private Point _panStartingPoint = Point.Empty; private bool _panIsActive; private void CurveBox_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Focus(); _panIsActive = true; _panStartingPoint = e.Location; } } private void CurveBox_MouseUp(object sender, MouseEventArgs e) { _panIsActive = false; } private void CurveBox_MouseLeave(object sender, EventArgs e) { _panIsActive = false; } private void CurveBox_MouseMove(object sender, MouseEventArgs e) { if(_panIsActive && IsZoomed) { var g = CreateGraphics();
I suspect a MouseMove ... I'm not sure if something is happening in this event and / or nx and ny contains the correct point.
Any hints / tips are really appreciated!
Saeid yazdani
source share