static void Main(string[] args) { Point2D zPoint = new Point2D(new List<Coordinate>(){ new Coordinate(5), new Coordinate(5) }); ZShape z = new ZShape(zPoint); var axes = AxisParser.Parse("axes.xml"); z.Rotate(axes[0]); z.Rotate(axes[1]); Mover2D mover2D = new Mover2D(); Direction negativeDirection = new Direction(DirectionType.Negative); foreach (Point2D item in z.Points) { Console.WriteLine("(" + item.X.Value + ", " + item.Y.Value + ")"); } mover2D.Move(z, axes[0], negativeDirection); Console.WriteLine("-----------------"); foreach (Point2D item in z.Points) { Console.WriteLine("(" + item.X.Value + ", " + item.Y.Value + ")"); } Console.WriteLine("------------------------"); ShapeFactory factory = new ShapeFactory(); var newShape = factory.CreateShape(new Point2D(new List<Coordinate>() { new Coordinate(10), new Coordinate(8) })); foreach (Point2D item in newShape.Points) { Console.WriteLine("(" + item.X.Value + ", " + item.Y.Value + ")"); } }
static void CreateProjectUsingEditor() { var project = new ProjectFactory().GetProject(); var editor = Editor.Create(project, null, false, false); var factory = new ShapeFactory(editor); factory.Line(30, 30, 60, 30); factory.Text(30, 30, 60, 60, "Sample2"); Project.Save(project, "sample2.project", new NewtonsoftSerializer()); }
public void TriangleFromSides(double firstSide, double secondSide, double thirdSide, bool shouldFail) { if (!shouldFail) { ShapeFactory.TriangleFromSides(firstSide, secondSide, thirdSide).Should().NotBeNull(); ShapeFactory.TriangleFromSides(thirdSide, firstSide, secondSide).Should().NotBeNull(); ShapeFactory.TriangleFromSides(secondSide, thirdSide, firstSide).Should().NotBeNull(); } else { CreateTriangleFromSides(firstSide, secondSide, thirdSide).Should().Throw <ArgumentException>(); CreateTriangleFromSides(thirdSide, firstSide, secondSide).Should().Throw <ArgumentException>(); CreateTriangleFromSides(secondSide, thirdSide, firstSide).Should().Throw <ArgumentException>(); } }
public void ErzeugeBalken(Double l) { // Hauptkoerper in Bearbeitung definieren hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody; // Block(Balken) erzeugen ShapeFactory catShapeFactory1 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory; Pad catPad1 = catShapeFactory1.AddNewPad(hsp_catiaProfil, l); // Block umbenennen catPad1.set_Name("Balken"); // Part aktualisieren hsp_catiaPart.Part.Update(); }
static void TestShapeFactory() { var shapeFactory = new ShapeFactory(); var shapes = new Shape[3]; shapes[0] = shapeFactory.CreateShape(ShapeTypes.Circle); shapes[1] = shapeFactory.CreateShape(ShapeTypes.Rectangle); shapes[2] = shapeFactory.CreateShape(ShapeTypes.Square); foreach (var shape in shapes) { shape.Draw(); } }
private static void Main(string[] args) { DependencyInyection(); var cube1 = ShapeFactory.Create(_intersectionService, new CubeDimensions(new X(0), new Y(0), new Side(10))); var cube2 = ShapeFactory.Create(_intersectionService, new CubeDimensions(new X(5), new Y(5), new Side(7))); Console.WriteLine("Shape Intersection"); Console.WriteLine($"-----------------"); Console.WriteLine($"Shape 1: {cube1}"); Console.WriteLine($"Shape 2: {cube2}"); Console.WriteLine(); Console.WriteLine($"Intersection result: \n"); Console.WriteLine($"\t{cube1.IntersectWith(cube2)}"); Console.ReadKey(); }
public CutterPanel() { System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; Thread.CurrentThread.CurrentCulture = customCulture; InitializeComponent(); MessageBox.Visibility = Visibility.Hidden; _motionCommands.Add(Calibration); _motionCommands.Add(GoToZeros); _motionCommands.Add(AlignHeads); _motionCommands.Add(StartPlan); _motionCommands.Add(CuttingDeltaT); Cnc = new DriverCNC(); Cnc.OnConnectionStatusChange += () => Dispatcher.Invoke(refreshConnectionStatus); Cnc.OnHomingEnded += () => Dispatcher.Invoke(enableMotionCommands); Cnc.Initialize(); CoordController = new Coord2DController(Cnc); _messageTimer.Interval = TimeSpan.FromMilliseconds(_messageShowDelay); _messageTimer.IsEnabled = false; _messageTimer.Tick += _messageTimer_Tick; _statusTimer.Interval = TimeSpan.FromMilliseconds(20); _statusTimer.Tick += _statusTimer_Tick; _statusTimer.IsEnabled = true; _autosaveTime.IsEnabled = false; _autosaveTime.Interval = TimeSpan.FromMilliseconds(1000); _autosaveTime.Tick += _autosaveTime_Tick; KeyUp += keyUp; KeyDown += keyDown; ContextMenu = createWorkspaceMenu(); resetWorkspace(true); initializeTransitionHandlers(); _factory = new ShapeFactory(this); /*/ OpenEditor_Click(null, null); this.Hide(); /**/ }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); SurfacePolygons surfacePolygons = Cache <SurfacePolygons> .GetItem("physicsplayGround.png"); foreach (Vector2D[] vertexes in surfacePolygons.Polygons) { Vector2D[] processed = vertexes; for (int index = 1; index < 4; index++) { processed = VertexHelper.Reduce(processed, index); } processed = VertexHelper.Subdivide(processed, 16); IShape shape = ShapeFactory.CreateColoredPolygon(processed, 10); DemoHelper.AddShape(DemoInfo, shape, Scalar.PositiveInfinity, new ALVector2D(0, surfacePolygons.Offset)).IgnoresGravity = true; } for (int x = 440; x < 480; x += 10) { for (int y = -2000; y < 0; y += 12) { Body body = DemoHelper.AddCircle(DemoInfo, 5, 7, 3, new ALVector2D(0, x + DemoHelper.NextScalar(-400, 400), y)); body.Updated += delegate(object sender, UpdatedEventArgs e) { if (body.State.Position.Linear.Y > 900) { body.State.Position.Linear.Y = -100; } }; } } for (int x = 490; x < 510; x += 10) { for (int y = -550; y < -500; y += 12) { Body body = DemoHelper.AddRectangle(DemoInfo, 10, 20, 10, new ALVector2D(0, x + DemoHelper.NextScalar(-400, 400), y)); body.Updated += delegate(object sender, UpdatedEventArgs e) { if (body.State.Position.Linear.Y > 900) { body.State.Position.Linear.Y = -100; } }; } } }
private void btnAddShape_Click(object sender, EventArgs e) { Shape3D newShape = null; string shape = cboxShape.SelectedItem.ToString(); try { newShape = ShapeFactory.Create(shape, _mType, Double.Parse(txtPara1.Text), Double.Parse(txtPara2.Text)); } catch (FormatException ef) { MessageBox.Show(ef.Message); } catch (NegativeException en) { MessageBox.Show(en.Message); } finally { if (newShape != null) { shapeArr.Add(newShape); txtAmountOfShape.Text = Shape3D.Amount.ToString(); txtBallAmount.Text = Ball.Amount.ToString(); txtCubeAmount.Text = Cube.Amount.ToString(); txtCylinderAmount.Text = Cylinder.Amount.ToString(); txtPyramidAmount.Text = Pyramid.Amount.ToString(); ShowAllShapeInfo(txtMessage); } } //switch (shape) //{ // case "球": // shapeArr.Add(new Ball(Double.Parse(txtPara1.Text), _mType)); // new 出 Ball 物件, 並將其加入 shapeArr中 // break; // case "立方體": // shapeArr.Add(new Cube(Double.Parse(txtPara1.Text), _mType)); // break; // case "圓柱體": // shapeArr.Add(new Cylinder(Double.Parse(txtPara1.Text), Double.Parse(txtPara2.Text), _mType)); // break; // case "金字塔": // shapeArr.Add(new Pyramid(Double.Parse(txtPara1.Text), Double.Parse(txtPara2.Text), _mType)); // break; // default: // break; //} }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Vector2D gravityCenter = new Vector2D(500, 500); Scalar gravityPower = 200; Scene.Engine.AddLogic(new GravityPointField(gravityCenter, gravityPower, new Lifespan())); DemoHelper.AddRagDoll(DemoInfo, gravityCenter + new Vector2D(0, -20)); Scalar length = 41; Scalar size = 8 ; bool reverse = false; for (Scalar distance = 250; distance < 650; length += 10, size *= 2, distance += 60 + length) { Scalar da = MathHelper.TwoPi / size;// ((MathHelper.TWO_PI * distance) / size); Scalar l2 = length / 2; // da /= 2; Vector2D[] vertexes = new Vector2D[] { Vector2D.FromLengthAndAngle(distance - l2, da / 2), Vector2D.FromLengthAndAngle(distance - l2, -da / 2), Vector2D.FromLengthAndAngle(distance + l2, -da / 2), Vector2D.FromLengthAndAngle(distance + l2, da / 2), }; //da *= 2; Vector2D[] vertexes2 = VertexHelper.CenterVertexes(vertexes); vertexes = VertexHelper.Subdivide(vertexes2, 5); PolygonShape shape = ShapeFactory.CreateColoredPolygon(vertexes, 1.5f); for (Scalar angle = 0; angle < MathHelper.TwoPi; angle += da) { Vector2D position = Vector2D.FromLengthAndAngle(distance, angle) + gravityCenter; Body body = DemoHelper.AddShape(DemoInfo, shape, (size * length) / 10, new ALVector2D(angle, position)); body.State.Velocity.Linear = DemoHelper.GetOrbitVelocity(gravityCenter, Vector2D.FromLengthAndAngle(distance - length, angle) + gravityCenter, gravityPower); body.State.Velocity.Linear *= .5f; body.State.Velocity.Angular = -(body.State.Velocity.Linear.Magnitude) / (distance);// *(1 / MathHelper.TWO_PI); if (reverse) { body.State.Velocity.Linear = -body.State.Velocity.Linear; body.State.Velocity.Angular = -body.State.Velocity.Angular; } } reverse = !reverse; } }
protected override void Open() { Scene.IsPaused = true; List <Body> bodies = new List <Body>(); Body b = DemoHelper.AddLine(DemoInfo, new Vector2D(300, 200), new Vector2D(400, 200), 40, Scalar.PositiveInfinity); b.IgnoresPhysicsLogics = true; bodies.Add(b); Body b2 = DemoHelper.AddCircle(DemoInfo, 20, 40, Scalar.PositiveInfinity, new ALVector2D(0, 300, 100)); b2.IgnoresPhysicsLogics = true; bodies.Add(b2); Body b3 = DemoHelper.AddCircle(DemoInfo, 20, 40, 50, new ALVector2D(0, 100, 100)); bodies.Add(b3); Body b4 = DemoHelper.AddRectangle(DemoInfo, 20, 20, 20, new ALVector2D(0, 150, 150)); bodies.Add(b4); dispose += RegisterDup(DemoInfo, bodies); DemoHelper.AddShell(DemoInfo, new BoundingRectangle(0, 0, 200, 200), 10, Scalar.PositiveInfinity).ForEach(delegate(Body sb) { sb.IgnoresPhysicsLogics = true; }); Body bStart = DemoHelper.AddShape(DemoInfo, ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("start.png"), 2, 16, 3), Scalar.PositiveInfinity, new ALVector2D(0, 100, 650)); // Body bStart = DemoHelper.AddLine(DemoInfo, new Vector2D(10, 600), new Vector2D(100, 600), 40, Scalar.PositiveInfinity); bStart.IgnoresPhysicsLogics = true; Body bStop = DemoHelper.AddShape(DemoInfo, ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("stop.png"), 2, 16, 3), Scalar.PositiveInfinity, new ALVector2D(0, 100, 700)); //Body bEnd = DemoHelper.AddLine(DemoInfo, new Vector2D(10, 700), new Vector2D(100, 700), 40, Scalar.PositiveInfinity); bStop.IgnoresPhysicsLogics = true; Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); dispose += DemoHelper.RegisterClick(DemoInfo, bStart, MouseButton.PrimaryButton, delegate(object sender, EventArgs e) { Scene.IsPaused = false; }); dispose += DemoHelper.RegisterClick(DemoInfo, bStop, MouseButton.PrimaryButton, delegate(object sender, EventArgs e) { Scene.IsPaused = true; }); }
public void SonderU_Extrusion(double SonderU_Laenge, double Flanschbreite) { double l = SonderU_Laenge; double f = Flanschbreite; double R1 = f; // Definition der Eckenradien nach DIN 1026-1 double R2 = R1 / 2; CATIA_SonderU_Part.Part.InWorkObject = CATIA_SonderU_Part.Part.MainBody; ShapeFactory SonderU_3D = (ShapeFactory)CATIA_SonderU_Part.Part.ShapeFactory; Pad SonderU_Pad = SonderU_3D.AddNewPad(CATIA_SonderU_2D, l); // Kantenverrundung #1 für R1 Reference Referenz11_R1 = CATIA_SonderU_Part.Part.CreateReferenceFromName(""); ConstRadEdgeFillet Verrundung1_R1 = SonderU_3D.AddNewEdgeFilletWithConstantRadius(Referenz11_R1, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R1); Reference Referenz21_R1 = CATIA_SonderU_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;4)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderU_Pad); Verrundung1_R1.AddObjectToFillet(Referenz21_R1); Verrundung1_R1.set_Name("Verrundung1_R1 = " + R1); // Kantenverrundung #2 für R1 Reference Referenz12_R1 = CATIA_SonderU_Part.Part.CreateReferenceFromName(""); ConstRadEdgeFillet Verrundung2_R1 = SonderU_3D.AddNewEdgeFilletWithConstantRadius(Referenz12_R1, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R1); Reference Referenz22_R1 = CATIA_SonderU_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;5)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;4)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderU_Pad); Verrundung2_R1.AddObjectToFillet(Referenz22_R1); Verrundung2_R1.set_Name("Verrundung2_R1 = " + R1); // Kantenverrundung #1 für R2 Reference Referenz11_R2 = CATIA_SonderU_Part.Part.CreateReferenceFromName(""); ConstRadEdgeFillet Verrundung1_R2 = SonderU_3D.AddNewEdgeFilletWithConstantRadius(Referenz11_R2, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R2); Reference Referenz21_R2 = CATIA_SonderU_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;2)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderU_Pad); Verrundung1_R2.AddObjectToFillet(Referenz21_R2); Verrundung1_R2.set_Name("Verrundung1_R2 = " + R2); // Kantenverrundung #2 für R2 Reference Referenz12_R2 = CATIA_SonderU_Part.Part.CreateReferenceFromName(""); ConstRadEdgeFillet Verrundung2_R2 = SonderU_3D.AddNewEdgeFilletWithConstantRadius(Referenz12_R2, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R2); Reference Referenz22_R2 = CATIA_SonderU_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;6)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;5)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderU_Pad); Verrundung2_R2.AddObjectToFillet(Referenz22_R2); Verrundung2_R2.set_Name("Verrundung2_R2 = " + R2); SonderU_Pad.set_Name("U-Profiltraeger"); CATIA_SonderU_Part.Part.Update(); }
public void Intersect_With_Another_Cube(float x1, float y1, float side1, float x2, float y2, float side2) { //Arrange var cubeDimensions1 = new CubeDimensions(new X(x1), new Y(y1), new Side(side1)); var cubeDimensions2 = new CubeDimensions(new X(x2), new Y(y2), new Side(side2)); var intersectionService = new IntersectionService(); var cube1 = ShapeFactory.Create(intersectionService, cubeDimensions1); var cube2 = ShapeFactory.Create(intersectionService, cubeDimensions2); //Act var shapeIntersection = cube1.IntersectWith(cube2); //Assert shapeIntersection.ToString().Should().Be($"Intersection result of a Cube (X = {x1}, Y = {y1}, Side = {side1}) with a Cube (X = {x2}, Y = {y2}, Side = {side2})"); }
private void respawnShapeTimer_Tick(object sender, EventArgs e) { if (shape.IsCollidingPictureBoxBottom(pictureBox1.Bottom) || shape.IsCollidingAnotherShape(shapes)) { shape.OnShapeMovement(Direction.Down, State.Idle); shapes.Add(shape); shape.NextShape = ShapeFactory.CreateRandomShape(); shape = shape.NextShape; } else { shape.OnShapeMovement(Direction.Down, State.Active); } pictureBox1.Invalidate(); }
//Erzeugen der Extrusion für RechteckHohl internal void ErzeugeExtrusionRechteckHohl(RechteckHohl rechteckHohl) { hspB1_catiaPart.Part.InWorkObject = hspB1_catiaPart.Part.MainBody; // Extrusion erzeugen ShapeFactory catShapeFactory1 = (ShapeFactory)hspB1_catiaPart.Part.ShapeFactory; Pad catPad1 = catShapeFactory1.AddNewPad(hspB1_catia_Profil, rechteckHohl.Länge); // Block umbenennen catPad1.set_Name("Profil Rechteck hohl"); // Part aktualisieren hspB1_catiaPart.Part.Update(); }
public GeometryFactory GetFactory(GeometryType geometryType) { GeometryFactory geometryFactory = null; switch (geometryType) { case GeometryType.Shape: geometryFactory = new ShapeFactory(); break; case GeometryType.Color: geometryFactory = new ColorFactory(); break; } return(geometryFactory); }
public override void Load(StreamReader sr, ShapeFactory sf) { groupShapes.Clear(); var count = Convert.ToInt32(sr.ReadLine().Split('=')[1]); isSticky = Convert.ToBoolean(sr.ReadLine().Split('=')[1]); Shape shape; for (int i = 0; i < count; i++) { var code = sr.ReadLine(); shape = sf.createShape(code); shape.Load(sr, sf); Add(shape); } }
public void SetColor(Material material) { if (material is null) { throw new ArgumentNullException(nameof(material)); } this.colorMaterial = material; MainThread.BeginInvokeOnMainThread(() => { this.AnchorNode.Renderable = null; this.nodeRenderable = ShapeFactory.MakeSphere(0.1f, new Vector3(0.0f, 0.15f, 0.0f), this.colorMaterial); this.AnchorNode.Renderable = this.nodeRenderable; }); }
private void btnRectangle_calculate_Click(object sender, EventArgs e) { // inputları al // hesap et // sonucu yaz double xAxis = Convert.ToDouble(txtRectangle_a.Text); double yAxis = Convert.ToDouble(txtRectangle_b.Text); Shape s1 = ShapeFactory.Instance().CreateShape(CalculateShape.Figure.Rectangle, xAxis, yAxis); double perimeter = s1.getPerimeter(); double area = s1.getArea(); txtRectangle_perimeter.Text = perimeter.ToString(); txtRectangle_area.Text = area.ToString(); }
public void TestValidConstruction() { ShapeFactory sf = new ShapeFactory(); var rectangle = sf.MakeRectangle(1, 2, 5, 6); Assert.AreEqual(1, rectangle.Point1.X); Assert.AreEqual(2, rectangle.Point1.Y); Assert.AreEqual(5, rectangle.Point2.X); Assert.AreEqual(6, rectangle.Point2.Y); rectangle = sf.MakeRectangle(1.22, 8.87, 12.1, 13.52); Assert.AreEqual(1.22, rectangle.Point1.X); Assert.AreEqual(8.87, rectangle.Point1.Y); Assert.AreEqual(12.1, rectangle.Point2.X); Assert.AreEqual(13.52, rectangle.Point2.Y); }
public static void Copy_ReferencesOriginalMesh() { var original = ShapeFactory.Instantiate <Cube>(); var copy = UObject.Instantiate(original); try { Assert.AreNotEqual(copy, original, "GameObject references are equal"); Assert.IsTrue(ReferenceEquals(copy.mesh, original.mesh), "Mesh references are equal"); } finally { UObject.DestroyImmediate(original.gameObject); UObject.DestroyImmediate(copy.gameObject); } }
static void Main(string[] args) { ShapeFactory shapeFactory = new ShapeFactory(); Shape circle = shapeFactory.getShape("Circle"); circle.draw(); Shape rectangle = shapeFactory.getShape("Rectangle"); rectangle.draw(); Shape square = shapeFactory.getShape("Square"); square.draw(); }
public static void Main(string[] args) { ShapeFactory shapeFactory = new ShapeFactory(); IShape shape1 = shapeFactory.getShape("CIRCLE"); shape1.Draw(); IShape shape2 = shapeFactory.getShape("RECTANGLE"); shape2.Draw(); IShape shape3 = shapeFactory.getShape("SQUARE"); shape3.Draw(); }
public void OutOfRangeInput() { IShapeFactory shapeFactory = new ShapeFactory(); Shape shape; double width = 5; try { shape = shapeFactory.CreateShape((ShapeTypeEnum)0, width); } catch (Exception ex) { Assert.AreEqual(ex.GetType(), typeof(ArgumentOutOfRangeException)); } }
public static void Main(string[] args) { ShapeFactory shapeFactory = new ShapeFactory(); // get an object of Circle and call its draw method IShape shape1 = shapeFactory.GetShape("CIRCLE"); shape1.draw(); // get an object of Rectangle and call its draw method IShape shape2 = shapeFactory.GetShape("RECTANGLE"); shape2.draw(); // get an object of Square and call its draw method IShape shape3 = shapeFactory.GetShape("SQUARE"); shape3.draw(); }
public void ShouldReturnAllPossibleShapeTypes() { var expectedShapes = new List <string> { "Triangle", "Circle", "Rectangle", "Square" }; var shapeFactory = new ShapeFactory(); var shapes = shapeFactory.GetShapeTypes(); CollectionAssert.AreEqual(expectedShapes, shapes.ToList()); }
static void Main(string[] args) { var factory = new ShapeFactory(); // треугольник I2dShape triangle = factory.GetShape(ShapeType.Triangle, 3, 4, 5); Console.WriteLine("Triangle has square {0}, it's {1}a right angle triangle.", triangle.GetSquare(), ((Triangle)triangle).IsRightAngle == true ? "" : "not "); // круг I2dShape circle = factory.GetShape(ShapeType.Circle, 5.5); Console.WriteLine("Circle has square {0}", circle.GetSquare()); Console.ReadKey(); }
public static void Run() { ShapeFactory sf = new ShapeFactory(); var circle = sf.GetShape(ShapeFactory.CirCle); circle.draw(); var rectangle = sf.GetShape(ShapeFactory.Rectangle); rectangle.draw(); var square = sf.GetShape(ShapeFactory.Square); square.draw(); }
public static void DrawShapes() { IFactory factory = new ShapeFactory(); IShape firstShape = factory.GetShape(Shapes.Circle); IShape secondShape = factory.GetShape(Shapes.Line); IShape thirdShape = factory.GetShape(Shapes.Rectangle); IShape forthShape = factory.GetShape(Shapes.Triangle); Console.WriteLine(firstShape.Draw(10.0, 9.0)); Console.WriteLine(secondShape.Draw(20.5, 5.6)); Console.WriteLine(thirdShape.Draw(30.0, 0)); Console.WriteLine(forthShape.Draw(40.0, 1.1)); Console.ReadKey(); }
void Setup() { camera = new GameObject("Camera", typeof(Camera)).GetComponent <Camera>(); camera.transform.position = new Vector3(.3f, 2.2f, -3f); ProBuilderMesh shape = ShapeFactory.Instantiate <Torus>(); shape.transform.position = Vector3.zero - shape.GetComponent <MeshRenderer>().bounds.center; camera.transform.LookAt(shape.transform); selectables = new ProBuilderMesh[] { shape }; }
static void FactoryDemo() { ShapeFactory shapeFactory = new ShapeFactory(); Shape circle = shapeFactory.GetShape("CIRCLE"); circle.Draw(); Shape rectangle = shapeFactory.GetShape("RECTANGLE"); rectangle.Draw(); Shape square = shapeFactory.GetShape("SQUARE"); square.Draw(); }
void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } }
public void DrawingStateTest() { Shape shape = new ShapeFactory().CreateShape(ShapeType.Rectangle); shape.SetStartPoint(5, 5); shape.SetEndPoint(15, 15); _model = new Model(); _modelTarget = new PrivateObject(_model); _manager = (CommandManager)_modelTarget.GetField("_commandManager"); _shapes = (List <Shape>)_modelTarget.GetField("_shapes"); _state = new DrawingState(_model, _shapes); _target = new PrivateObject(_state); _isNotify = false; _model._modelChanged += Notify; Assert.AreEqual(StateType.Drawing, _state.StateType); }
static void CreateProjectUsingContext() { var context = new EditorContext() { ProjectFactory = new ProjectFactory(), Serializer = new NewtonsoftSerializer() }; var project = context.ProjectFactory.GetProject(); context.Editor = Editor.Create(project, null, false, false); var factory = new ShapeFactory(context.Editor); factory.Line(30, 30, 60, 30); factory.Text(30, 30, 60, 60, "Sample1"); context.Save("sample1.project"); }