public void RemoveFigure(AbstractFigure figure) { _figures.Remove(figure); figure.OnUpdate -= Update; Update(); }
public void Deserialize(string str) { rewind.RemoveAll(); json = str; string[] jsonRows = json.Split("\n"); string[] arrTypes = JsonSerializer.Deserialize(jsonRows[0], jsonRows.GetType()) as string[]; List <string> notFound = new List <string>(); System.Type myType; rewind.FigureList.Clear(); for (int i = 0; i < arrTypes.Length; i++) { myType = System.Type.GetType(arrTypes[i], false, true); if (myType == null) { myType = pluginControl.FindType(arrTypes[i]); } if (myType != null) { AbstractFigure nfig = JsonSerializer.Deserialize(jsonRows[i + 1], myType) as AbstractFigure; rewind.AddToFigureList(nfig = nfig.GetCopy()); nfig.Draw(Canva); } else if (!notFound.Contains(arrTypes[i])) { MessageBox.Show(arrTypes[i] + " is missing"); notFound.Add(arrTypes[i]); } } }
public void TestFigureI() { figure = new FigureI(); var schemePhase1 = new Scheme(new[] { "#", "#", "#", "#" }); var schemePhase2 = new Scheme(new[] { "####" }); Assert.AreEqual(schemePhase1, figure.GetScheme()); Assert.AreEqual(1, figure.GetWidth()); Assert.AreEqual(4, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase2, figure.GetScheme()); Assert.AreEqual(4, figure.GetWidth()); Assert.AreEqual(1, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase1, figure.GetScheme()); Assert.AreEqual(1, figure.GetWidth()); Assert.AreEqual(4, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase2, figure.GetScheme()); Assert.AreEqual(4, figure.GetWidth()); Assert.AreEqual(1, figure.GetHeight()); }
public void TestFigureJ() { figure = new FigureJ(); var schemePhase1 = new Scheme(new[] {".#", ".#", "##"} ); var schemePhase2 = new Scheme(new[] { "#..", "###"} ); var schemePhase3 = new Scheme(new[] { "##", "#.", "#." } ); var schemePhase4 = new Scheme(new[] { "###", "..#" } ); Assert.AreEqual(schemePhase1, figure.GetScheme()); Assert.AreEqual(2, figure.GetWidth()); Assert.AreEqual(3, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase2, figure.GetScheme()); Assert.AreEqual(3, figure.GetWidth()); Assert.AreEqual(2, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase3, figure.GetScheme()); Assert.AreEqual(2, figure.GetWidth()); Assert.AreEqual(3, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase4, figure.GetScheme()); Assert.AreEqual(3, figure.GetWidth()); Assert.AreEqual(2, figure.GetHeight()); figure.Rotate(); Assert.AreEqual(schemePhase1, figure.GetScheme()); Assert.AreEqual(2, figure.GetWidth()); Assert.AreEqual(3, figure.GetHeight()); }
public void AddFigure(AbstractFigure figure) { _figures.AddLast(figure); figure.OnUpdate += Update; Update(); }
private void pictureBox_MouseDown(object sender, MouseEventArgs e) { if (PaintMode) { if (figure is TriangleFigure) { if (figure.Points.Count % 3 == 0) { figure = figureFactory.CreateFigure(figure.FigureController); } } if (!(figure is CurveFigure || figure is IrregularPolygonFigure || figure is TriangleFigure)) { figure = figureFactory.CreateFigure(figure.FigureController); } if (figure is PolygonFigure) { PolygonFigure tmp = (PolygonFigure)figure; tmp.N = (int)numericUpDown.Value; figure = tmp; } pictureBox.Image = canvas.TmpBitmap; figure.FigureController.MouseDownHandle(e.Location, pen, figure, canvas); pictureBox.Image = canvas.MainBitmap; } if (PaintMode == false) { toolController.MouseDownHandle(e.Location, pen, figure, canvas, container, tool); pictureBox.Image = canvas.MainBitmap; } }
public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas) { _mouseDown = true; figure.Update(point); canvas.CreateLayer(); GC.Collect(); }
private void Delete_Fab(object sender, FileSystemEventArgs e) { int TypeID = 0; for (int i = 0; i < Types.Count; i++) { if (Types[i].Name == e.Name.Split('.')[0]) { TypeID = i; } } string Name = FigList.DeleteFig(Types[TypeID]); DeleteDel Del = new DeleteDel(DeleteFromList); if (Name != null) { lvFigures.Invoke(Del, Name); } SelectedFig = null; SelectedFabric = 0; Types.RemoveAt(TypeID); Creators.RemoveAt(TypeID); Buttons.RemoveAt(TypeID); RedrawButtons(Buttons, TypeID); Domains.RemoveAt(TypeID); MainView.Image = Canvas; }
private void MarkFigure(AbstractFigure SelectedFig) { if (SelectedFig is IEditable) { SelectedFig.Mark(); MainView.Image = Canvas; } }
public void MouseUpHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas) { _mouseDown = false; figure.Markup.AddPolygon(figure.Points.ToArray()); canvas.Graphics.DrawPath(pen, figure.Markup); canvas.SaveLayer(); canvas.Graphics.Dispose(); }
public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool) { mouseDown = true; if (tool is Pipette) { ((Pipette)tool).changeColor(pen.Color, pen, point, canvas); } }
public void OnMouseUp(AbstractFigure figure, ActionParamter paramter) { if (figure != null && figure.CheckDraw()) { Canvas.Instanse.AddFigure(figure); } Canvas.Instanse.SetBitmap(Canvas.Instanse.GetTempBitmap()); }
public string Serialaze(AbstractFigure figure) { JArray jArray = new JArray(); jArray.Add("RightTriangle"); jArray.Add(JsonConvert.SerializeObject((RightTriangleFigure)figure)); return(jArray.ToString()); }
public string Serialaze(AbstractFigure figure) { JArray jArray = new JArray(); jArray.Add("NPointsFigure"); jArray.Add(JsonConvert.SerializeObject((NPointsFigure)figure)); return(jArray.ToString()); }
public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool) { mouseDown = true; if (tool is MinusLens) { ((MinusLens)tool).zoom(canvas, point); } }
public void MoveFigureSquareTest(AbstractFigure figure, PointF delta, PointF[] expected) { figure.Move(delta); PointF[] actual = figure.GetPoints(); CollectionAssert.AreEqual(expected, actual); }
public void Create(AbstractFigure item) { if (item == null) { throw new ArgumentNullException(); } _listFigure.Add(item); }
public void MouseUpHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool) { mouseDown = false; //if (ModifiedFigure != null) //{ // figures.Insert(_modifiedFigureIndex, ModifiedFigure); //} //canvas.SaveLayer(); }
public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas) { if (_mouseDown) { canvas.CreateLayer(); canvas.Graphics.DrawPolygon(pen, figure.Update(point)); GC.Collect(); } }
private void UpdateFillerOfFigure(AbstractFigure figure) { var points = figure.GetFillerPoints(); foreach (var point in points) { SetSymbol(FillerSymbol, point); } }
public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas) { if (_mouseDown) { figure.Update(point); canvas.CreateLayer(); GC.Collect(); } }
public void MoveVertexSquareTest(AbstractFigure figure, PointF touchPoint, PointF delta, PointF[] expected) { figure.IsThisVertex(touchPoint); figure.MoveVertex(delta); PointF[] actual = figure.GetPoints(); CollectionAssert.AreEqual(expected, actual); }
public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas) { _mouseDown = true; if (_mouseDoubleDown == false) { figure.Update(point); canvas.SaveLayer(); GC.Collect(); } }
public void OnMouseDown(out AbstractFigure figure, ActionParamter paramter) { var p = paramter; figure = p.Factory.CreateFigure(); figure.Color = p.Color; figure.Width = p.Width; figure.DoStart(p.Point); //return new EmptyActionResult(); }
public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas) { if (_mouseDown) { PointF prevPoint = figure.Points[figure.Points.Count - 1]; figure.Update(point); canvas.Graphics.DrawLine(pen, prevPoint, point); GC.Collect(); } }
public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool) { if (mouseDown && ModifiedFigure != null) { switch (mode) { case "Move": { canvas.CreateLayer(); PointF delta = new PointF(point.X - _pullStartPoint.X, point.Y - _pullStartPoint.Y); if (tool is HandTool) { ((HandTool)tool).Move(delta, ModifiedFigure.Markup); } _pullStartPoint = point; canvas.Graphics.DrawPath(pen, ModifiedFigure.Markup); GC.Collect(); break; } case "Rotate": { canvas.CreateLayer(); PointF delta = new PointF(point.X - _pullStartPoint.X, point.Y - _pullStartPoint.Y); if (tool is HandTool) { ((HandTool)tool).Rotate(delta, ModifiedFigure.CentrePoint, ModifiedFigure.Markup); } _pullStartPoint = point; canvas.Graphics.DrawPath(pen, ModifiedFigure.Markup); GC.Collect(); break; } case "Resize": { // Draw the rectangle to the screen before applying the // transform. //canvas.CreateLayer(); //// Create a matrix and scale it. //Matrix myMatrix = new Matrix(); //myMatrix.Scale(2, 2, MatrixOrder.Append); ////// Draw the rectangle to the screen again after applying the ////// transform. //ModifiedFigure.Markup.Transform(myMatrix); //canvas.Graphics.DrawPath(pen, ModifiedFigure.Markup); ////e.Graphics.DrawRectangle(myPen2, 50, 50, 100, 100); break; } } } }
protected override void UpdateFigureView(AbstractFigure figure) { UpdateFillerOfFigure(figure); var contouesPoints = figure.GetСontoursPoints(); foreach (var point in contouesPoints) { SetSymbol(СontourSymbol, point); } }
private void DrawAllAseptModified(Pen pen, Canvas canvas, AbstractFigure figure, Container figures) { Bitmap Tmp = new Bitmap(canvas.MainBitmap.Width, canvas.MainBitmap.Height); canvas.Graphics = Graphics.FromImage(Tmp); for (int i = 0; i < figures.Length; i++) { canvas.Graphics.DrawPath(pen, figures[i].Markup); } canvas.MainBitmap = Tmp; }
private void lvFigures_SelectedIndexChanged(object sender, EventArgs e) { ReadrawSelected(); if (lvFigures.SelectedIndices.Count > 0) { int ind = 0; ind = lvFigures.SelectedIndices[0]; SelectedFig = FigList.GetItem(ind); MarkFigure(SelectedFig); } }
public void OnMouseMove(AbstractFigure figure, ActionParamter paramter) { if (figure != null) { Color color = figure.Color; int width = figure.Width; figure.Points[indPoint] = paramter.Point; figure.Mover.MoveFigure(color, width, figure.Points.ToArray()); } Canvas.Instanse.GetBitmap(); }
private void btnChangeFig_Click(object sender, EventArgs e) { if (SelectedFig != null) { SelectedFig.ChangeColor(PenColor.Color); SelectedFig.Draw(); MainView.Image = Canvas; SelectedFig = null; lvFigures.SelectedIndices.Clear(); } }
public void ClearPos() { PrevPos.X = -1; PrevPos.Y = -1; ChosenFigure = null; if (ImFigure != null) { ImFigure.Remove(Canva); ImFigure = null; } }