using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class DdBotton : Button
{
public DdBotton()
{
this.MouseDown += new MouseEventHandler(DdBotton_MouseDown);
this.MouseUp += new MouseEventHandler(DdBotton_MouseUp);
this.MouseMove += new MouseEventHandler(DdBotton_MouseMove);
}
Point MousePoint;
void DdBotton_MouseMove(object sender, MouseEventArgs e)
{
if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
{
if (this.MousePoint != Point.Empty)
{
this.Left += e.X - this.MousePoint.X;
this.Top += e.Y - this.MousePoint.Y;
}
}
}
void DdBotton_MouseUp(object sender, MouseEventArgs e)
{
this.MousePoint = Point.Empty;
}
void DdBotton_MouseDown(object sender, MouseEventArgs e)
{
if((e.Button & MouseButtons.Left) == MouseButtons.Left)
{
if (this.MousePoint == Point.Empty)
{
this.MousePoint = new Point(e.X, e.Y);
}
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkNvbXBvbmVudE1vZGVsOwp1c2luZyBTeXN0ZW0uRGF0YTsKdXNpbmcgU3lzdGVtLkRyYXdpbmc7CnVzaW5nIFN5c3RlbS5MaW5xOwp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLldpbmRvd3MuRm9ybXM7CgpuYW1lc3BhY2UgV2luZG93c0Zvcm1zQXBwbGljYXRpb24xCnsKICAgIGNsYXNzIERkQm90dG9uIDogQnV0dG9uCiAgICB7CiAgICAgICAgcHVibGljIERkQm90dG9uKCkKICAgICAgICB7CiAgICAgICAgICAgIHRoaXMuTW91c2VEb3duICs9IG5ldyBNb3VzZUV2ZW50SGFuZGxlcihEZEJvdHRvbl9Nb3VzZURvd24pOwogICAgICAgICAgICB0aGlzLk1vdXNlVXAgKz0gbmV3IE1vdXNlRXZlbnRIYW5kbGVyKERkQm90dG9uX01vdXNlVXApOwogICAgICAgICAgICB0aGlzLk1vdXNlTW92ZSArPSBuZXcgTW91c2VFdmVudEhhbmRsZXIoRGRCb3R0b25fTW91c2VNb3ZlKTsKICAgICAgICB9CiAgICAgICAgUG9pbnQgTW91c2VQb2ludDsKICAgICAgICB2b2lkIERkQm90dG9uX01vdXNlTW92ZShvYmplY3Qgc2VuZGVyLCBNb3VzZUV2ZW50QXJncyBlKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKChlLkJ1dHRvbiAmIE1vdXNlQnV0dG9ucy5MZWZ0KSA9PSBNb3VzZUJ1dHRvbnMuTGVmdCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKHRoaXMuTW91c2VQb2ludCAhPSBQb2ludC5FbXB0eSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB0aGlzLkxlZnQgKz0gZS5YIC0gdGhpcy5Nb3VzZVBvaW50Llg7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5Ub3AgKz0gZS5ZIC0gdGhpcy5Nb3VzZVBvaW50Llk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHZvaWQgRGRCb3R0b25fTW91c2VVcChvYmplY3Qgc2VuZGVyLCBNb3VzZUV2ZW50QXJncyBlKQogICAgICAgIHsKICAgICAgICAgICAgdGhpcy5Nb3VzZVBvaW50ID0gUG9pbnQuRW1wdHk7CiAgICAgICAgfQoKICAgICAgICB2b2lkIERkQm90dG9uX01vdXNlRG93bihvYmplY3Qgc2VuZGVyLCBNb3VzZUV2ZW50QXJncyBlKQogICAgICAgIHsKICAgICAgICAgICAgaWYoKGUuQnV0dG9uICYgTW91c2VCdXR0b25zLkxlZnQpID09IE1vdXNlQnV0dG9ucy5MZWZ0KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAodGhpcy5Nb3VzZVBvaW50ID09IFBvaW50LkVtcHR5KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHRoaXMuTW91c2VQb2ludCA9IG5ldyBQb2ludChlLlgsIGUuWSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K