Exemple #1
0
        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;
            }
        }
Exemple #2
0
        private void picPaint_MouseDown(object sender, MouseEventArgs e)
        {
            if (Shape is RectangleSelection)
            {
                (Shape as RectangleSelection).isSelectDone = true;
            }
            isSaved = false;
            if (e.Button == MouseButtons.Left)
            {
                //Neu da chon doi tuong
                if (objectChoose == "bucket")
                {
                    //Shape = null;
                    if (isCropRectDraw == true)
                    {
                        grapList._list.RemoveAt(posOfCrop);
                        isCropRectDraw = false;
                        isCrop         = false;
                    }

                    // them 1 nonShape de ko hien handlepoint khi su dung bucket
                    //ObjectDrawing clear = new NoneShapeDrawing();
                    //grapList._posINCOMPLETE = grapList._list.Count;
                    //grapList._list.Insert(grapList._list.Count, clear);
                    //picPaint.Refresh();

                    Shape = new BucketDrawing(doubleBuffer, e.X, e.Y, mtitleCurrentColor.BackColor);

                    if (!grapList.isExist(Shape))
                    {
                        grapList._listBucketFill.Insert(grapList._listBucketFill.Count, grapList._list.Count);
                        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" || objectChoose == "select")
                {
                    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 (isCropRectDraw == true)
                        {
                            grapList._list.RemoveAt(posOfCrop);
                            isCropRectDraw = false;
                            isCrop         = false;
                        }

                        if (objectChoose == "crop")
                        {
                            isCropRectDraw = true;
                        }


                        //status = DRAW_STATUS.COMPLETE;
                        ChooseObject();
                        Shape.Mouse_Down(e);

                        grapList._list.Insert(grapList._list.Count, Shape);
                        grapList._posINCOMPLETE = grapList._list.Count - 1;
                    }
                }
                else
                {
                    if (isCropRectDraw == true)
                    {
                        grapList._list.RemoveAt(posOfCrop);
                        isCrop = false;
                    }
                    //status = DRAW_STATUS.COMPLETE;
                    ChooseObject();
                    Shape.Mouse_Down(e);
                    if (objectChoose != "none")
                    {
                        grapList._list.Insert(grapList._list.Count, Shape);
                        grapList._posINCOMPLETE = grapList._list.Count - 1;
                    }
                }
            }

            else
            {
                //status = DRAW_STATUS.COMPLETE;
                Shape = null;
            }
        }