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

Данные события ввода для сравнения с этим жестом.

Возвращаемое значение

true, если данные события ввода соответствуют этому MouseGesture, в противном случае — false.

Примеры

В следующем примере показано, как проверить, соответствует ли 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

Применяется к