2012-02-29 3 views
3

Я пытаюсь сделать GMap.Net контроль мультитач включен, используя встроенные события WPF, но я не был успешным.Масштабирование и панорамирование в GMap.net

Я нашел серию статей о мультитач, таких как this и this. Во всех из них ManipulationContainer представляет собой холст и движимые элементы управления, расположенные на нем, но в выпуске GMap ManipulationContainer находится GMapControl, и нет никакого контроля над ним. как я могу использовать данные e.ManipulationDelta для увеличения и перемещения?

GMapControl имеет свойство Zoom, которое, увеличив или уменьшив его, вы можете уменьшить или уменьшить.

ответ

3

Быстрый взгляд на код показывает, что GMapControl is an ItemsContainer.

Вы должны быть в состоянии Преобрази ItemsPanel шаблон и поставить IsManipulationEnabled свойство там:

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

На этом этапе вы должны проволоки до Window:

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

и поставить соответствующие методы в кодексе (бесстыдно украдены и адаптированы из этого MSDN Walkthrough):

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; 
}