Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a function when canvas zooming is done
    primarykey
    data
    text
    <p>I have a <code>UserControl</code> that contains a <code>Canvas</code>. The Canvas can be panned and zoomed in and out correctly. I also keep a small user control that shows the content of the big user control with a small rectangle that displays the user what he's currently looking at (The size / location of that rectangle is updated whenever the user pans / zooms on the main user control)</p> <p>All is working correctly except for one thing - When I zoom in or out using the mouse wheel, the location of the small reference rectangle is updated to the wrong location, and when I pan the canvas around it shows the correct location. I calculated the location of the reference rectangle by taking the 0, 0 point of the canvas in the main user control and converting it to point on the screen. Here's my code:</p> <pre><code>public Point GetTopLeftOffset() { Point topLeft = PointToScreen(new Point(0, 0)); return m_mainCanvas.PointFromScreen(topLeft); } </code></pre> <p>My idea was to call the above function when the zooming is actually done. My suspicion is that the code gets the top left offset while zooming is still performing - what causes the output to be wrong.</p> <p>If anyone can tell me why the value is wrong when zooming in or out and how to fix this I would be really greatful!</p> <p>Thanks!</p> <p>Here's an image of something identical to what I'm working on: (Curtesy of WPF-Graphics.com) <img src="https://i.stack.imgur.com/mEaQi.jpg" alt="This is a WPF control showing a main image, and a small thumb with a viewport rectangle showing the user what he&#39;s looking at"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload