Change the coordinate system of a Canvas in WPF

后端 未结 8 1771
一整个雨季
一整个雨季 2021-02-01 06:59

I\'m writing a mapping app that uses a Canvas for positioning elements. For each element I have to programatically convert element\'s Lat/Long to the canvas\' coordinate, then

8条回答
  •  既然无缘
    2021-02-01 07:32

    Another possible solution:

    Embed a custom canvas (the draw-to canvas) in another canvas (the background canvas) and set the draw-to canvas so that it is transparent and does not clip to bounds. Transform the draw-to canvas with a matrix that makes y flip (M22 = -1) and translates/scales the canvas inside the parent canvas to view the extend of the world you're looking at.

    In effect, if you draw at -115, 42 in the draw-to canvas, the item you are drawing is "off" the canvas, but shows up anyway because the canvas is not clipping to bounds. You then transform the draw-to canvas so that the point shows up in the right spot on the background canvas.

    This is something I'll be trying myself soon. Hope it helps.

提交回复
热议问题