public override void Draw(CreatedFigure cf) { for (int i = 0; i < cf.poin.Count - 2; i++) { brush.DrawLine(cf.poin[i].X, cf.poin[i].Y, cf.poin[i + 1].X, cf.poin[i + 1].Y); } }
public void DrowOnlyOneFigure(CreatedFigure cf) { drawer = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); drawer.Draw(cf); Graphics graph = Graphics.FromImage(bitmap); graph.DrawImage(bitFigure, 0, 0); }
public void DrowNotAllFigure(CreatedFigure cf2) { foreach (CreatedFigure f in listOfFigure) { if (f != cf2) { drawer = abstractFabric.CreateDrower(f.figur, f.brush, f.fill); drawer.Draw(f); } Graphics graph = Graphics.FromImage(bitmap); graph.DrawImage(bitFigure, 0, 0); } }
public override void Draw(Point point, Point point2, int nAngle, CreatedFigure cf) { if (points == null) { points = new List <Point>(); cf.poin.Add(point); brush.SetDot(point.X, point.Y); } else { brush.DrawLine(cf.poin[n].X, cf.poin[n].Y, point2.X, point2.Y); cf.poin.Add(point); n++; } }
public override void Draw(CreatedFigure cf) { for (int i = 0; i < cf.poin.Count - 1; i++) { brush.DrawLine(cf.poin[i].X, cf.poin[i].Y, cf.poin[i + 1].X, cf.poin[i + 1].Y); } if (cf.figur != null) { brush.DrawLine(cf.poin[0].X, cf.poin[0].Y, cf.poin[cf.poin.Count - 1].X, cf.poin[cf.poin.Count - 1].Y); } int x = (cf.poin[0].X + cf.poin[cf.poin.Count / 3].X + cf.poin[2 * cf.poin.Count / 3].X) / 3;//ищем куда лить int y = (cf.poin[0].Y + cf.poin[cf.poin.Count / 3].Y + cf.poin[2 * cf.poin.Count / 3].Y) / 3; if (cf.fill != null) { fill.SetColor(x, y); fill.Casting(x, y); } }
public override void Draw(Point first, Point last, int nAngle, CreatedFigure cf) { cf.poin = cf.figur.Drow(first.X, first.Y, last.X, last.Y, nAngle); cf.f = first; cf.centr = cf.figur.centr; cf.start = cf.figur.start; cf.l = last; for (int i = 0; i < cf.poin.Count - 1; i++) { brush.DrawLine(cf.poin[i].X, cf.poin[i].Y, cf.poin[i + 1].X, cf.poin[i + 1].Y); } brush.DrawLine(cf.poin[0].X, cf.poin[0].Y, cf.poin[cf.poin.Count - 1].X, cf.poin[cf.poin.Count - 1].Y); int x = (cf.poin[0].X + cf.poin[cf.poin.Count / 3].X + cf.poin[2 * cf.poin.Count / 3].X) / 3;//ищем куда лить int y = (cf.poin[0].Y + cf.poin[cf.poin.Count / 3].Y + cf.poin[2 * cf.poin.Count / 3].Y) / 3; if (cf.fill != null) { fill.SetColor(x, y); fill.Casting(x, y); } }
public override void Draw(Point point1, Point point2, int nAngle, CreatedFigure cf) { brush.DrawLine(point1.X, point1.Y, point2.X, point2.Y); cf.poin.Add(point1); cf.poin.Add(point2); }
public abstract void Draw(CreatedFigure cf);
public abstract void Draw(Point point1, Point point2, int nAngle, CreatedFigure cf);
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (drowing == true) { if (!(abstractFabric is UncommonPoligon)) { if (Figure == null) { cf = new CreatedFigure(new Brush(brush), null, Fill); } else { cf = new CreatedFigure(new Brush(brush), Figure, Fill); } drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); q.listOfFigure.Add(cf); q.Clone2(); } first = e.Location; isDrow = true; isFirst = true; if (firstColor == true) { if (e.Button == MouseButtons.Left) { if (fill == true) { if (button1.BackColor != q.bitmap.GetPixel(e.X, e.Y)) { Fill = new SolidFill(button1.BackColor); Fill.SetColor(e.X, e.Y); Fill.Casting(e.X, e.Y); pictureBox1.Image = q.bitmap; } } else if (Pipetka == true) { button1.BackColor = q.bitmap.GetPixel(e.X, e.Y); color = button1.BackColor; brush.SetColor(color); cf.brush.SetColor(color); } else if (Eraser == true) { if (cf != null) { cf.brush.SetColor(Color.White); } brush.SetColor(Color.White); brush.SetDot(e.X, e.Y); pictureBox1.Image = q.bitmap; } else { if (cf != null) { cf.brush.SetColor(button1.BackColor); } brush.SetColor(color); if (abstractFabric is LineFabric) { brush.SetDot(e.X, e.Y); q.DrawLine(); pictureBox1.Image = q.bitmap; } } } else if (e.Button == MouseButtons.Right) { cf.brush.SetColor(button4.BackColor); brush.SetColor(button4.BackColor); if (abstractFabric is LineFabric) { brush.SetDot(e.X, e.Y); q.DrawLine(); pictureBox1.Image = q.bitmap; } } } else { if (e.Button == MouseButtons.Left) { if (fill == true) { if (button4.BackColor != q.bitmap.GetPixel(e.X, e.Y)) { Fill = new SolidFill(button4.BackColor); Fill.SetColor(e.X, e.Y); Fill.Casting(e.X, e.Y); pictureBox1.Image = q.bitmap; } } else if (Pipetka == true) { button4.BackColor = q.bitmap.GetPixel(e.X, e.Y); color = button4.BackColor; brush.SetColor(color); if (cf != null) { cf.brush.SetColor(color); } } else if (Eraser == true) { cf.brush.SetColor(Color.White); brush.SetColor(Color.White); brush.SetDot(e.X, e.Y); pictureBox1.Image = q.bitmap; } else { if (cf != null) { cf.brush.SetColor(button4.BackColor); } brush.SetColor(button4.BackColor); if (abstractFabric is LineFabric) { brush.SetDot(e.X, e.Y); q.DrawLine(); pictureBox1.Image = q.bitmap; } } } else if (e.Button == MouseButtons.Right) { if (cf != null) { cf.brush.SetColor(button1.BackColor); } brush = new Brush(brush); brush.SetColor(button1.BackColor); if (abstractFabric is LineFabric) { brush = new Brush(brush); brush.SetDot(e.X, e.Y); q.DrawLine(); pictureBox1.Image = q.bitmap; } } } if (abstractFabric is UncommonPoligon) { if (isFirstPoligon == true) { cf = new CreatedFigure(brush, Figure, Fill); q.listOfFigure.Add(cf); isFirstPoligon = false; first = e.Location; last = e.Location; drower.Draw(e.Location, e.Location, nAngle, cf); q.DrawLine(); q.Clone2(); } else { drower.Draw(e.Location, first, nAngle, cf); q.DrawLine(); } pictureBox1.Image = q.bitmap; } } else if (isHanded == true || isZoom == true || isTurn == true) { isDrow = true; currentFigur = moving.FindPoint(e.Location); if (currentFigur != null) { q.bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowNotAllFigure(currentFigur); q.Clone2(); //q.SetTmp(); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowOnlyOneFigure(currentFigur); pictureBox1.Image = q.bitmap; } } else if (isTop == true || isFigureChanged == true) { isDrow = 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); currentFigur = moving.FindPoint(p); if (currentFigur != null) { tmpIndex = moving.FindMainPoint(p); first = moving.FirstPoint(p); break; } } if (currentFigur != null) { break; } } if (currentFigur != null) { q.bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowNotAllFigure(currentFigur); q.Clone2(); //q.SetTmp(); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowOnlyOneFigure(currentFigur); pictureBox1.Image = q.bitmap; } } else if (isGran == true) { isDrow = 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); currentFigur = moving.FindPoint(p); if (currentFigur != null) { tmpIndex = moving.FindMainPoint(p); break; } } if (currentFigur != null) { break; } } if (currentFigur != null) { q.bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowNotAllFigure(currentFigur); q.Clone2(); //q.SetTmp(); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowOnlyOneFigure(currentFigur); q.DrawFigure(); pictureBox1.Image = q.bitmap; } } else if (isColorChanged == true) { isDrow = true; currentFigur = moving.FindPoint(e.Location); if (currentFigur != null) { q.bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowNotAllFigure(currentFigur); q.Clone2(); currentFigur.brush.SetColor(button1.BackColor); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowOnlyOneFigure(currentFigur); q.DrawFigure(); pictureBox1.Image = q.bitmap; } } else if (isThicknessChange == true) { isDrow = true; currentFigur = moving.FindPoint(e.Location); if (currentFigur != null) { q.bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowNotAllFigure(currentFigur); q.Clone2(); currentFigur.brush.ChangePaint(n); q.GetBrush(brush, abstractFabric); q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.DrowOnlyOneFigure(currentFigur); q.DrawFigure(); pictureBox1.Image = q.bitmap; } } }