@TechTips: Can you explain the significance of declaring a constructor that takes an
IContainer
as a parameter? If it is important, that means that your base
PictureBox
should have also implemented it, yet, you are not calling the base class to pass the container to it as well.
Also it would help if you explain why for the mouse down event, you don't care which button was pressed when you store the current mouse location, but for the mouse move event, you only care about the left mouse button.
A suggestion:
this.Left += e.X - location.X;
this.Top += e.Y - location.Y;
can be re-written simply as:
Location += (Size)e.Location - (Size)location;
Both do the same thing, but the latter makes it obvious that you are computing the delta between the current mouse location (
e.Location
) and the point where the mouse button was first pressed (
location
), and then applying that delta to the current bitmap
Location
. The cast to
Size
is to take advantage of
Point
's explicit conversion as well as its support for using the addition and subtraction operators.