public static void ReversePolyline(Polyline pl) { if (pl != null) { // Collect our per-vertex data List <PerVertexData> vertData = new List <PerVertexData>(pl.NumberOfVertices); for (int i = 0; i < pl.NumberOfVertices; i++) { PerVertexData pvd = new PerVertexData(); pvd.bulge = (i > 0 ? pl.GetBulgeAt(i - 1) : 0); pvd.startWidth = (i > 0 ? pl.GetStartWidthAt(i - 1) : 0); pvd.endWidth = (i > 0 ? pl.GetEndWidthAt(i - 1) : 0); pvd.pt = pl.GetPoint2dAt(i); vertData.Add(pvd); } // Write the data back to the polyline, but in // reverse order for (int i = 0; i < pl.NumberOfVertices; i++) { PerVertexData pvd = vertData[pl.NumberOfVertices - (i + 1)]; pl.SetPointAt(i, pvd.pt); pl.SetBulgeAt(i, -pvd.bulge); pl.SetStartWidthAt(i, pvd.endWidth); pl.SetEndWidthAt(i, pvd.startWidth); } } }
public static void ReversePolyline(Polyline pl) { if (pl != null) { // Collect our per-vertex data List<PerVertexData> vertData = new List<PerVertexData>(pl.NumberOfVertices); for (int i = 0; i < pl.NumberOfVertices; i++) { PerVertexData pvd = new PerVertexData(); pvd.bulge = (i > 0 ? pl.GetBulgeAt(i - 1) : 0); pvd.startWidth = (i > 0 ? pl.GetStartWidthAt(i - 1) : 0); pvd.endWidth = (i > 0 ? pl.GetEndWidthAt(i - 1) : 0); pvd.pt = pl.GetPoint2dAt(i); vertData.Add(pvd); } // Write the data back to the polyline, but in // reverse order for (int i = 0; i < pl.NumberOfVertices; i++) { PerVertexData pvd = vertData[pl.NumberOfVertices - (i + 1)]; pl.SetPointAt(i, pvd.pt); pl.SetBulgeAt(i, -pvd.bulge); pl.SetStartWidthAt(i, pvd.endWidth); pl.SetEndWidthAt(i, pvd.startWidth); } } }