我在努力 GMap.Net 控制多点触控启用,使用WPF内置事件,但我没有成功。

我发现了一系列关于多点触控的文章 一个。在所有的人, ManipulationContainer 是一个画布和可移动的控件放在上面,但在GMap问题 ManipulationContainerGMapControl 而且无法控制它。我该如何使用 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">

并在后面的代码中提供适当的方法(无耻地窃取并改编自此 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