//public StaticlyPlacedObject(Vector begin, Vector end) //{ // BeginPoint = begin; // EndPoint = end; //} public Polygon ToPolygon() { //Make, add points, build and return. Polygon p = new Polygon(); p.Points.Add(BeginPoint); p.Points.Add(EndPoint); p.BuildEdges(); return p; }
public void event_PanelMouseDown(object sender, MouseEventArgs e) { foreach (PlacedProduct PlacedP in PlacementController.placedProductList) { //Get the mouse location var MouseLocation = new Point(e.X, e.Y); Polygon P = new Polygon(); P.Points.Add(new Vector(MouseLocation.X, MouseLocation.Y)); P.BuildEdges(); //And compare it to all possible polygons, so that when one collides, you know which one the user has clicked on. PolygonCollisionController.PolygonCollisionResult r = PolygonCollisionController.PolygonCollision(P, PlacedP.Poly, new Vector(0, 0)); if (r.WillIntersect) { //Do DragDrop clickLocation = MouseLocation; productAdding.DoDragDrop(PlacedP, DragDropEffects.Copy); //Set as current product productAdding.productInfo1.setProduct(PlacedP.Product); currentProduct = PlacedP; break; } } }
public List<Polygon> PolyBorder(int width, int height) { //List to return List<Polygon> list = new List<Polygon>(); // //Add the 4 corners // Polygon pTop = new Polygon(); Polygon pRight = new Polygon(); Polygon pBottom = new Polygon(); Polygon pLeft = new Polygon(); //Points for corners Vector pointTopLeft = new Vector(0, 0); Vector pointTopRight = new Vector(width, 0); Vector pointBottomLeft = new Vector(0, height); Vector pointBottomRight = new Vector(width, height); //Add points/vectors pTop.Points.Add(pointTopLeft); pTop.Points.Add(pointTopRight); // pRight.Points.Add(pointTopRight); pRight.Points.Add(pointBottomRight); // pBottom.Points.Add(pointBottomRight); pBottom.Points.Add(pointBottomLeft); // pLeft.Points.Add(pointBottomLeft); pLeft.Points.Add(pointTopLeft); //Build edges pTop.BuildEdges(); pRight.BuildEdges(); pBottom.BuildEdges(); pLeft.BuildEdges(); //Add to the list list.Add(pTop); list.Add(pRight); list.Add(pBottom); list.Add(pLeft); return list; }
public Polygon GetVirtualPolygon(Point newLocation) { Polygon virtualPolygon = new Polygon(); foreach (Vector v in Poly.Points) { virtualPolygon.Points.Add(v); } Vector delta = new Vector(new Vector(newLocation) - new Vector(Location)); virtualPolygon.Offset(delta); virtualPolygon.BuildEdges(); return virtualPolygon; }