Pan, Zoom, Extent buttons in a WPF app

1
gcargile
7/8/2021 1:29 PM

Good Morning Wout,

How can I implement zoom, pan, and extent buttons in a WPF (.NET 4.8) app?

Basically, pan a dwg, 10 pixels up, down, left, or right. Apply extent after panning and zooming.

I've looked at the examples but they've been for mouse events instead of button events.

gcargile
7/12/2021 11:10 AM

I looked at this thread - https://www.woutware.com/Forum/Topic/2073 but the code for using SimpleTranformProvider2D to do so wasn't there.

gcargile
7/13/2021 1:20 PM

Using the code from the examples (WpfViewApplicationCS), I'm able to get pan and zoom working, but zoom is giving some trouble.

My app is a single page app (ie. MainWindow has a ContentControl which calls other UserControls as you navigate from page to page.). The zoom in the example works perfectly. But the example is just a window. When you have a canvas in a usercontrol in a window, the zoom doesn't work as well.

The behavior showing now is that the dwg zooms away from or to wherever the mouse pointer is. How do I fix this problem?

Wout
7/15/2021 1:16 PM

Sounds like your mouse coordinates have some incorrect offset. If you can send me your VS solution to test I'll have a look at it.

- Wout

Wout
7/16/2021 12:12 PM

Just to be clear, you want to zoom using the mouse? Because the example shows zooming with the mouse around the mouse position, so what you describe is exactly what zooming normally does.

- Wout

1