Esempio n. 1
0
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive == true)
     {
         brush.BrushColor = Canvas.GetCanvas.GetPixel(e.X, e.Y);
     }
 }
Esempio n. 2
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);
     }
 }
Esempio n. 3
0
 public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (havecorners == true)
     {
         if ((Math.Abs(e.Location.X - activeFigure.figure.cornerBottomRight.X) < 5) && (Math.Abs(e.Location.Y - activeFigure.figure.cornerBottomRight.Y) < 5))
         {
             cursorActive = true;
             activecorner = "cornerBottomRight";
         }
         if ((Math.Abs(e.Location.X - activeFigure.figure.cornerBottomLeft.X) < 5) && (Math.Abs(e.Location.Y - activeFigure.figure.cornerBottomLeft.Y) < 5))
         {
             cursorActive = true;
             activecorner = "cornerBottomLeft";
         }
         if ((Math.Abs(e.Location.X - activeFigure.figure.cornerTopLeft.X) < 5) && (Math.Abs(e.Location.Y - activeFigure.figure.cornerTopLeft.Y) < 5))
         {
             cursorActive = true;
             activecorner = "cornerTopLeft";
         }
         if ((Math.Abs(e.Location.X - activeFigure.figure.cornerTopRight.X) < 5) && (Math.Abs(e.Location.Y - activeFigure.figure.cornerTopRight.Y) < 5))
         {
             cursorActive = true;
             activecorner = "cornerTopRight";
         }
     }
     tmpPoint = e.Location;
 }
Esempio n. 4
0
        // ================================================== Методы установки значений по умолчанию ==================================================

        private void startProgram() // Набор стартовых значений
        {
            labelX.Text = Convert.ToString(pictureBoxSheet.Width);
            labelY.Text = Convert.ToString(pictureBoxSheet.Height);
            if (canvas == Canvas.GetCanvas)
            {
                Canvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height);
                setDefaultToolRaster();
            }
            if (canvas == VectorCanvas.GetCanvas)
            {
                VectorCanvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height);
                setDefaultToolVector();
            }
            if (canvas == null)
            {
                Canvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height);
                VectorCanvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height);
                canvas           = Canvas.GetCanvas;
                brush            = new CircleBrush(brushSize, paintColor1);
                brush.BrushColor = palette1.BackColor;
                fill             = new NoFill(paintColor2);
                tool             = new PenTool();
            }
            pictureBoxSheet.DrawToBitmap(Canvas.GetCanvas.Bmp.Bmp, pictureBoxSheet.ClientRectangle);
        }
Esempio n. 5
0
 public void MouseUp(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     cursorActive = false;
     x2           = e.X;
     y2           = e.Y;
     Canvas.GetCanvas.WriteToPictureBox(sheet);
 }
Esempio n. 6
0
 public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (canvas == Canvas.GetCanvas)
     {
         Canvas.GetCanvas.Fill(e.X, e.Y, brush.BrushColor);
         Canvas.GetCanvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 7
0
 public void MouseUp(PictureBox sheet, IBrush brushFig, IFill fillFig, MouseEventArgs e)
 {
     activeFigure.brush = (IBrush)brushFig.Clone();
     activeFigure.fill  = (IFill)fillFig.Clone();
     cursorActive       = false;
     canvas.Render();
     canvas.WriteToPictureBox(sheet);
 }
Esempio n. 8
0
 public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     color            = brush.BrushColor;
     brush.BrushColor = sheet.BackColor;
     cursorActive     = true;
     x1 = e.X;
     y1 = e.Y;
     brush.DrawDot(Canvas.GetCanvas.Bmp, e.X, e.Y);
     Canvas.GetCanvas.WriteToPictureBox(sheet);
 }
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive)
     {
         canvas.LoadFromCache();
         canvas.Turn(activeFigure);
         activeFigure.Draw(canvas);
         canvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 10
0
 public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     canvas.SaveToCache();
     cursorActive = true;
     x1           = e.X;
     y1           = e.Y;
     x2           = e.X;
     y2           = e.Y;
     canvas.WriteToPictureBox(sheet);
 }
