简体   繁体   中英

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.

样本图片

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM