The math of your mouse move handler to move the rectangle based on mouse movements seems completely off; I think you need something like this:
private void Image_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int initialX = 0, initialY = 0;
Rectangle.X = (e.X - FirstPoint.X) + initialX;
Rectangle.Y = (e.Y - FirstPoint.Y) + initialY;
Image.Invalidate();
}
}
Thus, the upper left corner of the rectangle will follow the mouse, tracking the delta between the initial location of the mouse and the current location of the mouse. Note, however, that every time you click and drag repeatedly, the rectangle returns to its original location.
, Rectangle "" (.. ), :
private void Image_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Rectangle.X += e.X - FirstPoint.X;
Rectangle.Y += e.Y - FirstPoint.Y;
FirstPoint = new MovePoint { X = e.X, Y = e.Y };
Image.Invalidate();
}
}
: MovePoint, System.Drawing.Point. , .