Beispiel #1
0
 private void picBox_MouseUp(object sender, MouseEventArgs e)
 {
     if (selectMode != SelectionMode.None)
     {
         if (selectMode == SelectionMode.Size || selectMode == SelectionMode.Move) //|| mode == ClickObj.Move)
         {
             selectMode = SelectionMode.None;
             select     = Choice.None;
         }
     }
     if (select == Choice.Pen)
     {
         tempPen = null;
     }
 }
Beispiel #2
0
        private void picBox_MouseDown(object sender, MouseEventArgs e)
        {
            oldLocation = e.Location;
            selectMode  = SelectionMode.None;

            foreach (var item in obj)
            {
                int handleNumber = item.CheckHandlePoint(e.Location);
                if (handleNumber > 0)
                {
                    selectMode    = SelectionMode.Size;
                    selectShape   = item;
                    item.Selected = true;
                    break;
                }
            }

            if (selectMode == SelectionMode.None)
            {
                foreach (var item in obj)
                {
                    if (item.CheckHandlePoint(e.Location) == 0)
                    {
                        item.Selected = true;
                        selectMode    = SelectionMode.Move;
                        Cursor        = Cursors.SizeAll;
                    }
                    if (!CTRLpresed)
                    {
                        if (item.CheckHandlePoint(e.Location) < 0)
                        {
                            item.Selected = false;
                        }
                    }
                }
            }
            //picBox.Refresh();
            Refresh();
            if (select == Choice.Pen)
            {
                Pencil p = new Pencil(e.Location, pen, g);
                p.Draw();
                obj.Add(p);
                tempPen = p;
            }
            if (select == Choice.Rectangle || select == Choice.Squre) //|| select==Choice.Rhom)
            {
                Recangle s = new Recangle(e.Location, new Point(e.X + 5, e.Y + 5), pen, brush, g);
                s.Draw();
                s.DrawHandle();
                s.Selected = true;
                obj.Add(s);
                selectShape = s;
                selectMode  = SelectionMode.Size;
                handelNum   = 5;
            }
            if (select == Choice.Circle)
            {
                Circle s = new Circle(e.Location, new Point(e.X + 5, e.Y + 5), pen, brush, g);
                s.Draw();
                s.DrawHandle();
                s.Selected = true;
                obj.Add(s);
                selectShape = s;
                selectMode  = SelectionMode.Size;
                handelNum   = 5;
            }
            if (select == Choice.Triangle)
            {
                Triangle s = new Triangle(e.Location, new Point(e.X + 5, e.Y + 5), pen, brush, g);
                s.Draw();
                s.DrawHandle();
                s.Selected = true;
                obj.Add(s);
                selectShape = s;
                selectMode  = SelectionMode.Size;
                handelNum   = 5;
            }
            if (select == Choice.Rhom)
            {
                Rhomboid s = new Rhomboid(e.Location, new Point(e.X + 5, e.Y + 5), pen, brush, g);
                s.Draw();
                s.DrawHandle();
                s.Selected = true;
                obj.Add(s);
                selectShape          = s;
                selectShape.Selected = true;
                selectMode           = SelectionMode.Size;
                handelNum            = 5;
            }
            if (select == Choice.Line)
            {
                Line s = new Line(e.Location, new Point(e.X + 5, e.Y + 5), pen, g);
                s.Draw();
                s.DrawHandle();
                s.Selected = true;
                obj.Add(s);
                selectShape          = s;
                selectShape.Selected = true;
                selectMode           = SelectionMode.Size;
                handelNum            = 5;
            }
            Refresh();
        }