private void btnUndo_Click(object sender, EventArgs e) { status = DRAW_STATUS.COMPLETE; grapList.RemoveLast(); picPaint.Refresh(); }
private void picPaint_MouseUp(object sender, MouseEventArgs e) { if (objectChoose == "pencil" || objectChoose == "eraser") { Shape = null; //status = DRAW_STATUS.COMPLETE; } if (Shape != null) { Shape.Mouse_Up(e); } if (objectChoose == "crop" || objectChoose == "select") { if (Shape._endPoint.X < 0) { Shape._endPoint.X = 0; } if (Shape._endPoint.Y < 0) { Shape._endPoint.Y = 0; } if (Shape._endPoint.X > fillImage.Size.Width) { Shape._endPoint.X = fillImage.Size.Width; } if (Shape._endPoint.Y > fillImage.Size.Height) { Shape._endPoint.Y = fillImage.Size.Height; } } if (objectChoose == "select" && isSelect == true) { //status = DRAW_STATUS.COMPLETE; int width = Math.Abs(Shape._endPoint.X - Shape._startPoint.X); int height = Math.Abs(Shape._endPoint.Y - Shape._startPoint.Y); if (width != 0 && height != 0) { if (Shape._startPoint.X > Shape._endPoint.X) { int temp = Shape._startPoint.X; Shape._startPoint.X = Shape._endPoint.X; Shape._endPoint.X = temp; } if (Shape._startPoint.Y > Shape._endPoint.Y) { int temp = Shape._startPoint.Y; Shape._startPoint.Y = Shape._endPoint.Y; Shape._endPoint.Y = temp; } ObjectDrawing t = Shape; grapList.RemoveLast(); picPaint.Refresh(); Rectangle ROI = new Rectangle(Shape._startPoint.X, Shape._startPoint.Y, width, height); (Shape as RectangleSelection)._img = CropImage(doubleBuffer, ROI); selectedArea = new Rectangle(0, 0, width, height); //Vị trí lấy hình cắt được gán vào HCN _CopyCut._img = (Shape as RectangleSelection)._img; //Hình dc cắt grapList._list.Insert(grapList._list.Count, t); RectangleDrawing rec = new RectangleDrawing(Color.White, 1); rec._startPoint = Shape._startPoint; rec._endPoint = Shape._endPoint; rec.isSelectRect = true; grapList._list.Add(rec); int Soluong = grapList._list.Count; grapList.Swap(Soluong - 1, Soluong - 2); isSelect = false; } picPaint.Refresh(); } }