/// <summary> /// Gets the fertile plots of land in ascending order as a single string /// </summary> /// <param name="plotsToSaltAsStrings">The plots to salt as a collection of strings, with each string representing an plot to salt</param> /// <returns>A single string containing the fertile plots, separated by a space, in ascending order</returns> public static string GetFertileLandsAsOrderedString(string[] plotsToSaltAsStrings) { _logger.Debug($"Entering {nameof(GetFertileLandsAsOrderedString)}"); var pointFactory = new PointFactory(); var rectangleFactory = new RectangleFactory(); var landFactory = new LandFactory(); var landDefinition = rectangleFactory.CreateRectangle(pointFactory, COLUMNS_OF_LAND, ROWS_OF_LAND); var land = landFactory.CreateLand(landDefinition); // Salt the land var plotsToSalt = plotsToSaltAsStrings.Select(plotToSaltAsString => rectangleFactory.CreateRectangle(pointFactory, plotToSaltAsString)); foreach (var plotToSalt in plotsToSalt) { land.AddSalt(plotToSalt); } // This line satisfies the output requirements string fertileLandAsOrderedString = string.Join(" ", land.FertilePlotsInSquareMeters.OrderBy(plot => plot)); _logger.Debug($"Exiting {nameof(GetFertileLandsAsOrderedString)} with a return value of \"{fertileLandAsOrderedString}\""); return(fertileLandAsOrderedString); }
static void Main(string[] args) { ShapeFactory rectangleFactory = new RectangleFactory(); ShapeFactory squareFactory = new SquareFactory(); ShapeFactory tritangleFactory = new TritangleFactory(); int allarea = 0; for (int i = 0; i < 10; i++) { Random random = new Random(); //在外面生成对象 int r = random.Next(1, 4); switch (r) { case 1: allarea += rectangleFactory.createShape().getarea(); Console.WriteLine("产生了一个长方形,面积为:{0}", rectangleFactory.createShape().getarea()); break; case 2: allarea += squareFactory.createShape().getarea(); Console.WriteLine("产生了一个正方形,面积为:{0}", squareFactory.createShape().getarea()); break; case 3: allarea += tritangleFactory.createShape().getarea(); Console.WriteLine("产生了一个三角形,面积为:{0}", tritangleFactory.createShape().getarea()); break; } } Console.WriteLine("十个形状总面积为:{0}", allarea); }
private void toolStripButtonRectangle_Click(object sender, EventArgs e) { CurrentFactory = new RectangleShapeFactory(); Factory current = new RectangleFactory(pnlMain); CurrentDrawman = current.FactoryMethod(); }
private void PatternsForm_Paint(object sender, PaintEventArgs e) { gs = e.Graphics; Map.Map.Graphics = e.Graphics; map.DrawMap(); foreach (IObjectBuilder bl in map.MapObjects) { if (bl is CircleBuilder) { bl.formGraphics = e.Graphics; (bl as CircleBuilder).DrawObject(); } else { bl.formGraphics = e.Graphics; (bl as RectangleBuilder).DrawObject(); } } if (!FormLoaded) { IUnitFactory factory = new CircleFactory(); for (int i = 0; i < 50; i++) { if (i > 25) { factory = new RectangleFactory(); } if (factory is CircleFactory) { IObjectBuilder cl = factory.ObjectBuilder as CircleBuilder; CircleBuilder temp = CircleBuilder.CopyCircle(cl as CircleBuilder); (cl as CircleBuilder).Draw(cl, map, Tasks); temp.Draw(temp, map, Tasks); } else { IObjectBuilder cl = factory.ObjectBuilder as Factory.Rectangle.RectangleBuilder; (cl as Factory.Rectangle.RectangleBuilder).Draw(cl, map, Tasks); } FormLoaded = true; } foreach (IObjectBuilder cl in map.MapObjects) { if (cl is CircleBuilder) { (cl as CircleBuilder)._thisObject.X = new Random(cl.GetHashCode()).Next(1, 1000); (cl as CircleBuilder)._thisObject.Y = new Random(cl.GetHashCode()).Next(1, 1000); } else { (cl as RectangleBuilder)._thisObject.X = new Random(cl.GetHashCode()).Next(1, 1000); (cl as RectangleBuilder)._thisObject.Y = new Random(cl.GetHashCode()).Next(1, 1000); } } } }
public void HandleEvent() { rectangleFactory = new RectangleFactory(); Canvas.CurFigureFactory = rectangleFactory; MouseEventArgs eMouse = (MouseEventArgs)E; Canvas.PrevPoint = new PointF(eMouse.X, eMouse.Y); }
public void TwoRectangle_DoOverlap_ShouldReturn() { var operation = new GeneralShapeOperation(); var rectangle1 = RectangleFactory.CreateByDimensions(0, 0, 3, 3); var rectangle2 = RectangleFactory.CreateByDimensions(2, 2, 3, 3); var result = operation.DoOverlap(rectangle1, rectangle2); result.Should().BeTrue(); }
public void Rectangle_CheckPolygonPoints_ShouldReturnProper(double x, double y, double width, double height, RectanglePolygonOperation.ShapeRelation expected) { Polygon polygon = CreateTestPolygon1(); var rectangle = RectangleFactory.CreateByDimensions(x, y, width, height); var operation = new RectanglePolygonOperation(); var result = operation.CheckPolygonPoints(rectangle, polygon); result.Should().Be(expected); }
public void TestGetHeight() { ShapeFactory sf = new RectangleFactory(); Shapes.Rectangle rectangle = (Shapes.Rectangle)sf.Create2dShape(); rectangle.Point1.X = 2; rectangle.Point1.Y = 2; rectangle.Point2.X = 4; rectangle.Point2.Y = 4; Assert.AreEqual(2, rectangle.GetHeight()); }
public void TestComputeArea() { ShapeFactory sf = new RectangleFactory(); Shapes.Rectangle rectangle = (Shapes.Rectangle)sf.Create2dShape(); rectangle.Point1.X = 0; rectangle.Point1.Y = 0; rectangle.Point2.X = 5; rectangle.Point2.Y = 6; Assert.AreEqual(30, rectangle.ComputeArea(), 0); }
private void btnCreate_Click(object sender, EventArgs e) { if (cmboShapeType.SelectedItem is null) { errorMessage("Please select a type of shape"); } else if (ValidateInfo()) { ShapeFactory factory = null; switch (cmboShapeType.SelectedItem.ToString()) { case "Circle": Shapes.Point CirclePoint = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); factory = new CircleFactory(CirclePoint, Int32.Parse(txtRadius1.Text)); break; case "Ellipse": Shapes.Point EllipsePoint = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); factory = new EllipseFactory(EllipsePoint, Int32.Parse(txtRadius1.Text), Int32.Parse(txtRadius2.Text)); break; case "Rectangle": Shapes.Point RectanglePoint = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); factory = new RectangleFactory(RectanglePoint, Int32.Parse(txtRadius1.Text), Int32.Parse(txtRadius2.Text)); break; case "Square": Shapes.Point SquarePoint = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); factory = new SquareFactory(SquarePoint, Int32.Parse(txtRadius1.Text)); break; case "Triangle": Shapes.Point TriPoint1 = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); Shapes.Point TriPoint2 = new Shapes.Point(Int32.Parse(txtPoint2X.Text), Int32.Parse(txtPoint2Y.Text)); Shapes.Point TriPoint3 = new Shapes.Point(Int32.Parse(txtPoint3X.Text), Int32.Parse(txtPoint3Y.Text)); factory = new TriangleFactory(TriPoint1, TriPoint2, TriPoint3); break; case "Composite Image": factory = new CompositeImageFactory(filepath); break; case "Embedded Pic": Shapes.Point EmbeddedPoint = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); factory = new EmbeddedPicFactory(EmbeddedPoint, Int32.Parse(txtRadius1.Text), Int32.Parse(txtRadius2.Text), filepath); break; } Shape shape = factory.GetShape(); Console.WriteLine(shape.ShapeType); shapeToDraw = shape; this.Close(); } }
public Analysis() { InitializeComponent(); Factory = new RectangleFactory(); ListCountry.DisplayMember = "Country"; ListCountry2.DisplayMember = "Country"; SearchCountry(); SearchCountry2(); Charts(); }
public void TestDrawRectangle() { ERectangle rectangle = RectangleFactory.GetRectangle(); rectangle.FirstpointXCoordinate = 40; rectangle.FirstpointYCoordinate = 40; rectangle.SecondpointXCoordinate = 60; rectangle.SecondpointYCoordinate = 60; IRectangleOperation rectangleOperation = RectangleOperationFactory.GetRectangleOperation(); rectangleOperation.Draw(rectangle); }
public void TestValidConstruction() { ShapeFactory sf = new RectangleFactory(); Shapes.Rectangle rectangle = (Shapes.Rectangle)sf.Create2dShape(); rectangle.Point1.X = 1; rectangle.Point1.Y = 2; rectangle.Point2.X = 5; rectangle.Point2.Y = 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); }
private Scene2D CreateShapes() { var scene = new Scene2D(); scene.Shapes.Add(new Circle(new Vector2D(3, 5), 8)); scene.Shapes.Add(RectangleFactory.CreateByDimensions(7, -2, 12, 8)); var points = new List <Vector2D>() { new Vector2D(2, 2), new Vector2D(6, 7), new Vector2D(4, -3), new Vector2D(-2, 1) }; scene.Shapes.Add(PolygonFactory.CreateByPoints(points)); return(scene); }
public void RectangleAndPolygon_DoOverlap_ShouldReturn() { var operation = new GeneralShapeOperation(); var rectangle = RectangleFactory.CreateByDimensions(0, 0, 3, 3); var polygon = PolygonFactory.CreateByPoints(new List <Vector2D>() { new Vector2D(1, 1), new Vector2D(1, 2), new Vector2D(2, 1) }); var result = operation.DoOverlap(rectangle, polygon); result.Should().BeTrue(); }
public void TestMove() { ShapeFactory sf = new RectangleFactory(); Shapes.Rectangle rectangle = (Shapes.Rectangle)sf.Create2dShape(); rectangle.Point1.X = 1; rectangle.Point1.Y = 2; rectangle.Point2.X = 5; rectangle.Point2.Y = 6; rectangle.Move(2, 3); Assert.AreEqual(3, rectangle.Point1.X); Assert.AreEqual(5, rectangle.Point1.Y); Assert.AreEqual(7, rectangle.Point2.X); Assert.AreEqual(9, rectangle.Point2.Y); }
static IFoldingDrawer CreateFoldingDrawer() { var rectangleFactory = new RectangleFactory(); return(new FoldingDrawer( new EmptyCanvasFactory(), new PanelRectangleFactory( new RootPanelPositioner(rectangleFactory), new PanelPositioner( new AttachToHingeDeterminer(), new RotationDeterminer(), rectangleFactory, new RectangleRotator(), new HingeOffsetApplier())), new RectangleDrawer())); }
public void Setup() { List <Vector2D> points = new List <Vector2D>(); Console.WriteLine($"PolygonSize: {PolygonSides}"); for (int p = 0; p < PolygonSides; p++) { var x = random.NextDouble() * 60000 + 20000; var y = random.NextDouble() * 60000 + 20000; points.Add(new Vector2D(x, y)); } this.RandomPolygon = PolygonFactory.CreateByPoints(points); this.RandomPolygon.MarginWidth = 2000; points = new List <Vector2D>(); for (int p = 0; p < PolygonSides; p++) { var x = Math.Cos(Math.PI / PolygonSides * p) * OverlapProbability * 100000 + 50000; var y = Math.Cos(Math.PI / PolygonSides * p) * OverlapProbability * 100000 + 50000; points.Add(new Vector2D(x, y)); } this.RegularPolygon = PolygonFactory.CreateByPoints(points); this.RegularPolygon.MarginWidth = 2000; points = new List <Vector2D>(); for (int p = 0; p < PolygonSides; p++) { var radius = random.NextDouble() * OverlapProbability * 50000; var x = Math.Cos(Math.PI / PolygonSides * p) * radius + 50000; var y = Math.Cos(Math.PI / PolygonSides * p) * radius + 50000; points.Add(new Vector2D(x, y)); } this.RadialPolygon = PolygonFactory.CreateByPoints(points); this.RadialPolygon.MarginWidth = 2000; for (int i = 0; i < Count; i++) { var x = random.NextDouble() * 90000; var y = random.NextDouble() * 90000; var width = random.NextDouble() * 20000; var height = random.NextDouble() * 20000; var rectangle = RectangleFactory.CreateByDimensions(x, y, width, height); rectangle.MarginWidth = random.NextDouble() * 3000; Rectangles.Add(rectangle); } }
public void Should_ReturnCorrectRectangle_When_RectanglePointsStringIsValid() { var rectangleFactory = new RectangleFactory(); var pointFactory = new MockPointFactory(new Point(10, 23), new Point(34, 50)); var rectangle = rectangleFactory.CreateRectangle(pointFactory, "10 23 34 50"); Assert.AreEqual(10, rectangle.BottomLeft.X); Assert.AreEqual(23, rectangle.BottomLeft.Y); Assert.AreEqual(34, rectangle.BottomRight.X); Assert.AreEqual(23, rectangle.BottomRight.Y); Assert.AreEqual(34, rectangle.TopRight.X); Assert.AreEqual(50, rectangle.TopRight.Y); Assert.AreEqual(10, rectangle.TopLeft.X); Assert.AreEqual(50, rectangle.TopLeft.Y); Assert.AreEqual(24, rectangle.XLength); Assert.AreEqual(27, rectangle.YLength); }
public void Should_ReturnCorrectRectangle_When_LengthAndWidthAreValid() { var rectangleFactory = new RectangleFactory(); var pointFactory = new MockPointFactory(new Point(0, 0), new Point(30, 40)); var rectangle = rectangleFactory.CreateRectangle(pointFactory, 30, 40); Assert.AreEqual(0, rectangle.BottomLeft.X); Assert.AreEqual(0, rectangle.BottomLeft.Y); Assert.AreEqual(30, rectangle.BottomRight.X); Assert.AreEqual(0, rectangle.BottomRight.Y); Assert.AreEqual(30, rectangle.TopRight.X); Assert.AreEqual(40, rectangle.TopRight.Y); Assert.AreEqual(0, rectangle.TopLeft.X); Assert.AreEqual(40, rectangle.TopLeft.Y); Assert.AreEqual(30, rectangle.XLength); Assert.AreEqual(40, rectangle.YLength); }
public void Should_ThrowException_When_PointsAreEmpty() { var rectangeFactory = new RectangleFactory(); var rectangle = rectangeFactory.CreateRectangle(new MockPointFactory(), string.Empty); }
public void Should_ThrowException_When_TooManyPointsAreEntered() { var rectangeFactory = new RectangleFactory(); var rectangle = rectangeFactory.CreateRectangle(new MockPointFactory(), "10 20 30 40 50"); }
public void Should_ThrowException_When_PointFactoryIsNull() { var rectangeFactory = new RectangleFactory(); var rectangle = rectangeFactory.CreateRectangle(null, "10 20 30 40"); }
static void Main() { Figure factory = new Figure(); Random rand = new Random(); List <IFigure> figures = new List <IFigure>(); bool finish = false; for (int i = 0; i < 5; i++) { figures.Add(factory.Create((Dict)rand.Next(0, 3))); } do { Console.WriteLine("1. Wyświetl figury."); Console.WriteLine("2. Dodaj figurę."); Console.WriteLine("K. Wyjdź."); string choice; choice = Console.ReadLine(); switch (choice) { case "1": Console.Clear(); do { Console.WriteLine("Aby zwiększyc, zmniejszyć lub usunąć figurę wybierz ją po numerze."); for (int i = 0; i < figures.Count; i++) { Console.WriteLine("{0}. {1}", i + 1, figures[i].ToString()); } Console.WriteLine("K. Wróć."); choice = Console.ReadLine(); if (choice == "K" || choice == "k") { finish = true; Console.Clear(); } else { try { int index = Convert.ToInt32(choice) - 1; Console.Clear(); do { Console.WriteLine(figures[index].ToString()); Console.WriteLine("1. Powiększ."); Console.WriteLine("2. Zmniejsz."); Console.WriteLine("3. Usuń."); Console.WriteLine("K. Wróć."); choice = Console.ReadLine(); Console.Clear(); switch (choice) { case "1": figures[index].Increase(); break; case "2": figures[index].Decrease(); break; case "3": figures.RemoveAt(index); finish = true; break; case "k": case "K": finish = true; break; default: Console.WriteLine("Zła wartość. Wpisz ponownie."); break; } }while (!finish); finish = false; } catch { Console.Clear(); Console.WriteLine("Zła wartość. Podaj ponownie."); } } }while (!finish); finish = false; break; case "2": do { Console.WriteLine("Wybierz jaką figurę tworzysz:"); Console.WriteLine("1. Kwadrat."); Console.WriteLine("2. Prostokąt."); Console.WriteLine("3. Koło."); Console.WriteLine("K. Wróć."); choice = Console.ReadLine(); Console.Clear(); double a, b; switch (choice) { case "1": SquareFactory squareFactory = new SquareFactory(); Console.WriteLine("Podaj długość boku. "); a = Convert.ToDouble(Console.ReadLine()); figures.Add(squareFactory.Create(a)); break; case "2": RectangleFactory rectangleFactory = new RectangleFactory(); Console.WriteLine("Podaj długość pierwszego boku. "); a = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Podaj długość drugiego boku. "); b = Convert.ToDouble(Console.ReadLine()); figures.Add(rectangleFactory.Create(a, b)); break; case "3": CircleFactory circleFactory = new CircleFactory(); Console.WriteLine("Podaj długość promienia. "); a = Convert.ToDouble(Console.ReadLine()); figures.Add(circleFactory.Create(a)); break; case "k": case "K": finish = true; break; default: Console.Clear(); Console.WriteLine("Zły wybór. Wybierz ponownie."); break; } }while (!finish); finish = false; Console.Clear(); break; case "k": case "K": finish = true; break; default: Console.Clear(); Console.WriteLine("Zły wybór. Wybierz ponownie."); break; } }while (!finish); }
public TestsForRectangleFactory() { _sut = new RectangleFactory(); }
public static RectangleFactory getInstance() { return(Instance ?? (Instance = new RectangleFactory())); }
public static void Demo() { List <Figure> figures = new List <Figure>(); while (true) { Console.Clear(); Console.WriteLine("Console graphical editor."); Console.WriteLine("Select option."); Console.WriteLine("1. Add Line."); Console.WriteLine("2. Add Circle."); Console.WriteLine("3. Add Rectangle."); Console.WriteLine("4. Add Round."); Console.WriteLine("5. Add Ring."); Console.WriteLine("6. Add Ring (aggregation)."); Console.WriteLine("7. Show figures."); Console.WriteLine("0. Exit."); int select; while (!int.TryParse(Console.ReadLine(), out select)) { Console.WriteLine("Wrong input. Try again."); } switch (select) { case 1: figures.Add(LineFactory.Create()); Console.Clear(); Console.WriteLine("Line added. Press enter to continue."); Console.ReadLine(); break; case 2: figures.Add(CircleFactory.Create()); Console.Clear(); Console.WriteLine("Circle added. Press enter to continue."); Console.ReadLine(); break; case 3: figures.Add(RectangleFactory.Create()); Console.Clear(); Console.WriteLine("Rectangle added. Press enter to continue."); Console.ReadLine(); break; case 4: figures.Add(RoundFactory.Create()); Console.Clear(); Console.WriteLine("Round added. Press enter to continue."); Console.ReadLine(); break; case 5: figures.Add(RingFactory.Create()); Console.Clear(); Console.WriteLine("Ring added. Press enter to continue."); Console.ReadLine(); break; case 6: figures.Add(RingAggregationFactory.Create()); Console.Clear(); Console.WriteLine("Ring (aggregation) added. Press enter to continue."); Console.ReadLine(); break; case 7: Console.Clear(); foreach (Figure figure in figures) { figure.ShowInfo(); Console.WriteLine(); } Console.ReadLine(); break; case 0: Console.WriteLine("Good luck!"); Console.ReadLine(); return; default: Console.WriteLine("Wrong option. Try again."); break; } } }
static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); int ChoiceOfShape = 0; do { Console.WriteLine("Enter Your Choice to Draw Shape"); Console.WriteLine("1.Line"); Console.WriteLine("2.Circle"); Console.WriteLine("3.Rectangle"); Console.WriteLine("4.Exit"); ChoiceOfShape = int.Parse(Console.ReadLine()); switch (ChoiceOfShape) { case 1: Console.WriteLine("1.Line"); Line line = LineFactory.GetLine(); Console.WriteLine("Enter X Co-ordinate of First point"); int XLineFirst = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Y Co-ordinate of First point"); int YLineFirst = int.Parse(Console.ReadLine()); Console.WriteLine("Enter X Co-ordinate of Second point"); int XLineSecond = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Y Co-ordinate of Second point"); int YLineSecond = int.Parse(Console.ReadLine()); line.FirstpointXCoordinate = XLineFirst; //100 line.FirstpointYCoordinate = YLineFirst; //200 line.SecondpointXCoordinate = XLineSecond; //400 line.SecondpointYCoordinate = YLineSecond; //300 ILineOperation lineOperation = LineOperationFactory.GetLineOperation(); //IShapeOperation lineOperation = ShapeOperationFactory.GetLineOperation(); lineOperation.Draw(line); log.InfoFormat("Line Created"); break; case 2: Console.WriteLine("2.Circle"); Circle circle = CircleFactory.GetCircle(); Console.WriteLine("Enter X & Y Co-ordinate of Centre point"); int XCircleFirst = int.Parse(Console.ReadLine()); int YCircleFirst = int.Parse(Console.ReadLine()); Console.WriteLine("Enter X & Y Equidistance Points of Radius"); int XCircleSecond = int.Parse(Console.ReadLine()); int YCircleSecond = int.Parse(Console.ReadLine()); circle.FirstpointXCoordinate = XCircleFirst; //10 circle.FirstpointYCoordinate = YCircleFirst; //10 circle.SecondpointXCoordinate = XCircleSecond; //50 circle.SecondpointYCoordinate = YCircleSecond; //50 ICircleOperation circleOperation = CircleOperationalFactory.GetCircleOperation(); circleOperation.Draw(circle); log.InfoFormat("Circle Created"); break; case 3: Console.WriteLine("3.Rectangle"); ERectangle rectangle = RectangleFactory.GetRectangle(); Console.WriteLine("Enter X & Y Co-ordinate of First point of Rectangle"); int XRectFirst = int.Parse(Console.ReadLine()); int YRectFirst = int.Parse(Console.ReadLine()); Console.WriteLine("Enter X & Y Co-ordinate of Second Point of Rectangle"); int XRectSecond = int.Parse(Console.ReadLine()); int YRectSecond = int.Parse(Console.ReadLine()); rectangle.FirstpointXCoordinate = XRectFirst; rectangle.FirstpointYCoordinate = YRectFirst; rectangle.SecondpointXCoordinate = XRectSecond; rectangle.SecondpointYCoordinate = YRectSecond; IRectangleOperation rectangleOperation = RectangleOperationFactory.GetRectangleOperation(); rectangleOperation.Draw(rectangle); log.InfoFormat("Rectangle Created"); break; case 4: Console.WriteLine("4.Exit"); Console.WriteLine("Welcome Again!!"); System.Environment.Exit(0); break; default: Console.WriteLine("Wrong Choice ! "); break; } } while (ChoiceOfShape != 3); }
private PrimitivesFactory() { rectangleFactory = RectangleFactory.getInstance(); }
public Shape getShape(int initialX, int initialY, int secondaryX, int secondaryY, bool add) { if (designation == shapeDesignation.EMBEDDED_PIC) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { string file = openFileDialog1.FileName; Console.WriteLine(openFileDialog1.FileName); embeddedPicFilepath = openFileDialog1.FileName; } } ShapeFactory factory = null; switch (designation) { case shapeDesignation.CIRCLE: Shapes.Point CirclePoint = new Shapes.Point(Math.Min(initialX, secondaryX), Math.Min(initialY, secondaryY)); factory = new CircleFactory(CirclePoint, Math.Abs(secondaryX - initialX)); break; case shapeDesignation.ELLIPSE: Shapes.Point EllipsePoint = new Shapes.Point(Math.Min(initialX, secondaryX), Math.Min(initialY, secondaryY)); factory = new EllipseFactory(EllipsePoint, Math.Abs(secondaryY - initialY), Math.Abs(secondaryX - initialX)); break; case shapeDesignation.RECTANGLE: Shapes.Point RectanglePoint = new Shapes.Point(Math.Min(initialX, secondaryX), Math.Min(initialY, secondaryY)); factory = new RectangleFactory(RectanglePoint, Math.Abs(secondaryY - initialY), Math.Abs(secondaryX - initialX)); break; case shapeDesignation.SQUARE: Shapes.Point SquarePoint = new Shapes.Point(Math.Min(initialX, secondaryX), Math.Min(initialY, secondaryY)); factory = new SquareFactory(SquarePoint, Math.Abs(secondaryX - initialX)); break; case shapeDesignation.TRIANGLE: //TODO: Figure out rectangular triangle drawing //Shapes.Point TriPoint1 = new Shapes.Point(Int32.Parse(txtPoint1X.Text), Int32.Parse(txtPoint1Y.Text)); //Shapes.Point TriPoint2 = new Shapes.Point(Int32.Parse(txtPoint2X.Text), Int32.Parse(txtPoint2Y.Text)); //Shapes.Point TriPoint3 = new Shapes.Point(Int32.Parse(txtPoint3X.Text), Int32.Parse(txtPoint3Y.Text)); //factory = new TriangleFactory(TriPoint1, TriPoint2, TriPoint3); break; case shapeDesignation.EMBEDDED_PIC: Shapes.Point EmbeddedPoint = new Shapes.Point(Math.Min(initialX, secondaryX), Math.Min(initialY, secondaryY)); factory = new EmbeddedPicFactory(EmbeddedPoint, Math.Abs(secondaryX - initialX), Math.Abs(secondaryY - initialY), embeddedPicFilepath); break; case shapeDesignation.LINE: //TODO: Create Line in shapes break; default: return(null); } Shape shape = factory.GetShape(); if (add) { addToList(shape); } return(shape); }