How do I draw polygon?( in C# WPF project) -
click points, want make polygon area on image.
mypolygon = new polygon(); mypolygon.stroke = brushes.black; mypolygon.fill = brushes.lightyellow; mypolygon.strokethickness = 2; mypolygon.horizontalalignment = horizontalalignment.left; mypolygon.verticalalignment = verticalalignment.center; mypolygon.previewmouseleftbuttondown += new mousebuttoneventhandler(polygon_mousedown); mypolygon.previewmouseleftbuttonup += new mousebuttoneventhandler(polygon_mouseup); private void polygon_mousedown(object sender, mousebuttoneventargs e) { point p = e.getposition(image); mypolygon.points = new pointcollection() { new point(p.x,p.y) }; rootcanvas.children.add(mypolygon); } //mouseclick event but, did not click behavior.. want draw line along points.
how can do...?
we can draw polygon using wpf canvas collection of children objects.
polygon p = new polygon(); p.stroke = brushes.black; p.fill = brushes.lightblue; p.strokethickness = 1; p.horizontalalignment = horizontalalignment.left; p.verticalalignment = verticalalignment.center; p.points = new pointcollection() { new point(10, 10), new point(100, 100), new point(200, 200) }; freecanvas.children.add(p);
for more information,. please refer following urls
http://www.codeproject.com/articles/128705/wpf-rounded-corners-polygon
http://classicalprogrammer.wikidot.com/draw-dynamic-polygons-in-wpf
Comments
Post a Comment