public void HighlightSelectedFigureW(AFigure aFigure) { if (aFigure != null) { List <Point> points = aFigure.DoFigureMath(); if (points.Count > 100) { if (points.Count > 360) { for (int i = 0; i < points.Count; i = i + (points.Count / 4)) { DrawLine(points[i], points[i], 7, Color.White); } } for (int i = 0; i < points.Count; i = i + 45) { if (i == 0 || i == 90 || i == 180 || i == 270 || i == 360) { } else { DrawLine(points[i], points[i], 7, Color.White); } } } else { for (int i = 0; i < points.Count; i++) { DrawLine(points[i], points[i], 7, Color.White); } } } }
public void IsoscelesTriangleIFabricTest() { IsoscelesTriangleIFabric isoscelesTriangleIFabric = new IsoscelesTriangleIFabric(); AFigure actual = isoscelesTriangleIFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(IsoscelesTriangleIFigure), actual.GetType()); }
public void FigureNDCreateFigureTest() { FigureNDIFabric figureNDFabric = new FigureNDIFabric(); AFigure actual = figureNDFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(FigureNDIFigure), actual.GetType()); }
public void LineNDIFabricTest() { LineNDIFabric lineNDIFabric = new LineNDIFabric(); AFigure actual = lineNDIFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(LineNDIFigure), actual.GetType()); }
public void MouseDown(Pen p, MouseEventArgs e, AFigure figure, IFigureFabric fabric) { _singletone = SingletonData.GetData(); _movingFigure = null; foreach (AFigure checkFigure in _singletone.FigureList) { //if (checkFigure.IsPeak(e.Location)) //{ // _figure = checkFigure; // movingFigure = checkFigure; // figuresList.Remove(_figure); // pictureBox1.Image = canvas.Clear(); // DrawAll(); // startPoint = checkFigure.touchPoint; // mode = "PEAK"; // break; //} if (checkFigure.IsEdge(e.Location) || (checkFigure.IsArea(e.Location) && checkFigure.IsFilled)) { _movingFigure = checkFigure; _singletone.FigureList.Remove(checkFigure); _singletone.PictureBox1.Image = _singletone.Canvas.Clear(); foreach (AFigure figureINList in _singletone.FigureList) { _singletone.PictureBox1.Image = _singletone.Canvas.DrawIt(figureINList, new Pen(figureINList.Color, figureINList.Width)); _singletone.Canvas.Save(); } _startPoint = checkFigure.TouchPoint; break; } } }
public void RectTriangleIFabricTest() { RectTriangleIFabric rectTriangleIFabric = new RectTriangleIFabric(); AFigure actual = rectTriangleIFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(RectTriangleIFigure), actual.GetType()); }
public void CircleCreateFigureTest() { CircleIFabric circleFabric = new CircleIFabric(); AFigure actual = circleFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(CircleFigure), actual.GetType()); }
public void Triangle3DIFabricTest() { Triangle3DIFabric triangle3DIFabric = new Triangle3DIFabric(); AFigure actual = triangle3DIFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(Triangle3DFigure), actual.GetType()); }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { mouseDown = false; fill = false; if (mode == "Изменить") { mode = "Рисуем"; bitmap.AddFigure(ActiveFigure); bitmap.DeleteFigure(Current); ActiveFigure = null; q = false; } if (mode == "Заливка") { ActiveFigure.FindPoint(); ActiveFigure.FillFigure(); mode = "Рисуем"; } if (CurrentFigure != null && _deletingFigure == false) { if (_fillColor != Color.Transparent) { CurrentFigure.FindPoint(); CurrentFigure.FillFigure(); } bitmap.AddFigure(CurrentFigure); } bitmap.CopyInOld(); pictureBox.Image = bitmap.Bitmap; }
private void pictureBox_MouseClick(object sender, MouseEventArgs e) { if (toolBox.SelectedIndex == 6) { if (count == 0) { list.Add(e.Location); count++; } else if (count == 1) { list.Add(e.Location); count++; } else if (count == 2) { list.Add(e.Location); factoryFigure = new TriangleFactory(list); count = 0; list = new List <Point>(); CurrentFigure = factoryFigure.Create(FirstPoint, n, _currentColor, _fillColor, _currentThickness); bitmap.DrawFigure(CurrentFigure); } } }
public void MouseDown(Pen p, MouseEventArgs e, AFigure figure, IFigureFabric fabric) { _singletone = SingletonData.GetData(); if (fabric is LineNDIFabric || fabric is FigureNDIFabric || fabric is Triangle3DIFabric) { //если фигура начинается то записать первую стартПоинт if (_figure == null) { _figure = fabric.CreateFigure(p); _startPoint = e.Location; _figure.TmpPoint = e.Location; _figure.Started = true; } else { _figure.TmpPoint = e.Location; _startPoint = _figure.SecondPoint; } } else { _startPoint = e.Location; _figure = fabric.CreateFigure(p); } }
public void SqareCreateFigureTest() { SquareIFabric squareFabric = new SquareIFabric(); AFigure actual = squareFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(SquareFigure), actual.GetType()); }
public void DrawFillFigure(AFigure aFigure) { List <Point> points = aFigure.DoFigureMath(); ConnectPoints(points, aFigure.SetColor(), aFigure.SetThickness()); aFigure.FillFigure(); }
public void EllipseFCreateFigureTest() { EllipseIFabric ellipseFabric = new EllipseIFabric(); AFigure actual = ellipseFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(EllipseFigure), actual.GetType()); }
public void BrushCreateFigureTest() { BrushFabric brushFabric = new BrushFabric(); AFigure actual = brushFabric.CreateFigure(new Pen(Color.Black, 5)); Assert.AreEqual(typeof(BrushIFigure), actual.GetType()); }
public void DrawUponFigureWithWhite(AFigure aFigure) { if (aFigure != null) { List <Point> points = aFigure.DoFigureMath(); ConnectPoints(points, Color.White, aFigure.SetThickness()); } }
public override void DoLogicOnMouseUp(AFigure figure) { sBitmap.Copy(); sBitmap.FillFigure(figure); sBitmap.CopyFromFill(); figure._movingPoint = new Point(0, 0); figure._nextMovingPoint = new Point(0, 0); }
public override void DoLogicOnMouseClick(Point location, AFigure figure, Color color) { sBitmap.Clear(); sBitmap.EraseIndexFigure(figure); sBitmap.Copy(); sBitmap.FillAllFigures(); sBitmap.CopyFromFill(); }
public override void DoLogicOnMouseClick(Point location, AFigure figure, Color color) { sBitmap.Copy(); //sBitmap.DrawExceptIndexFigures(figure); //sBitmap.FillExceptIndexFigures(_currentFigure); figure._fillColor = color; figure.FillFigure(location); sBitmap.CopyFromFill(); }
private void Form1_Load(object sender, EventArgs e) { _data = SingletonData.GetData(); _data.PictureBox1 = pictureBox1; _data.Canvas = new Canvas(pictureBox1.Width, pictureBox1.Height); fabric = new BrushFabric(); _figure = fabric.CreateFigure(_pen); _mouseMode = new PaintIMode(); }
public override void DoLogigOnMouseDown(AFigure figure) { sBitmap.Clear(); sBitmap.DrawExceptIndexFigures(figure); if (sBitmap._figureList.Count > 1) { sBitmap.Copy(); sBitmap.FillExceptIndexFigures(figure); sBitmap.CopyFromFill(); } }
public Bitmap DrawIt(AFigure figure, Pen pen) { _tmpBitmap = (Bitmap)_mainBitmap.Clone(); _graphics = Graphics.FromImage(_tmpBitmap); //графикс рисует на временном битмапе figure.Painter.DrawFigure(pen, _graphics, figure.GetPath()); if (figure.IsFilled == true) { figure.Filler.FillFigure(pen, _graphics, figure.GetPath()); } return(_tmpBitmap); }
public bool PointInPoint(AFigure aF, Point e) { List <Point> points = aF.DoFigureMath(); for (int i = 0; i < points.Count; i++) { if (e == points[i]) { DrawLine(points[i], points[i], 7, Color.Green); return(true); } } return(false); }
public bool SelectFigureByPointq(Point mousePoint) // ищщет фигуру, в которой находится мышка (если она есть) { foreach (AFigure a in aFigures) { if (a != null) { if (a.IsPointInFigure(mousePoint)) // проверяет, находится ли мышка в рамках фигуры { figure = a; return(true); } } } return(false); }
public void HighlightSelectedFigure(AFigure aFigure) { if (aFigure != null) { List <Point> points = aFigure.DoFigureMath(); if (points.Count > 50) { if (points.Count == 360) // круг { for (int i = 0; i < points.Count; i = i + 45) { if (i == 0 || i == 90 || i == 180 || i == 270 || i == 360) { } else { DrawLine(points[i], points[i], 7, Color.Red); } } } else { Point first = aFigure.ReturnPoints()[0]; Point second = aFigure.ReturnPoints()[1]; List <Point> focusPoints = new MathEllipse().FindFocusPoints(first, second); Point right = focusPoints[1]; Point left = focusPoints[2]; Point top = focusPoints[3]; Point bottom = focusPoints[4]; DrawLine(right, right, 7, Color.Red); DrawLine(left, left, 7, Color.Red); DrawLine(top, top, 7, Color.Red); DrawLine(bottom, bottom, 7, Color.Red); } } else { for (int i = 0; i < points.Count; i++) { DrawLine(points[i], points[i], 7, Color.Red); } } } }
public void ShowWithOutFigure(AFigure afigure) { tmpBitmap = new Bitmap(tmpBitmap.Width, tmpBitmap.Height); Bitmap = new Bitmap(Bitmap.Width, Bitmap.Height); int q = 0; for (int i = 0; i < aFigures.Count; i++) { if (aFigures[i] != afigure) { DrawFigure(afigure); } } CopyInOld(); //DrawUponFigureWithWhite(aFigures[q]); //aFigures.RemoveAt(q); //ShowOnTheScreen(); }
public void MouseDown(Pen p, MouseEventArgs e, AFigure figure, IFigureFabric fabric) { _singletone = SingletonData.GetData(); _rotateFigure = null; foreach (AFigure checkFigure in _singletone.FigureList) { if (checkFigure.IsEdge(e.Location) || (checkFigure.IsArea(e.Location) && checkFigure.IsFilled)) { _rotateFigure = checkFigure; _singletone.FigureList.Remove(checkFigure); _singletone.PictureBox1.Image = _singletone.Canvas.Clear(); foreach (AFigure figureINList in _singletone.FigureList) { _singletone.PictureBox1.Image = _singletone.Canvas.DrawIt(figureINList, new Pen(figureINList.Color, figureINList.Width)); _singletone.Canvas.Save(); } _startPoint = checkFigure.TouchPoint; break; } } }
public void DeleteFigure(AFigure figure) { if (aFigures.Count < 1) { return; } tmpFigure.Add(figure); int index = 0; for (int i = 0; i < aFigures.Count; i++) { if (aFigures[i] == figure) { index = i; break; } } aFigures.RemoveAt(index); ShowOnTheScreen(); }
public void MouseDown(Pen p, MouseEventArgs e, AFigure figure, IFigureFabric fabric) { _singletone = SingletonData.GetData(); foreach (AFigure checkFigure in _singletone.FigureList) { if (checkFigure.IsEdge(e.Location)) { _figure = checkFigure; _movingFigure = checkFigure; _singletone.FigureList.Remove(_figure);//это удаление первой по значению? _figure.AddPeak(); fabric = new FigureNDIFabric(); _figure = fabric.CreateFigure(p); _singletone.PictureBox1.Image = _singletone.Canvas.Clear(); foreach (AFigure figureINList in _singletone.FigureList) { _singletone.PictureBox1.Image = _singletone.Canvas.DrawIt(figureINList, new Pen(figureINList.Color, figureINList.Width)); _singletone.Canvas.Save(); } _startPoint = checkFigure.TouchPoint; } } }
public void MouseUp(Pen pen, MouseEventArgs e, IFigureFabric fabric) { _mouseMove = false; if (_figure != null && _figure.Reaction is NoReactionIReaction) { _figure.Reaction.Do(); SingletonData _fL = SingletonData.GetData(); _fL.FigureList.Add(_figure); _figure = null; } else if (_figure != null && _figure.Reaction is Triangle3DIRightClickReaction && _figure.AnglesNumber == 3) { //ничего не происходит для фигур с FreeLineIRightClickReaction и FreeFigureIRightClickReaction _figure.Reaction.Do(); SingletonData _fL = SingletonData.GetData(); _fL.FigureList.Add(_figure); _figure = null; } if (e.Button == MouseButtons.Right && _figure != null) { if (_figure.Reaction is FreeLineIRightClickReaction || _figure.Reaction is FreeFigureIRightClickReaction) { _figure.Reaction.Do(); SingletonData _fL = SingletonData.GetData(); _fL.FigureList.Add(_figure); _figure = null; } else { _figure.Reaction.Do(); } } }