Exemple #1
0
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     figure.Create(x1, y1, x2, y2);
     figureTmp.Create(x1, y1, x2, y2);
     if (cursorActive == true)
     {
         canvas.LoadFromCache();
         x2 = e.X;
         y2 = e.Y;
         IFill  tmpFill = new NoFill();
         IBrush tmpBrush;
         if (fill is OnlyFill)
         {
             tmpBrush = new SquareBrush(1, fill.FillColor);
         }
         else
         {
             tmpBrush = brush;
         }
         Drawfigure drawer    = new Drawfigure(figure, tmpBrush, tmpFill);
         Drawfigure drawerTmp = new Drawfigure(figureTmp, tmpBrush, tmpFill);
         drawer.Draw(canvas);
         canvas.WriteToPictureBox(sheet);
     }
 }
        public void PointChangeModeOfRectangle(PictureBox sheet, Drawfigure obj)
        {
            SquareBrush  brush         = new SquareBrush(1, Color.Blue);
            Square       square        = new Square();
            List <Point> rectanglelist = new List <Point>();

            rectanglelist.Add(obj.figure.cornerTopLeft);
            rectanglelist.Add(obj.figure.cornerBottomRight);
            rectanglelist.Add(obj.figure.cornerBottomLeft);
            rectanglelist.Add(obj.figure.cornerTopRight);


            foreach (Point t in rectanglelist)
            {
                for (int i = -3; i <= 3; i++)
                {
                    Point p1 = new Point(t.X - 3, t.Y + i);
                    Point p2 = new Point(t.X + 3, t.Y + i);
                    square.Createdotlist(p1.X, p1.Y, p2.X, p2.Y);
                    //WriteToPictureBox(sheet);
                    brush.DrawLine(Bmp, p1.X, p1.Y, p2.X, p2.Y, false);
                    WriteToPictureBox(sheet);
                }
            }
        }
Exemple #3
0
        public void Draw(AbstractCanvas canvas)
        {
            //случай линии
            if (figure.dotlist.Count == 2)
            {
                Drawline drawer = new Drawline(figure.dotlist[0].X, figure.dotlist[0].Y, figure.dotlist[1].X, figure.dotlist[1].Y, brush, true);
                drawer.Draw(canvas);
                return;
            }

            BitmapWrap tmp = new BitmapWrap(canvas.Width, canvas.Height);

            tmp.Lock();

            IBrush tmpBrush = new SquareBrush(1, fill.FillColor);

            tmpBrush.DrawLine(tmp, figure.dotlist[0].X, figure.dotlist[0].Y, figure.dotlist[1].X, figure.dotlist[1].Y, true);
            for (int i = 1; i < figure.dotlist.Count - 1; i++)
            {
                tmpBrush.DrawLine(tmp, figure.dotlist[i].X, figure.dotlist[i].Y, figure.dotlist[i + 1].X, figure.dotlist[i + 1].Y);
            }
            tmpBrush.DrawLine(tmp, figure.dotlist[figure.dotlist.Count - 1].X, figure.dotlist[figure.dotlist.Count - 1].Y, figure.dotlist[0].X, figure.dotlist[0].Y);

            if (figure.IsInside(figure.center))
            {
                fill.Fill(tmp, figure.center);
            }

            if (!(fill is OnlyFill))
            {
                brush.DrawLine(tmp, figure.dotlist[0].X, figure.dotlist[0].Y, figure.dotlist[1].X, figure.dotlist[1].Y, true);
                for (int i = 1; i < figure.dotlist.Count - 1; i++)
                {
                    brush.DrawLine(tmp, figure.dotlist[i].X, figure.dotlist[i].Y, figure.dotlist[i + 1].X, figure.dotlist[i + 1].Y);
                }
                brush.DrawLine(tmp, figure.dotlist[figure.dotlist.Count - 1].X, figure.dotlist[figure.dotlist.Count - 1].Y, figure.dotlist[0].X, figure.dotlist[0].Y);
            }

            tmp.Unlock();
            Graphics g = Graphics.FromImage(canvas.Bmp.Bmp);

            g.DrawImage(tmp.Bmp, new System.Drawing.Rectangle(0, 0, canvas.Width, canvas.Height));
        }
        public void PointChangeModeActiveFigure(PictureBox sheet, Drawfigure obj)
        {
            SquareBrush brush  = new SquareBrush(1, Color.Red);
            Square      square = new Square();

            if (obj.figure is Ellips || obj.figure is Circle)
            {
                brush.BrushColor = obj.brush.BrushColor;
                brush.BrushSize  = 0;
            }
            foreach (Point t in obj.figure.dotlist)
            {
                for (int i = -3; i <= 3; i++)
                {
                    Point p1 = new Point(t.X - 3, t.Y + i);
                    Point p2 = new Point(t.X + 3, t.Y + i);
                    square.Createdotlist(p1.X, p1.Y, p2.X, p2.Y);
                    brush.DrawLine(Bmp, p1.X, p1.Y, p2.X, p2.Y, false);
                    WriteToPictureBox(sheet);
                }
            }
        }