/// <summary> /// removes a point at a special position in a polygon and recalculates boundingBox /// </summary> /// <param name="index"></param> public override void RemovePoint(int index) { if (index == 0) { minX = double.NaN; minY = double.NaN; width = double.NaN; height = double.NaN; points.RemoveAt(index); } else { ShpPoint tempPoint = points[index]; points.RemoveAt(index); if (tempPoint.CenterX == minX || tempPoint.CenterX == minX + width || tempPoint.CenterY == minY || tempPoint.CenterY == minY + height ) { minX = points[0].CenterX; minY = points[0].CenterY; width = 0; height = 0; checkBoundingBox(); } } }
public override int RemovePoint(ShpPoint point) { bool result = false; if (points.Count > 4) // since we save start and end points seperately { int index = points.IndexOf(point); result = points.Remove(point); if (result) { if (index == 0) // did we delete the root point? Close the polygon again! { points[points.Count - 1].moveTo( points[0].RootX, points[0].RootY, false, true); } else if (index == points.Count) // did we delete the closing point? (since we removed one point we test against the now smaller list, hence Count can be used { points[0].moveTo( points[points.Count - 1].RootX, points[points.Count - 1].RootY, false, true); } checkBoundingBox(); return(index); } } return(-1); }
public override void InsertPointAt(int index, double x, double y, double scale) { ShpPoint pointToAdd = new ShpPoint(x, y, scale); if (index == points.Count) { points.Add(pointToAdd); points[0].moveTo( points[points.Count - 1].RootX, points[points.Count - 1].RootY, false, true); } else { points.Insert(index, pointToAdd); if (index == 0) // did we delete the root point? Close the polygon again! { points[points.Count - 1].moveTo( points[0].RootX, points[0].RootY, false, true); } } checkBoundingBox(); pointToAdd.Changed += new PositionChangedDelegate(vertex_PositionChanged); }
public override int RemovePoint(ShpPoint point) { int index = points.IndexOf(point); bool result = points.Remove(point); if (points.Count == 0) { minX = double.NaN; minY = double.NaN; width = double.NaN; height = double.NaN; } else { checkBoundingBox(); } if (result) { return(index); } else { return(-1); } }
public EditGeometryMenu(MainForm mainForm, IShape container, ShpPoint vertex) : base() { this.mainForm = mainForm; this.container = container; this.vertex = vertex; moveMenuItem = new MenuItem(); moveMenuItem.Text = "verschieben"; moveMenuItem.Checked = false; moveMenuItem.Click += new System.EventHandler(menuItemClick); //choosePositionMenuItem = new MenuItem(); //choosePositionMenuItem.Text = "Position eingeben"; //choosePositionMenuItem.Checked = false; //choosePositionMenuItem.Click += new System.EventHandler(menuItemClick); removeShapeMenuItem = new MenuItem(); removeShapeMenuItem.Text = "löschen"; removeShapeMenuItem.Checked = false; removeShapeMenuItem.Click += new System.EventHandler(menuItemClick); // you can not delete a point if there are less then three points in the polygon if ((container.PointCount <= 4 && (container as ShpPolygon) != null) || (container.PointCount <= 2 && (container as ShpPolyline) != null)) removeShapeMenuItem.Enabled = false; this.MenuItems.Add(moveMenuItem); //this.MenuItems.Add(choosePositionMenuItem); this.MenuItems.Add(removeShapeMenuItem); }
public override void AddPoint(double x, double y, double scale) { ShpPoint pointToAdd = new ShpPoint(x, y, scale); points.Add(pointToAdd); checkBoundingBox(); pointToAdd.Changed += new PositionChangedDelegate(vertex_PositionChanged); }
public override void InsertPointAt(int index, double x, double y, double scale) { ShpPoint pointToAdd = new ShpPoint(x, y, scale); points.Insert(index, pointToAdd); checkBoundingBox(); pointToAdd.Changed += new PositionChangedDelegate(vertex_PositionChanged); }
public RemoveGeometryAction(ShpPoint shapeToRemove, IShape container, LayerManager layerManager) { this.layerManager = layerManager; this.d.x = this.layerManager.GetMainControler().MapPanel.DX; this.d.y = this.layerManager.GetMainControler().MapPanel.DY; this.scale = layerManager.Scale; this.shapeToDelete = shapeToRemove; this.container = container; this.pointSize = 2; deletedPoint.x = shapeToDelete.RootX; deletedPoint.y = shapeToDelete.RootY; }
/// <summary> /// Compares two points on coordinate basis. if they have the same coodinates they are considered equal /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { ShpPoint pnt = obj as ShpPoint; if (pnt != null) { if (this.CenterX == pnt.CenterX && pnt.CenterY == this.CenterY) { return(true); } } return(false); }
public void removeVertex(IShape container, ShpPoint vertex) { if (container != null && vertex != null) { DialogResult result = MessageBox.Show("Möchten Sie diesen Punkt wirklich löschen?", "Punkt löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { if (PerformAction(new RemoveGeometryAction(vertex, container, layerManager))) { mainForm.setStatus_Timed("Punkt erfolgreich gelöscht.", 1000); mapPanel.Invalidate(); } else mainForm.setStatus_Timed("Punkt nicht gelöscht.", 1000); } } }
public override int RemovePoint(ShpPoint point) { throw new Exception("A point can not delete itself."); }
public abstract int RemovePoint(ShpPoint point);
public ShpPoint addPoint(double x, double y, double scale) { ShpPoint pnt = new ShpPoint(x, y, scale); if (points.Count == 0) { _boundingBox.Left = pnt.RootX; _boundingBox.Bottom = pnt.RootY; _boundingBox.TopRight = _boundingBox.BottomLeft; } else { if (pnt.RootX < _boundingBox.Left) _boundingBox.Left = pnt.RootX; if (pnt.RootY < _boundingBox.Bottom) _boundingBox.Bottom = pnt.RootY; if (pnt.RootX > _boundingBox.Right) _boundingBox.Right = pnt.RootX; if (pnt.RootY > _boundingBox.Top) _boundingBox.Top = pnt.RootY; } points.Add(pnt); pnt.Changed += new IShape.PositionChangedDelegate(pnt_Changed); ElementAdded(pnt); return pnt; }