Esempio n. 1
0
        public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            cursorActive = true;
            x1           = e.X;
            y1           = e.Y;
            Drawline drawer = new Drawline(x1, y1, x1, y1, brush, true);

            drawer.Draw(Canvas.GetCanvas);
            Canvas.GetCanvas.WriteToPictureBox(sheet);
        }
Esempio n. 2
0
        public void MouseDoubleClick(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            cursorActive = false;
            x2           = e.X;
            y2           = e.Y;
            Drawline drawer = new Drawline(x2, y2, x0, y0, brush, false);

            drawer.Draw(Canvas.GetCanvas);
            Canvas.GetCanvas.WriteToPictureBox(sheet);
            gon = false;
        }
Esempio n. 3
0
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive == true)
     {
         x2 = e.X;
         y2 = e.Y;
         Drawline drawer = new Drawline(x1, y1, x2, y2, brush, false);
         drawer.Draw(Canvas.GetCanvas);
         x1 = x2;
         y1 = y2;
         Canvas.GetCanvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 4
0
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive == true)
     {
         Canvas.GetCanvas.LoadFromCache();
         x2 = e.X;
         y2 = e.Y;
         dotList.Add(new Tuple <int, int>(x2, y2));
         Drawline drawer = new Drawline(x1, y1, x2, y2, brush, false);
         drawer.Draw(Canvas.GetCanvas);
         Canvas.GetCanvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 5
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));
        }
Esempio n. 6
0
        public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            Canvas.GetCanvas.SaveToCache();
            cursorActive = true;
            if (gon == false)
            {
                x1  = e.X;
                y1  = e.Y;
                gon = true;
                x0  = x1;
                y0  = y1;
            }
            else
            {
                x1 = x2;
                y1 = y2;
            }

            Drawline drawer = new Drawline(x1, y1, e.X, e.Y, brush, true);

            drawer.Draw(Canvas.GetCanvas);
            Canvas.GetCanvas.WriteToPictureBox(sheet);
        }