MouseGesture.Matches(Object, InputEventArgs) 方法
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定 MouseGesture 是否和与指定 InputEventArgs 对象关联的输入匹配。
public:
override bool Matches(System::Object ^ targetElement, System::Windows::Input::InputEventArgs ^ inputEventArgs);
C#
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 进行比较。
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");
}
}
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
产品 | 版本 |
---|---|
.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 |