简体   繁体   中英

WPF: How to know if users clicked a Rectangle/Line/Ellipse which are drawn in Canvas?

I'm doing MyPaint application. Now I have some problem.

  1. Users draw some shapes in canvas. Then they can select and move it by click-drag and drop . So how to know if users clicked on a shapes (Outline or within the shapes)?
  2. As soon as they clicked on the shapes, a dash-stroke square and some anchor points will be shown (as the Picture ). Then users can click and keep pressing on those anchor point to resize the shapes. So how to design Resize function like this ?

I have no idea about the code. Can anyone give me some hints? Thanks in advance

Finding out if the user has clicked on the shape could be as easy as implementing a MouseDown event handler on the shape (rectangle.MouseDown += ...). As far as moving and resizing, this example should be useful (you may have to calculate your own scale if you're only using the mouse but it should point you in the right direction): https://msdn.microsoft.com/en-us/library/vstudio/ee649090(v=vs.100).aspx

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