Pregunta

estoy tratando de hacer GMap.Net control multitáctil habilitado, usando eventos integrados de WPF, pero no tuve éxito.

Encontré una serie de artículos sobre multitáctil como este y este uno.En todos ellos, ManipulationContainer es un lienzo y controles móviles colocados en él, pero en el problema de GMap ManipulationContainer es GMapControl y no hay control sobre ello.¿Cómo puedo usar? e.ManipulationDelta datos para hacer zoom y mover?

El GMapControl tiene un Zoom propiedad que al aumentarla o disminuirla, puede acercarla o alejarla.

¿Fue útil?

Solución

Un vistazo rápido al código muestra que el GMapControl es un ItemsContainer.

Deberías poder cambiar el estilo del ItemsPanel plantilla y suministrar el IsManipulationEnabled propiedad allí:

<g:GMapControl x:Name="Map" ...>
   <g:GMapControl.ItemsPanel>
       <ItemsPanelTemplate>
           <Canvas IsManipulationEnabled="True" />
       </ItemsPanelTemplate>
   </g:GMapControl.ItemsPanel>
   <!-- ... -->

En este punto es necesario conectar el Window:

<Window ...
    ManipulationStarting="Window_ManipulationStarting"
    ManipulationDelta="Window_ManipulationDelta"
    ManipulationInertiaStarting="Window_InertiaStarting">

Y proporcione los métodos apropiados en el Código Detrás (descaradamente robado y adaptado de este Tutorial de MSDN):

void Window_ManipulationStarting(
    object sender, ManipulationStartingEventArgs e)
{
    e.ManipulationContainer = this;
    e.Handled = true;
}

void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    // uses the scaling value to supply the Zoom amount
    this.Map.Zoom = e.DeltaManipulation.Scale.X;
    e.Handled = true;
}

void Window_InertiaStarting(
    object sender, ManipulationInertiaStartingEventArgs e)
{
    // 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);
    e.Handled = true;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top