1

enter image description here

This is an example of the form I have created. The minimap will show anything that I have drawn in the main area.

Notice the RED COLOR BOX in the minimap. The red color box will follow my mouse cursor once the mouse enter the minimap.

What I wanted to achieve is that I click on any part of the minimap that I wanted, the main form will scroll to the position that I clicked in the minimap. Eg. https://docs.devexpress.com/WindowsForms/17894/Controls-and-Libraries/Map-Control/End-User-Features/Mini-Map

I used AutoScrollPosition but seems like something wrong with my calculation for coordinate. Any hints or help for calculating the coordinate? Thanks

public void moveTo(double x, double y)
    {
       /*Calculation for the coordinate*/
        panel1.AutoScrollPosition = new Point((int)g, (int)f);
    }
Ron
  • 37
  • 5
  • If `g` and `f` are the minimap coordinates, then you'll presumably have to multiply them by some factor to get the real image coordinates. – ProgrammingLlama Aug 27 '19 at 02:11
  • yeah, still figuring how to do the factor things – Ron Aug 27 '19 at 02:17
  • 1
    See both answers here: [Translate Rectangle Position in Zoom Mode Picturebox](https://stackoverflow.com/q/53800328/7444103) and this one [here](https://stackoverflow.com/a/56128394/7444103). There are tools ready to use that perform these calculations. – Jimi Aug 27 '19 at 02:27
  • About the scrolling, you can set the `[Container].VerticalScroll.Maximum = [Container].PreferredSize.Height;`, then determine whether a point is inside the visible client area and if not, set `[Container].VerticalScroll.Value = [The new position]`. The `VerticalScroll.Maximum` value can be set in the `HandleCreated` event and must be re-set in the `Resize` event (or the corresponding, overridden, methods in a custom control). – Jimi Aug 27 '19 at 02:41
  • Alright. Will have a look on it. Thanks – Ron Aug 27 '19 at 02:49
  • Have a look at [this](https://stackoverflow.com/questions/45072620/get-position-of-cursor-on-panel-with-scrollbars/45074927#45074927) - Note the remark on sign! – TaW Aug 27 '19 at 05:53

0 Answers0