문제

만들려고 노력 중이야 GMap.Net WPF 내장 이벤트를 사용하여 멀티터치를 활성화했지만 성공하지 못했습니다.

다음과 같은 멀티터치에 관한 일련의 기사를 찾았습니다. 이것 그리고 이것 하나.그들 모두에서, ManipulationContainer 캔버스와 그 위에 배치된 이동 가능한 컨트롤이지만 GMap 문제에서는 ManipulationContainer ~이다 GMapControl 그리고 그것을 통제할 수 없습니다.어떻게 사용하나요? e.ManipulationDelta 데이터를 확대/축소하고 이동하시겠습니까?

그만큼 GMapControl 가지고있다 Zoom 속성을 늘리거나 줄여서 확대하거나 축소할 수 있습니다.

도움이 되었습니까?

해결책

코드를 잠깐 살펴보면 GMapControl 이다 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">

그리고 Code Behind에서 적절한 방법을 제공합니다(이로부터 뻔뻔스럽게 도난당하고 개조됨). 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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top