I'm using zoom panel for viewing and designing some kind of floor plans. I need feature when drawing my elements (lines, rectangles, etc.) that view automatically move (pan) when mouse try to go out of viewbox. How I can do this?
This is an interesting question.
To move the content of ZoomPanel from code you can use many methods, but probably the easiest to use is TranslateNow - for example:
You can see a sample on how to handle mouse mouse events to manually move the content with TranslateNow method if you check the source of the ManualZoomPanelControl.cs file in the ZoomPanel samples.
But this is only the simple part of the answer.
Now comes the tricky part.
The problem is that it is hard to get mouse events when mouse goes out of your control - for example if you subscribe to MouseMove event on ZoomPanel, you will not get that event when mouse is not over ZoomPanel. If there is some border or some other control around ZoomPanel, then you can also subscribe there. But still if mouse will go outside your application you will not get mouse events.
A solution to this is to call CaptureMouse method on ZoomPanel (or any other element that you have subscribed to MouseMove) - from that point on all mouse events will go only to this control - even if mouse is over the edge of your application (you can release mouse capture with ReleaseMouseCapture) - this is also demonstrated in the ManualZoomPanelControl sample - but there it is used only when mouse button is pressed over ZoomPanel.
If you would call CaptureMouse without any button pressed, then all mouse event will get to your control and no other part of UI (including Windows controls and other applications) will not get any mouse event. So this can be a serious problem. But maybe you will be fine with that if you will use a special keyboard to turn this mode on and off.
Another approach (better in my opinion) is to subscribe to MouseMove event on ZoomPanel and then define an invisible area at the edge of the ZoomPanel - for example 50 outer pixels of the ZoomPanel - if user would enter this area with the mouse, you would call TranslateNow method. You can translate only slightly when user just enters this ares (for example is 45 pixels from the edge of ZoomPanel) and translate more when user is on the edge. But if user would exit the ZoomPanel, there will be no translation.
I hope that any of those solutions will work well for you.