开发者

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:

  1. How can intercept the event when i click on a Line or Polyline?
  2. 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?
  3. How can i create a panning and zooming functionality? How can i control the canvas for that funct开发者_开发技巧ionality?
  4. 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 other UIElement, so commons events like MouseEnter, 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