# question

## C# How can I find the mouse scroll coordinates?

Hello. I want the image to slide to the right when I shear the image to the right with the mouse, or to the downward when I shear downward. I have "shearing" codes. But I need the x and y coordinates of the mouse. How can I get the coordinates (x and y) of mouse movements? (Not mouse click coordinates. It's like holding the mouse and dragging it.) Ex: ![83870-example.jpg][1] [1]: /answers/storage/attachments/83870-example.jpg Thank You! My Shearing Codes: Color WriteColor; Bitmap ExImage; ExImage= new Bitmap(pictureBox1.Image); int ImageWidth = ExImage.Width; int ImageHeight = ExImage.Height; double Bendingcoef = 0.5; double x2 = 0,y2 = 0; for (int x1 = 0; x1<(ImageWidth ); x1++) { for (int y1 = 0; y1<(ImageHeight ); y1++) { WriteColor = ExImage.GetPixel(x1, y1); //+X Direction Axis //x2 = x1 + Bendingcoef y1; //y2 = y1; // -X Direction of Axis //x2 = x1 - Bendingcoef y1; //y2 = y1; //+Y Direction Axis //x2 = x1; //y2 = Bendingcoef x1 + y1; //-Y Direction Axis x2 = x1; y2 = -Bendingcoef x1 + y1; if (x2 > 0 && x2 < ImageWidth && y2 >0 && y2<ImageHeight) ExImage.SetPixel((int)x2,(int)y2, WriteColor); } } pictureBox1.Image = ExImage;

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Try handling three events:

`````` bool IsShearing = false;
Point OriginalCoordinates;

private void pictureBox1_MouseDown( object sender, MouseEventArgs e )
{
IsShearing = true;
OriginalCoordinates = e.Location;
}

private void pictureBox1_MouseMove( object sender, MouseEventArgs e )
{
if( IsShearing )
{
Point current_coordinates = e.Location;
Size movement = new Size( current_coordinates.X - OriginalCoordinates.X, current_coordinates.Y - OriginalCoordinates.Y );

// make the new image based on 'movement' value
// ...

}

}

private void pictureBox1_MouseUp( object sender, MouseEventArgs e )
{
if( IsShearing )
{
IsShearing = false;
// do some final operations, if any
// ...
}
}
``````

You can also detect the clicked button and the keys like <Ctrl> or <Shift>, if needed.

· 2

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks.I started to understand its logic..These are my shearing codes ( Top) .How can I make compatible with these? I tried to make it compatible with the codes but i cant.

\$\$ANON_USER\$\$

Hi，
And re-edit you code by using the following tab.

First understand the use of events such as MouseMove, and what error did you encounter when you code compatible.
Best Regards,
Daniel Zhang