c# - Drawing squares in WPF -
i want achieve following wpf application (in area/defined area):
- when clicking , holding on app, can draw square
- you can many times, not overlap squares
- you can drag squares around application
what need achieve this, assume bunch of onclick/onmove's. there easier way, such using canvas? insight great.
you have use canvas if want squares appear user clicks , drags.
the mouse down event define 1 corner , mouse second. you'd have constrain movement of cursor x , y dimensions of rectangle same.
on each mouse move event you'd have check if cursor on 1 of existing squares , prevent square growing further.
for dragging of existing squares modify mouse down event check what's under cursor. if it's canvas start square drawing mode, if it's rectangle (square) start dragging mode. again you'd need use mouse move event check square doesn't intersect existing squares.
Comments
Post a Comment