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关联的输入是否InputEventArgs匹配。 MouseDown事件处理程序使用MouseGesture该方法将事件数据与Matches该数据进行比较。

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

适用于