Mapsui on Surface

Aug 2, 2011 at 8:31 AM

2 Years ago I started experimenting with Brutile on the MS Surface and now I am starting again to experimenting with Mapsui again.
However the Surface libraries are not maintained at the moment and they target WPF3.5 whereas the new libraries all target WPF4.0. Any idea how I can get the latest Mapsui release to work on the Surface table again? I understand I cannot target WPF4 when using the Surface1.0SP1 SDK.

Cheers,
Koen

Aug 4, 2011 at 4:40 PM

Hi Koen,

I do not plan to maintain the Surface.sln myself and was thinking about retiring it since I have not developed for the Surface in a year and do not have the SDK installed right now. If you are willing you could maintain it yourself. I added you as a developer. 

Only the Mapsui.Wpf project is 4.0 but the only thing the Mapsui.Surface project uses from it is the MapTransformHelper.cs. Copy this to the Surface project and then remove the reference to Mapsui.Wpf. Then you should have no problems with 4.0 projects and a lot of compile errors :)  Hopefully it is not so hard to update the surface.sln to the latests version of Mapsui. I am willing to help with it.

cheers,

Paul

Aug 4, 2011 at 7:56 PM
Edited Aug 5, 2011 at 7:51 AM

Hi Paul,

Thanks for your reply. I already started experimenting and decided to first add multitouch functionality to the exisiting Mapsui.WPF using the new Win7 multitouch methods (TouchUp, Manipulation, etc.) Unfortunately the WPF4.0 multitouch is not compatible with the Surface 1-multitouch, so I will try to fix that later.

This is the basic code I used to add multitouch (inertia and pinch-to-zoom) to the current release. It works perfectly on my touchscreen-laptop!

(Of course don't forget to add the necessary handlers somewhere in the constructor)

 

 

void MapControl_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {

            var currentPosition = new Point(e.ManipulationOrigin.X + e.DeltaManipulation.Translation.X,
                                            e.ManipulationOrigin.Y + e.DeltaManipulation.Translation.Y);
            var previousPosition = new Point(e.ManipulationOrigin.X, 
                                             e.ManipulationOrigin.Y);

            MapTransformHelper.Pan(view, currentPosition, previousPosition);
            
            if (e.DeltaManipulation.Scale.X != 1.0 ) {

                // pinch-to-zoom gestures will be translated internally by the manipulation processor of .Net

                var newResolution = view.Resolution / e.DeltaManipulation.Scale.X;
             
                view.Center = view.ViewToWorld(currentPosition.X, currentPosition.Y);
                view.Resolution = newResolution;
                
                view.Center = view.ViewToWorld(view.Width - currentPosition.X,
                                               view.Height - currentPosition.Y);

            }
                        
            OnViewChanged(true, true);
            Redraw();

        }


        void MapControl_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            e.TranslationBehavior.DesiredDeceleration = 10 * 96.0 / (1000.0 * 1000.0);
 
        // Decrease the velocity of the Rectangle's resizing by 
        // 0.1 inches per second every second.
        // (0.1 inches * 96 pixels per inch / (1000ms^2)
            e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / 1000.0 * 1000.0;
 
        // Decrease the velocity of the Rectangle's rotation rate by 
        // 2 rotations per second every second.
        // (2 * 360 degrees / (1000ms^2)
            e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);

            e.Handled = true;
        }


        void MapControl_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
        {

            e.Handled = true;

        }



 

Apr 29, 2012 at 4:55 PM

Hi,

I am using MS Surface 2 and have problems to implement multi-touch. At the moment I am using the mouse simulation from the Tabletop, but only panning works, zooming doesn't.

My first question is, why is zooming with the mouse simulation not working?

And how can I get the panning and zooming events from the MS Surfece 2 Table?

 

Thank You :)

Apr 30, 2012 at 4:30 PM

What are you using? We now use Mapsui on Surface 2. I think we use the WPF4 Touch Support in the MapControl. But I am not exactly sure if there is Touch code in our client that is not in Mapsui.

We do not use Surface.sln anymore and it should be removed.

Paul