Exemple #1
0
 private void bePainted1_MouseMove(object sender, MouseEventArgs e)
 {
     if (Ischoose_Button() && this.down)
     {
         if (this.bLine && this.down)
         {
             shapes[shapes.Count - 1]._endPoint = e.Location;
             bePainted1.Invalidate();
         }
         else if (this.bRec && this.down)
         {
             shapes[shapes.Count - 1]._endPoint = e.Location;
             bePainted1.Invalidate();
         }
         else if (this.bCir && this.down)
         {
             shapes[shapes.Count - 1]._endPoint = e.Location;
             bePainted1.Invalidate();
         }
         else if (this.bSqua && this.down)
         {
             shapes[shapes.Count - 1]._endPoint = e.Location;
             bePainted1.Invalidate();
         }
         else if (this.bEllip && this.down)
         {
             shapes[shapes.Count - 1]._endPoint = e.Location;
             bePainted1.Invalidate();
         }
         else if (this.bPolyg && this.down)
         {
             if (this.PolyDrawing)
             {
                 Polygon polygon = shapes[shapes.Count - 1] as Polygon;
                 polygon.points[polygon.points.Count - 1] = e.Location;
                 this.bePainted1.Invalidate();
             }
         }
         else if (this.bBezier && this.down)
         {
             if (this.BezierDrawing)
             {
                 Bezier bezier = shapes[shapes.Count - 1] as Bezier;
                 bezier.points[bezier.points.Count - 1] = e.Location;
                 this.bePainted1.Invalidate();
             }
         }
     }
     else if (this.Moving)
     {
         Cursor.Current = Cursors.SizeAll;
         Point distance = new Point(e.X - SomePoit.X, e.Y - SomePoit.Y);
         SomePoit = e.Location;
         shapes[IndexMoving].Moving(distance);
         this.bePainted1.Invalidate();
     }
     else if (changesSize)
     {
         Cursor.Current = Cursors.SizeNWSE;
         Point distance = new Point(e.X - SomePoit.X, e.Y - SomePoit.Y);
         SomePoit = e.Location;
         shapes[IndexZooming].Zoomming(distance);
         this.bePainted1.Invalidate();
     }
 }