Esempio n. 11
0
 public void MouseUp(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (activeFigure != null)
     {
         cursorActive = false;
         canvas.Render();
         canvas.PointChangeModeOfRectangle(sheet, activeFigure);
         canvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 12
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. 13
0
 private void buttonLine_Click(object sender, EventArgs e) // Выбор инструмента Линия
 {
     tool = new FigureTool(new Line(), canvas);
     if (canvas is VectorCanvas)
     {
         VectorCanvas.GetCanvas.RenderWrite(pictureBoxSheet);
     }
     fill = new NoFill(fill);
     hideOptMenu(sender);
     option = 0;
 }
Esempio n. 14
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. 15
0
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive == true)
     {
         x2 = e.X;
         y2 = e.Y;
         brush.DrawLine(Canvas.GetCanvas.Bmp, x1, y1, x2, y2, false);
         x1 = x2;
         y1 = y2;
         Canvas.GetCanvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 16
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);
     }
 }
 public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     foreach (Drawfigure f in canvas.figures)
     {
         if (f.figure.IsInside(e.Location))
         {
             activeFigure = f;
             cursorActive = true;
             canvas.RenderExceptFigure(activeFigure);
             canvas.SaveToCache();
         }
     }
 }
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive)
     {
         canvas.LoadFromCache();
         dx = e.X - tmpPoint.X;
         dy = e.Y - tmpPoint.Y;
         activeFigure.figure.MoveFigure(dx, dy);
         tmpPoint = e.Location;
         activeFigure.Draw(canvas);
         canvas.WriteToPictureBox(sheet);
     }
 }
Esempio n. 19
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);
     }
 }
 public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     if (cursorActive)
     {
         if (activeFigure != null)
         {
             canvas.LoadFromCache();
             activeFigure.figure.dotlist[tmpIndex] = e.Location;
             activeFigure.Draw(canvas);
             canvas.PointChangeModeActiveFigure(sheet, activeFigure);
             canvas.WriteToPictureBox(sheet);
         }
     }
 }
Esempio n. 21
0
        public void MouseUp(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            cursorActive = false;
            x2           = e.X;
            y2           = e.Y;
            Drawfigure drawer    = new Drawfigure(figure, brush, fill);
            Drawfigure drawerTmp = new Drawfigure(figureTmp, brush, fill);

            if (canvas is VectorCanvas)
            {
                VectorCanvas.GetCanvas.figures.Add(drawer);
                VectorCanvas.GetCanvas.figuresTmp.Add(drawerTmp);
            }
            drawer.Draw(canvas);
            canvas.WriteToPictureBox(sheet);
        }
Esempio n. 22
0
        public void MouseMove(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            if (cursorActive)
            {
                if (activeFigure != null)
                {
                    canvas.LoadFromCache();
                    dx = e.X - tmpPoint.X;
                    dy = e.Y - tmpPoint.Y;
                    activeFigure.figure.ChangeSizeFigure(dx, dy, activecorner);

                    tmpPoint = e.Location;
                    activeFigure.Draw(canvas);
                    canvas.PointChangeModeOfRectangle(sheet, activeFigure);
                    canvas.WriteToPictureBox(sheet);
                }
            }
        }
        public void MouseDoubleClick(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            if (activeFigure != null)
            {
                canvas.LoadFromCache();

                //если попали по точке удаляем точку
                //если нет, пытаемся добавить точку на грань
                if (!activeFigure.figure.DeleteApproximatePoint(e.Location, 10))
                {
                    activeFigure.figure.AddPoint(e.Location, 10);
                }

                activeFigure.Draw(canvas);
                //canvas.PointChangeMode(sheet);
                canvas.PointChangeModeActiveFigure(sheet, activeFigure);
                canvas.WriteToPictureBox(sheet);
            }
        }
        public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            cursorActive = true;
            for (int i = -10; i <= 10; i++)
            {
                for (int j = -10; j <= 10; j++)
                {
                    Point p = new Point(e.X + i, e.Y + j);
                    activeFigure = canvas.FindFigureByPoint(p);
                    if (activeFigure != null)
                    {
                        tmpIndex = canvas.FindPointByPoint(p);
                        break;
                    }
                }
                if (activeFigure != null)
                {
                    break;
                }
            }

            //для дабл клика(добавления вершин)
            if (activeFigure == null)
            {
                cursorActive = false;
                foreach (Drawfigure f in canvas.figures)
                {
                    if (f.figure.IsInside(e.Location))
                    {
                        activeFigure = f;
                    }
                }
            }
            //---------
            if (activeFigure != null)
            {
                canvas.RenderExceptFigure(activeFigure);
                canvas.SaveToCache();
                activeFigure.Draw(canvas);
                canvas.WriteToPictureBox(sheet);
            }
        }
