MouseGesture.Matches(Object, InputEventArgs) 方法

定义

确定 MouseGesture 是否和与指定 InputEventArgs 对象关联的输入匹配。

C#
public override bool Matches (object targetElement, System.Windows.Input.InputEventArgs inputEventArgs);

参数

targetElement
Object

目标。

inputEventArgs
InputEventArgs

要与此笔势进行比较的输入事件数据。

返回

如果事件数据与此 MouseGesture 匹配,则为 true;否则为 false

示例

以下示例演示如何测试 是否 MouseGesture 与 与 实例 InputEventArgs关联的输入匹配。 事件处理程序MouseDown使用 Matches 方法将事件数据与 MouseGesture 进行比较。

C#
private void OnMouseDown(object sender, MouseEventArgs e)
{
    MouseGesture mouseGesture = new MouseGesture(MouseAction.MiddleClick,ModifierKeys.Control);

    if (mouseGesture.Matches(null, e))
    {
        MessageBox.Show("Trapped Mouse Gesture");
    }
}

适用于

产品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9