private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
downPoint = e.Location;
downRectangle =
new Rectangle(0, 0, ((Control)sender).Width, label1.Height);
downRectangle.Offset(((Control)sender).PointToScreen(new Point(0, 0)));
ControlPaint.DrawReversibleFrame(
downRectangle, Color.White, FrameStyle.Thick);
lastRectangle = downRectangle;
}
}
private void label1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ControlPaint.DrawReversibleFrame(
lastRectangle, Color.White, FrameStyle.Thick);
label1.Location = new Point(
((Control)sender).Location.X + e.X - downPoint.X,
((Control)sender).Location.Y + e.Y - downPoint.Y);
}
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ControlPaint.DrawReversibleFrame(
lastRectangle, Color.White, FrameStyle.Thick);
Rectangle rectangle = downRectangle;
rectangle.Offset(e.X - downPoint.X, e.Y - downPoint.Y);
ControlPaint.DrawReversibleFrame(
rectangle, Color.White, FrameStyle.Thick);
lastRectangle = rectangle;
}
}