When we draw any shapes (rectangle, polygon, ellipse...etc), i notice they are all represented by PolygonShape, so the user can add/delete/move vertices. Is there any method to retrieve vertices of a shape so i can replicate those shapes in WPF? there is a method "RemoveVertex", but i can't fins a way to retrieve all vertices.
Yes, as you said, we do not have a built-in API to retrieve all vertecis for any given shape, the reason is that we do not have a very common statndards to retrieve all those vertices. While, I am sure you could write your own logic to implement it. Following is some code you can take a reference if you want. private Collection<Vertex> GetAllVertices(BaseShape baseShape) { Collection<Vertex> returningVertices = new Collection<Vertex>();
switch (wellKnowType) { case WellKnownType.Point: PointShape targetShape1 = (PointShape)baseShape; returningVertices.Add(new Vertex(targetShape1)); break; case WellKnownType.Multipoint: MultipointShape targetShape2 = (MultipointShape)baseShape; foreach (PointShape pointShape in targetShape2.Points) { returningVertices.Add(new Vertex(pointShape)); } break; case WellKnownType.Line: //logic for LineShape. break; case WellKnownType.Multiline: //Logic for MultilineShape. break; case WellKnownType.Polygon: //Logic for PolygonShape break; case WellKnownType.Multipolygon: //Logic for MultiPolygon shape. break; default: throw new ArgumentException("baseshape is not a valid shape"); }