private void ScreenBody_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { isDowned = true; if (RectReady == false) { Rect.X = e.X; Rect.Y = e.Y; downPoint = new Point(e.X, e.Y); } if (RectReady == true) { tmpx = e.X; tmpy = e.Y; } } if (e.Button == MouseButtons.Right) { if (RectReady != true) { this.Close(); return; } MainPainter.DrawImage(baseImage, 0, 0); RectReady = false; } } private void ScreenBody_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { isDowned = false; RectReady = true; } } private void ScreenBody_MouseMove(object sender, MouseEventArgs e) { if (RectReady == false) { if (isDowned == true) { Image New = DrawScreen((Image)baseImage.Clone(), e.X, e.Y); MainPainter.DrawImage(New, 0, 0); New.Dispose(); } } if (RectReady == true) { if (Rect.Contains(e.X, e.Y)) { //this.Cursor = Cursors.Hand; if (isDowned == true) { //和上一次的位置比较获取偏移量 Rect.X = Rect.X + e.X - tmpx; Rect.Y = Rect.Y + e.Y - tmpy; //记录现在的位置 tmpx = e.X; tmpy = e.Y; MoveRect((Image)baseImage.Clone(), Rect); } } } } |