Exemple #2
0
        private void bePainted1_MouseDown(object sender, MouseEventArgs e)
        {
            this.down = true;
            if (Ischoose_Button() && this.down)
            {
                #region Button
                if (this.bLine && this.down)
                {
                    Line ay = new Line();
                    ay._beginPoint = e.Location;
                    ay._endPoint   = ay._beginPoint;
                    ay._lcolor     = btnColor.BackColor;
                    ay._lwidth     = (int)numericUpDown1.Value;
                    ay._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                    ay._lcolorFill = btn_colorFill.BackColor;
                    if (rdb_NoFill.Checked)
                    {
                        ay._fill = false;
                    }
                    else if (rdb_Fill.Checked)
                    {
                        ay._fill = true;
                    }
                    shapes.Add(ay);
                    //   Rectangle a = new Rectangle();


                    //  LowerRight.Add()
                }
                else if (this.bCir && this.down)
                {
                    Circl cir = new Circl();
                    cir._beginPoint = e.Location;
                    cir._endPoint   = cir._beginPoint;
                    cir._lcolor     = btnColor.BackColor;
                    cir._lwidth     = (int)numericUpDown1.Value;
                    cir._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                    cir._lcolorFill = btn_colorFill.BackColor;
                    if (rdb_NoFill.Checked)
                    {
                        cir._fill = false;
                    }
                    else if (rdb_Fill.Checked)
                    {
                        cir._fill = true;
                    }
                    shapes.Add(cir);
                }
                else if (this.bSqua && this.down)
                {
                    Square squa = new Square();
                    squa._beginPoint = e.Location;
                    squa._endPoint   = squa._beginPoint;
                    squa._lcolor     = btnColor.BackColor;
                    squa._lwidth     = (int)numericUpDown1.Value;
                    squa._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                    squa._lcolorFill = btn_colorFill.BackColor;
                    if (rdb_NoFill.Checked)
                    {
                        squa._fill = false;
                    }
                    else if (rdb_Fill.Checked)
                    {
                        squa._fill = true;
                    }
                    shapes.Add(squa);
                }
                else if (this.bRec && this.down)
                {
                    Rectangle rec = new Rectangle();
                    rec._beginPoint = e.Location;
                    rec._endPoint   = rec._beginPoint;
                    rec._lcolorFill = btn_colorFill.BackColor;
                    rec._lcolor     = btnColor.BackColor;
                    rec._lwidth     = (int)numericUpDown1.Value;
                    rec._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                    if (rdb_NoFill.Checked)
                    {
                        rec._fill = false;
                    }
                    else if (rdb_Fill.Checked)
                    {
                        rec._fill = true;
                    }
                    shapes.Add(rec);
                }
                else if (this.bEllip && this.down)
                {
                    Ellipse elip = new Ellipse();
                    elip._beginPoint = e.Location;
                    elip._endPoint   = elip._beginPoint;
                    elip._lcolor     = btnColor.BackColor;
                    elip._lcolorFill = btn_colorFill.BackColor;
                    elip._lwidth     = (int)numericUpDown1.Value;
                    elip._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                    if (rdb_NoFill.Checked)
                    {
                        elip._fill = false;
                    }
                    else if (rdb_Fill.Checked)
                    {
                        elip._fill = true;
                    }
                    shapes.Add(elip);
                }
                else if (this.bPolyg && this.down)
                {
                    if (!this.PolyDrawing)
                    {
                        this.PolyDrawing = true;
                        Polygon poly = new Polygon();
                        poly._beginPoint = e.Location;
                        poly._endPoint   = poly._beginPoint;
                        poly._lcolorFill = btn_colorFill.BackColor;
                        poly._lcolor     = btnColor.BackColor;
                        poly._lwidth     = (int)numericUpDown1.Value;
                        poly._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                        if (rdb_NoFill.Checked)
                        {
                            poly._fill = false;
                        }
                        else if (rdb_Fill.Checked)
                        {
                            poly._fill = true;
                        }
                        poly.points.Add(poly._beginPoint);
                        poly.points.Add(poly._beginPoint);
                        shapes.Add(poly);
                    }
                    else
                    {
                        Polygon polygon = this.shapes[shapes.Count - 1] as Polygon;
                        polygon.points.Add(e.Location);
                    }
                    //this.LowerRight.Add()
                }
                else if (this.bBezier && this.down)
                {
                    if (!this.BezierDrawing)
                    {
                        this.BezierDrawing = true;
                        Bezier bezier = new Bezier();
                        bezier._beginPoint = e.Location;
                        bezier._endPoint   = bezier._beginPoint;
                        bezier._lcolorFill = btn_colorFill.BackColor;
                        bezier._lcolor     = btnColor.BackColor;
                        bezier._lwidth     = (int)numericUpDown1.Value;
                        bezier._dashStyle  = (DashStyle)cbbDashStyle.SelectedIndex;
                        if (rdb_NoFill.Checked)
                        {
                            bezier._fill = false;
                        }
                        else if (rdb_Fill.Checked)
                        {
                            bezier._fill = true;
                        }
                        bezier.points.Add(bezier._beginPoint);
                        bezier.points.Add(bezier._beginPoint);
                        shapes.Add(bezier);
                    }
                    else
                    {
                        Bezier bezier = this.shapes[shapes.Count - 1] as Bezier;
                        if (bezier.points.Count < 4)
                        {
                            bezier.points.Add(e.Location);
                        }
                        else
                        {
                            this.BezierDrawing = false;
                            //Bezier bezier = this.shapes[shapes.Count - 1] as Bezier;
                            string a = "";
                            if (shapes.Count != 0 && Ischoose_Button())
                            {
                                a = shapes[shapes.Count - 1].ShowProp();
                                clb_listHinh.Items.Add(a);
                            }
                        }
                    }
                }
            }
            #endregion
            else if (!this.Moving)
            {
                for (int i = shapes.Count - 1; i >= 0; i--)
                {
                    if (shapes[i]._thisShapeIsChoosing && IsHit(shapes[i].ToMoving_rec.UpperLeft, shapes[i].ToMoving_rec.LowwerRight, e.Location))
                    {
                        this.changesSize = true;
                        this.SomePoit    = e.Location;
                        IndexZooming     = i;
                        i = 0;
                        //Cursor.Current = Cursors.Hand;
                    }
                    else if (IsHit(shapes[i].UpperLeft, shapes[i].LowwerRight, e.Location))
                    {
                        clb_listHinh.SetItemChecked(i, true);
                        shapes[i]._thisShapeIsChoosing = true;
                        this.Moving   = true;
                        IndexMoving   = i;
                        this.SomePoit = e.Location;
                        i             = 0;
                        this.bePainted1.Refresh();
                    }
                }
            }
            else
            {
            }
        }