gpt4 book ai didi

c# - 按住右键单击与 Manipulation 事件冲突

转载 作者:太空宇宙 更新时间:2023-11-03 17:01:30 24 4
gpt4 key购买 nike

我正在使用 Manipulation 事件(IsManipulationEnabledManipulationDelta 等)来移动和缩放图像。这很好用。我还想使用右键单击创建一个矩形选区以在图像上定义一个区域(拖放,通常的方式,只有右键单击)。在触摸(Surface)和非触摸(Win 7)设备上使用鼠标都可以正常工作。虽然,当在 Surface 上“右键单击”(因此用手指点击并按住)时,我看到典型的小方 block 出现,但是当我在那之后移动手指时,它会移动图像,而不是绘制矩形。看起来 Manipulation 事件优先于“手指右键单击”。我做错了什么?

 <Grid
Name="theGrid"
MouseMove="OnMouseMove"
MouseRightButtonUp="theGrid_MouseRightButtonUp"
MouseRightButtonDown="theGrid_MouseRightButtonDown"
Background="Black">

<Rectangle Name="RectangleContainingBackgroundImage"
IsManipulationEnabled="True"
RenderTransform="{Binding Path=ImageTransform}">
<Rectangle.Fill>
<ImageBrush x:Name="BackgroundImage" Stretch="Uniform"/>
</Rectangle.Fill>
</Rectangle>

开始时:

ScreenTouchManager touchManager = new ScreenTouchManager(this.theGrid);
this.RectangleContainingBackgroundImage.ManipulationStarting += touchManager.Image_ManipulationStarting;
this.RectangleContainingBackgroundImage.ManipulationDelta += touchManager.Image_ManipulationDelta;
this.DataContext = touchManager;

在 ScreenTouchManager 中:

public void Image_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
{
// Ask for manipulations to be reported relative to the grid
e.ManipulationContainer = this.ManipContainer; // MC = constructor param
}

谢谢。

最佳答案

我做了一项研究,可能会在这里找到答案:http://www.mobilemotion.eu/?p=1396&lang=en

The VisualState changes are triggered by dedicated mouse events: For example, the Pressed state is reached when the button’s OnMouseLeftButtonDown event occurs. The finger touch-and-hold event is usually mapped to a click with the right mouse button (when tapping on the screen and not instantly releasing the finger, Windows interprets this as right-click operation) – the OnMouseLeftButtonDown event never fires, and the Pressed state is never reached!

希望这对您有所帮助。

关于c# - 按住右键单击与 Manipulation 事件冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29558240/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com