VertexGeometry.cs
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using System; using System.Collections.Generic; using System.Linq; using System.Text; using ESRI.ArcGISExplorer.Geometry; namespace UpdateNoteGeometryCS { // This class can be used to edit the vertices of single-part polygons and polylines, and also of multipoints. // If used to edit multipart polygons or polylines, only the first part is edited; the class can be extended to // edit multiparts. class VertexGeometry { private Polygon _pgon = null; private Polyline _pline = null; private Multipoint _mpt = null; public VertexGeometry(Geometry geom) { switch (geom.GeometryType) { case GeometryType.Polygon: _pgon = geom as Polygon; break; case GeometryType.Polyline: _pline = geom as Polyline; break; case GeometryType.Multipoint: _mpt = geom as Multipoint; break; default: throw new NotSupportedException(); } } public Point GetPoint(int vertexIndex) { Point retVal = null; if (_pgon != null) { retVal = _pgon.GetPoint(vertexIndex); } else if (_pline != null) { retVal = _pline.GetPoint(vertexIndex); } else if (_mpt != null) { retVal = _mpt.GetPoint(vertexIndex); } return retVal; } public void SetPoint(int vertexIndex, Point newPoint) { if (_pgon != null) { _pgon.SetPoint(vertexIndex, newPoint); } else if (_pline != null) { _pline.SetPoint(vertexIndex, newPoint); } else if (_mpt != null) { _mpt.SetPoint(vertexIndex, newPoint); } } public int PointCount() { int retVal = -1; if (_pgon != null) { retVal = _pgon.PointCount(0); } else if (_pline != null) { retVal = _pline.PointCount(0); } else if (_mpt != null) { retVal = _mpt.PointCount; } return retVal; } } }