Esempio n. 25
0
 public void MouseDown(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     foreach (Drawfigure f in canvas.figures)
     {
         if (f.figure.IsInside(e.Location))
         {
             activeFigure    = f;
             index           = canvas.figures.IndexOf(activeFigure);
             activeFigureTmp = canvas.figuresTmp[index];
             for (int i = 0; i < activeFigureTmp.figure.dotlist.Count; i++)
             {
                 activeFigure.figure.dotlist[i] = activeFigureTmp.figure.dotlist[i];
             }
             activeFigure.brush = activeFigureTmp.brush;
             activeFigure.fill  = activeFigureTmp.fill;
             cursorActive       = true;
             canvas.SaveToCache();
         }
     }
 }
Esempio n. 26
0
        public void MouseClick(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
        {
            foreach (Drawfigure f in canvas.figures)
            {
                if (f.figure.IsInside(e.Location))
                {
                    activeFigure = f;

                    cursorActive = true;
                    canvas.RenderExceptFigure(activeFigure);
                    canvas.SaveToCache();
                }
            }

            if (activeFigure != null)
            {
                activeFigure.figure.ChangeCorners();
                canvas.PointChangeModeOfRectangle(sheet, activeFigure);
                havecorners = true;
            }
        }
Esempio n. 27
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);
        }
Esempio n. 28
0
        // ================================================== Методы работы меню ==================================================

        private void changeFill(object obj) // Изменение отображения параметров в меню заливки фигур
        {
            if (labelFillCont.ForeColor == Color.Gold)
            {
                pictureBoxFillCont.Visible = false;
                labelFillCont.ForeColor    = Color.White;
            }
            if (labelFill.ForeColor == Color.Gold)
            {
                pictureBoxFillOnly.Visible = false;
                labelFill.ForeColor        = Color.White;
            }
            if (labelCont.ForeColor == Color.Gold)
            {
                pictureBoxContOnly.Visible = false;
                labelCont.ForeColor        = Color.White;
            }
            if ((obj as Label).Text == "Контур + заливка")
            {
                labelFillCont.ForeColor    = Color.Gold;
                pictureBoxFillCont.Visible = true;
                fill = new SolidFill(fill);
            }
            if ((obj as Label).Text == "Контур")
            {
                labelCont.ForeColor        = Color.Gold;
                pictureBoxContOnly.Visible = true;
                fill = new NoFill(fill);
            }
            if ((obj as Label).Text == "Заливка")
            {
                labelFill.ForeColor        = Color.Gold;
                pictureBoxFillOnly.Visible = true;
                fill = new OnlyFill(fill);
            }
        }
Esempio n. 29
0
 public void MouseClick(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
 }
Esempio n. 30
0
 public void MouseUp(PictureBox sheet, IBrush brush, IFill fill, MouseEventArgs e)
 {
     cursorActive = false;
     x2           = e.X;
     y2           = e.Y;
 }