WPF lines and polylines events for a 2D Editor
i want to create a 2d-editor like application in WPF an i need to know how to do this:
- How can intercept the event when i click on a Line or Polyline?
- How can detect the end / beginning of a line and show a small dot or small box in the end or the beginning of the line. Is there a way to raise an event if i get close of end or the beginning of the line?
- How can i create a panning and zooming functionality? How can i control the canvas for that funct开发者_开发技巧ionality?
- How can i maintain the aspect ratio between X and Y and the scale. I mean if i have a horizontal line of length 5 and a vertical line of length 5, what do i have to do to both lines look the same length visually?
Thanks for your answers. Eduardo
I don't know much, but the ideas that came to my mind are as below, correct me if anything wrong.
Using Hit-Testing [Ref] or Pre-defined extendable Shapes [Ref], which already have common Input events (like
MouseEnter
,MouseLeave
, ...)For showing a small dot, u can use Adorners. Every line a has end and start point, u can just get it's value and adjust your visual (small dot) for them. Yes,
Adorner
can help u, they are just like any otherUIElement
, so commons events likeMouseEnter
,MouseLeave
, ... are there.For panning and zooming, u can use the code from here or here or here
The lines will be visually same. Just draw them using Shapes (link above).
精彩评论