public void TestValidConstruction() { Shape shape1 = new Point("Point1", "Red", 1, 2); Shape2d shape2d = shape1; Assert.AreEqual("Point1", shape2d.name); Assert.AreEqual("Red", shape2d.color); }
public override void OnDeactivate() { if (_selectedShape != null) { log.Debug("EditAction deactivate"); _selectedShape.EndDragging(); _selectedShape.Deselect(); _selectedShape = null; } }
public void TestValidConstruction2() { Shape p1 = new Point("Point1", "Red", 1, 2); Shape p2 = new Point("Point2", "Blue", 3, 4); Shape L1 = new Line("Line1", "Black", (Point)p1, (Point)p2); Shape2d Line2d = L1; Assert.AreEqual("Line1", Line2d.name); Assert.AreEqual("Black", Line2d.color); }
public void TestMethod1() { Shape myRectangle = new Rectangle("Rectangle1", "FusionBlue", 0, 0, 0, 1, 1, 1, 1, 0); Shape myRectangle2 = new Rectangle("Rectangle2", "FusionGreen", 0, 0, 0, 1, 1, 1, 1, 0); Shape p1 = new Point("Point1", "Red", 1, 2); Shape p2 = new Point("Point2", "Blue", 3, 4); Shape2d rect2d = myRectangle; Shape2d rect2d2 = myRectangle2; Shape2d p12d = p1; Shape2d p22d = p2; Shape2d Jumble = new CompositeShape("Jumble", "grey"); Jumble.Add(rect2d); Jumble.Add(p12d); Jumble.Add(p22d); Jumble.Add(rect2d2); List <Shape2d> _myShapes = Jumble.GetMyShapes(); Assert.AreEqual(_myShapes[0].GetData(), rect2d.GetData()); Assert.AreEqual(_myShapes[1].GetData(), p12d.GetData()); Assert.AreEqual(_myShapes[2].GetData(), p22d.GetData()); Assert.AreEqual(_myShapes[3].GetData(), rect2d2.GetData()); Assert.AreEqual(_myShapes.Count, 4); Assert.AreEqual(Jumble.ComputeArea(), 2 * myRectangle.ComputeArea()); Jumble.Add(rect2d); Assert.AreEqual(Jumble.ComputeArea(), 2 * myRectangle.ComputeArea()); Jumble.Remove(rect2d); Assert.AreEqual(_myShapes.Count, 3); Jumble.Remove(rect2d); Assert.AreEqual(_myShapes.Count, 3); Jumble.Remove(p12d); Assert.AreEqual(_myShapes.Count, 2); Jumble.Remove(p22d); Assert.AreEqual(_myShapes.Count, 1); Jumble.Remove(rect2d2); Assert.AreEqual(_myShapes.Count, 0); Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); Jumble.Add(p12d); Assert.AreEqual(_myShapes.Count, 2); Jumble.Move(1, 1); Jumble.RemoveAll(); Assert.AreEqual(_myShapes.Count, 0); Jumble.Add(Jumble); Jumble.Add(rect2d); Jumble.Add(p12d); Assert.AreEqual(Jumble.GetData(), "Rectangle1 FusionBlue 1 1 1 2 2 2 2 1 Point1 Red 2 3 "); }
public void TestVoidFunctions() { Shape myRectangle = new Rectangle("Rectangle1", "Fusion Blue", 0, 0, 0, 1, 1, 1, 1, 0); Shape p1 = new Point("Point1", "Red", 1, 2); Shape p2 = new Point("Point2", "Blue", 3, 4); Shape2d rect2d = myRectangle; rect2d.Add(p1); rect2d.Add(p2); rect2d.Remove(p1); rect2d.Remove(p2); }
public void TestMethod1() { string[] parseList = { "Point", "name", "colour", "0", "1" }; Shape2dFactory myShape2DFactory = new Shape2dFactory(); Shape2d myPoint = myShape2DFactory.GetShape2D(parseList); Assert.AreEqual(myPoint.color, "colour"); Assert.AreEqual(myPoint.name, "name"); string[] parseList2 = { "Line", "name1", "colour1", "0", "1", "10", "10" }; Shape2d myLine = myShape2DFactory.GetShape2D(parseList2); Assert.AreEqual(myLine.color, "colour1"); Assert.AreEqual(myLine.name, "name1"); string[] parseList3 = { "Circle", "name2", "colour2", "0", "1", "10", }; Shape2d myCircle = myShape2DFactory.GetShape2D(parseList3); Assert.AreEqual(myCircle.color, "colour2"); Assert.AreEqual(myCircle.name, "name2"); string[] parseList4 = { "Ellipse", "name3", "colour3", "0", "0", "0", "1", "2", "1", "2", "0" }; Shape2d myEllipse = myShape2DFactory.GetShape2D(parseList4); Assert.AreEqual(myEllipse.color, "colour3"); Assert.AreEqual(myEllipse.name, "name3"); string[] parseList5 = { "Square", "name4", "colour4", "0", "0", "0", "1", "1", "1", "1", "0" }; Shape2d mySquare = myShape2DFactory.GetShape2D(parseList5); Assert.AreEqual(mySquare.color, "colour4"); Assert.AreEqual(mySquare.name, "name4"); string[] parseList6 = { "Rectangle", "name5", "colour5", "0", "0", "0", "1", "1", "1", "1", "0" }; Shape2d myRectangle = myShape2DFactory.GetShape2D(parseList6); Assert.AreEqual(myRectangle.color, "colour5"); Assert.AreEqual(myRectangle.name, "name5"); string[] parseList7 = { "Triangle", "name6", "colour6", "0", "0", "0", "1", "1", "1" }; Shape2d myTriangle = myShape2DFactory.GetShape2D(parseList7); Assert.AreEqual(myTriangle.color, "colour6"); Assert.AreEqual(myTriangle.name, "name6"); }
public void TestMethod1() { Script myScript = new Script(); string path = "C:\\Users\\Camron Martinez\\Desktop\\Current OO Homework\\HW3\\HW3-OO\\Minimal (c-sharp)\\ShapesTests\\Point.txt"; FileStream myStream = File.OpenRead(path); Shape2d myShape = myScript.Load(myStream); Assert.AreEqual(myShape.color, "Colour"); Assert.AreEqual(myShape.name, "Name"); MemoryStream myMemoryStream = myScript.Save(myShape); StreamWriter writer = new StreamWriter(myMemoryStream); using (FileStream fs = new FileStream("output.txt", FileMode.OpenOrCreate)) { myMemoryStream.CopyTo(fs); fs.Flush(); } }
public static void AddShape(Node rootNode, Shape2d shape) { var list = shape.GetMagicPoints(); if (list != null) { OCgp_Pnt previousPoint = new OCgp_Pnt(); bool secondPoint = false; foreach (OCgp_Pnt point in list) { AddVertex(rootNode, point); // After the secodn point start calculating the mid points if (secondPoint == true) { AddVertex(rootNode, ComputeMidPoint(previousPoint, point)); } previousPoint = point; secondPoint = true; } } }
protected override void OnReceiveInputData(string inputName, object data) { if (inputName == ActionNames.EditDetectionPipe) { _selectedShape = data as Shape2d; } else { base.OnReceiveInputData(inputName, data); } // A shape must be selected if ((_occMousePosition == null) || (_selectedShape == null)) { return; } // The input was processed in the base class, just use the coordinates received if (inputName == ActionNames.SolverDrawerPipe) { OnMouseClick3dAction(_occMousePosition); } }
protected override void SourceOnData(object data) { // Check if the pipe is enabled if (!_enableEditDetectionPipe) { return; } var mouseData = data as Mouse3dPosition; // Filter the mouse events, only mouse down is passing if (!mouseData.IsMouseDown) { return; } // Filter also the shape dragging if (_selectedShape != null) { if (_selectedShape.CanDrag(mouseData.Point.X(), mouseData.Point.Y())) { return; } if (_selectedShape.IsDragging) { return; } } // Retrieve the selected shapes and enable the markers for them bool shapeSelected = false; _selectedShape = null; foreach (Shape2d shape2d in _drawnShapesList) { int nb = _context2d.NbSelected(); if (_context2d.IsSelected(shape2d)) { shape2d.Select(); _selectedShape = shape2d; _context2d.AddOrRemoveSelected(shape2d, false); shapeSelected = true; } else { shape2d.Deselect(); } shape2d.EndDragging(); } if (shapeSelected) { log.Debug("EditDetectionPipe shape selected"); // Inform the action controller that it can switch to edit mode ActivateActionHandler(ActionType.Action2d_EditShape, true); // Notify listeners that a new selected shape is found AddData(_selectedShape); } else { //log.Debug("EditDetectionPipe unselect shape"); //ActivateActionHandler(ActionType.Action2d_EditShape, false); } _view2d.Update(); }