void PbConvertedMouseUp(object sender, MouseEventArgs e) { // If the MouseUp event occurs, the user is not dragging. if (isDrag) { isDrag = false; //erase old rectangle ControlPaint.DrawReversibleFrame(theRectangle, this.BackColor, FrameStyle.Dashed); int left = (PbConverted.Width - PbConverted.Image.Width) / 2; int top = (PbConverted.Height - PbConverted.Image.Height) / 2; Rectangle CropRect = new Rectangle(Math.Min(sP.X, eP.X) - left, Math.Min(sP.Y, eP.Y) - top, Math.Abs(eP.X - sP.X), Math.Abs(eP.Y - sP.Y)); //Rectangle CropRect = new Rectangle(p.X-left, p.Y-top, orientedRect.Width, orientedRect.Height); IP.CropImage(CropRect, PbConverted.Image.Size); //PbOriginal.Image = IP.Original; // Reset the rectangle. theRectangle = new Rectangle(0, 0, 0, 0); Cropping = false; Cursor.Clip = new Rectangle(); UpdateCropping(); } }