Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# WPF: Creating UI for drawing shapes using mouse

I am developing an application in C# .NET using WPF. I want the users to be able to draw shapes on a draw area. The shapes are zigzag lines and polygons. The end points of line segments should be small squares as shown in the image below. In some cases, I need arrows in the middle of line segments as shown in the image below.

Sample image

I have partially implemented the drawing by adding lines to a canvas and resizing the lines on mouse events. However, I have not been able to implement creation of small squares on the end points of line segments and arrows.

Is there any package or tool that provides the functionality of drawing such shapes?

Thank you for any help which you can provide.

like image 512
geekowl Avatar asked Mar 01 '26 22:03

geekowl


1 Answers

A common way to approach this is to use Adorners. Basically, there is a virtual layer rendered for adorners. You can use these to drag / resize (among other things) visual elements on the screen with a little bit of glue code.

Here is a page from Microsoft on the subject: http://msdn.microsoft.com/en-us/library/ms743737.aspx?ppud=4

like image 198
RQDQ Avatar answered Mar 04 '26 10:03

RQDQ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!