0
votes

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?

1
Which version do you use? - pauldendulk

1 Answers

0
votes

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.