MouseGesture.Matches(Object, InputEventArgs) 方法

定义

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

public:
 override bool Matches(System::Object ^ targetElement, System::Windows::Input::InputEventArgs ^ inputEventArgs);
public override bool Matches (object targetElement, System.Windows.Input.InputEventArgs inputEventArgs);
override this.Matches : obj * System.Windows.Input.InputEventArgs -> bool
Public Overrides Function Matches (targetElement As Object, inputEventArgs As InputEventArgs) As Boolean

参数

targetElement
Object

目标。

inputEventArgs
InputEventArgs

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

返回

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

示例

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

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");
    }
}
Private Overloads Sub OnMouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim mouseGesture As New MouseGesture(MouseAction.MiddleClick,ModifierKeys.Control)

    If mouseGesture.Matches(Nothing, e) Then
        MessageBox.Show("Trapped Mouse Gesture")
    End If
End Sub

适用于