You can use the Shape
and in particolar the Polygon
Class, interact with these object is particularly simple, but if you are dealing with thousands of edges I suggest to use the DrawingVisual
Class, a visual object that can be used to render vector graphics on the screen, and its RenderOpen
method.
DrawingVisual
does not provide event handling, so if with Shape
you can use events to interact with edges, with DrawingVisual
you need to implement Hit-Testing.
With a Polygon
to know Height
and Width
simply use the element properties.
If you want to check if a Point
is inside your polygon you can use the InputHitTest
Method or esle the VisualTreeHelper.HitTest
Method:
let res = yourPolygon.InputHitTest(new Point(x, y))
let res = VisualTreeHelper.HitTest(yourPolygon, new Point(x, y))
In conclusion: if you seek an elegant method to check if a point is inside a polygon take a look at this answer.