Pergunta

Eu estou tentando fazer GMap.Net controle multitouch habilitado, usando WPF construir-em eventos, mas eu não era bem-sucedida.

Eu encontrei uma série de artigos sobre multitouch como este e este um.Em todos eles, ManipulationContainer é uma tela móvel e controles colocados sobre ele, mas no GMap problema ManipulationContainer é GMapControl e não há nenhum controle sobre ele.como posso usar e.ManipulationDelta dados para aumentar o Zoom e Mover?

O GMapControl tem um Zoom propriedade que, por aumento ou diminuindo-a, você pode ampliar ou diminuir o zoom.

Foi útil?

Solução

Uma rápida olhada no código mostra que o GMapControl é um ItemsContainer.

Você deve ser capaz de revolucionar o ItemsPanel modelo e fornecer o IsManipulationEnabled propriedade:

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

Neste ponto, você precisa conectar o Window:

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

E fornecimento de métodos apropriados no Code-Behind (descaradamente roubado e adaptado a partir desse MSDN passo a passo):

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top