public void btnObject_Click(object sender, EventArgs e) { Button btnObject = (Button)sender; objectChoose = btnObject.Name.Remove(0, 3).ToLower(); if (objectChoose != "crop") { isCrop = false; } if (objectChoose == "crop" && isCrop == 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); Rectangle ROI = new Rectangle(Shape._startPoint.X + 1, Shape._startPoint.Y + 1, width - 2, height - 2); fillImage = CropImage(doubleBuffer, ROI); panelPaint.Size = fillImage.Size; picPaint.Refresh(); isCrop = false; } }
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); } }
private void picPaint_MouseMove(object sender, MouseEventArgs e) { toolStripStatusLabel1.Text = "Cursor: " + e.Location.X + " x " + e.Location.Y; if (Shape != null) { Shape.Mouse_Move(e); status = DRAW_STATUS.INCOMPLETE; if (Shape.CheckLocation(e.Location) == 0) { Cursor = Cursors.SizeAll; } else if (Shape.CheckLocation(e.Location) > 0) { Cursor = Cursors.Cross; } else { Cursor = Cursors.Default; } picPaint.Refresh(); } }
private void picPaint_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { //Neu da chon doi tuong if (objectChoose == "bucket") { ; } //{ // //Shape = null; // Shape = new BucketDrawing(doubleBuffer, fillImage, e.X, e.Y, current); // grapList._list.Insert(grapList._list.Count, Shape); // picPaint.Refresh(); // } else if (objectChoose == "rectangle" || objectChoose == "circle" || objectChoose == "star" || objectChoose == "line" || objectChoose == "rhombus" || objectChoose == "triangle" || objectChoose == "pentagon" || objectChoose == "hexagon" || objectChoose == "crop") { if (Shape != null && Shape.CheckLocation(e.Location) >= 0) { Shape.Mouse_Down(e); status = DRAW_STATUS.INCOMPLETE; if (Shape.CheckLocation(e.Location) == 0) { Cursor = Cursors.SizeAll; } if (Shape.CheckLocation(e.Location) > 0) { Cursor = Cursors.Cross; } } else { if (objectChoose != "crop") { status = DRAW_STATUS.COMPLETE; ChooseObject(); Shape.Mouse_Down(e); grapList._list.Insert(grapList._list.Count, Shape); } else { if (isCrop == true) { if (grapList._list.Count != 0) { grapList._list.RemoveAt(grapList._list.Count - 1); } picPaint.Refresh(); } status = DRAW_STATUS.COMPLETE; ChooseObject(); Shape.Mouse_Down(e); grapList._list.Insert(grapList._list.Count, Shape); } } } else { status = DRAW_STATUS.COMPLETE; ChooseObject(); Shape.Mouse_Down(e); grapList._list.Insert(grapList._list.Count, Shape); } } else { status = DRAW_STATUS.COMPLETE; Shape = null; } }
private void btnUndo_Click(object sender, EventArgs e) { status = DRAW_STATUS.COMPLETE; grapList.RemoveLast(); picPaint.Refresh(); }