0

I'm using Mapsui as a mapping control in a C# application. By default, panning is initiated by dragging using the left mouse button. I want to change this to the middle mouse button.

Does anyone know how to do this?

Mapsui has an object called PanMode, you can create an instance as follows, however, I believe it is just an enum for centering the map when panning:

Mapsui.UI.PanMode panMode = new PanMode();

EDIT:

Based on what 'pauldendulk's' answer (thank you for your support) I think I need to do something like this:

First, catch the middle button click and relay it to the mapsui left button method. Unfortuantly MapControlMouseLeftButtonDown() is a private method so this will not work.

MyMapControl.MouseDown += MapControlOnMouseButtonDown;

private void MapControlOnMouseButtonDown(object sender, MouseButtonEventArgs e)
    {
        if(e.ChangedButton == MouseButton.Middle)
        {
            Mapsui.UI.Wpf.MapControl.MapControlMouseLeftButtonDown(sender, e);
        }

    }

Secondly I need to stop the origional left button click from firing.

MyMapControl.MouseLeftButtonDown += null;

Again, this is not correct syntax as it throws an exception (cannot be null).

Does anyone know how to solve these issues?

Richard
  • 439
  • 3
  • 25

1 Answers1

0

Mapsui was not designed with this in mind. Perhaps it is possible if you assign an event handler to WPFs mouse down event, set the viewport in there. Also, you need to suppress the regular mouse event. Perhaps this is possible by setting the MouseLeftButtonDown event handler to null.

PanMode is not relevant. It is meant to limit the area where users can pan/zoom.

pauldendulk
  • 1,378
  • 12
  • 23
  • Thank you for your help. I've been scratching my head trying to implement your suggestions but I've had no luck as yet (workings shown in the edit). If you have any pointers that would be great. Thanks. – Richard Sep 11 '18 at 19:57
  • Not sure how to remove all events. Perhaps this can help https://stackoverflow.com/questions/91778/how-to-remove-all-event-handlers-from-an-event – pauldendulk Sep 11 '18 at 21:21
  • When adding your own event handler don't call the mouse down event (those handlers should be removed) but use another method, like Map.NavigateTo. – pauldendulk Sep 11 '18 at 21:24