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); }
private void pictureBox1_DoubleClick(object sender, EventArgs e) { drower.Draw(first, last, nAngle, cf); q.DrawLine(); pictureBox1.Image = q.bitmap; drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFirstPoligon = true; q.Clone(); }
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); } }
private void button2_Click(object sender, EventArgs e) { Figure = null; abstractFabric = new UncommonPoligon(); textBox3.Visible = false; Eraser = false; Pipetka = false; fill = false; isFirstPoligon = true; Fill = null; toolStripDropDownButton1.Image = безЗаливкиToolStripMenuItem.Image; drower = abstractFabric.CreateDrower(Figure, brush, Fill); }
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; } } }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.X < 0 || e.X > pictureBox1.Width || e.Y < 0 || e.Y > pictureBox1.Height) { isFirst = true; } if (isDrow == true && e.X > 0 && e.X < pictureBox1.Width && e.Y > 0 && e.Y < pictureBox1.Height) { if (drowing == true) { brush.SetIsFirst(isFirst); isFirst = false; if (!(abstractFabric is UncommonPoligon)) { q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { if (Figure is Ellipse) { cf.figur = new Сircle(); drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFigureChanged = true; } else if (Figure is Rectangl) { cf.figur = new Square(); drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFigureChanged = true; } else if (Figure is IsoscelesTriangle) { cf.figur = new RightTriangle(); drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFigureChanged = true; } } else if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift) { if (Figure is Ellipse && isFigureChanged == true) { cf.figur = new Ellipse(); drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFigureChanged = false; } else if (Figure is Rectangl && isFigureChanged == true) { cf.figur = new Rectangl(); drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFigureChanged = false; } else if (Figure is IsoscelesTriangle && isFigureChanged == true) { cf.figur = new IsoscelesTriangle(); drower = abstractFabric.CreateDrower(cf.figur, cf.brush, cf.fill); isFigureChanged = false; } } last = e.Location; drower.Draw(first, last, nAngle, cf); if (!(drower is ClassLine)) { q.DrawFigure(); } else if (drower is ClassLine) { q.DrawLine(); first = last; } pictureBox1.Image = q.bitmap; } } else if ((isHanded == true || isGran == true) && currentFigur != null) { q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); moving.ChangeFigure(e.Location); q.Move(); q.DrowOnlyOneFigure(currentFigur); pictureBox1.Image = q.bitmap; } else if (isZoom == true && currentFigur != null) { q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); if (currentFigur.figur is Сircle) { drower.Draw(currentFigur.centr, e.Location, nAngle, currentFigur); } else if (currentFigur.figur is Ellipse) { Point po = new Point(currentFigur.l.X + (e.X - first.X), currentFigur.l.Y + (e.Y - first.Y)); drower.Draw(currentFigur.f, po, nAngle, currentFigur); first = e.Location; } else { moving.ChangeFigure(e.Location); } q.DrawFigure(); q.DrowOnlyOneFigure(currentFigur); pictureBox1.Image = q.bitmap; q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); } else if (isTurn == true && currentFigur != null) { q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); moving.ChangeFigure(e.Location); q.Move(); q.DrowOnlyOneFigure(currentFigur); pictureBox1.Image = q.bitmap; } else if (isTop == true && currentFigur != null) { q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); currentFigur.poin[tmpIndex] = e.Location; q.DrowOnlyOneFigure(currentFigur); q.DrawFigure(); pictureBox1.Image = q.bitmap; } else if (isFigureChanged == true && currentFigur != null) { q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); currentFigur.poin[tmpIndex] = e.Location; drower.Draw(first, currentFigur.poin[tmpIndex], nAngle, cf); q.DrowOnlyOneFigure(currentFigur); q.DrawFigure(); pictureBox1.Image = q.bitmap; } } }