-
Notifications
You must be signed in to change notification settings - Fork 500
/
Copy pathBlankPage.xaml.cs
56 lines (52 loc) · 1.74 KB
/
BlankPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//<snippetCode>
using System.Collections.Generic;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
namespace PointerExample
{
public sealed partial class BlankPage : Page
{
Dictionary<uint, Point?> _contacts;
const uint SUPPORTEDCONTACTS = 5;
public BlankPage()
{
this.InitializeComponent();
_contacts = new Dictionary<uint, Point?>((int)SUPPORTEDCONTACTS);
this.PointerPressed += BlankPage_PointerPressed;
this.PointerReleased += BlankPage_PointerReleased;
}
private void BlankPage_PointerPressed(object sender,
PointerRoutedEventArgs e)
{
// Ignore mouse inputs.
if (e.Pointer.PointerDeviceType !=
Windows.Devices.Input.PointerDeviceType.Mouse)
{
// Store and touch input contacts.
Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this);
_contacts[e.Pointer.PointerId] = pt.Position;
}
e.Handled = true;
}
private void BlankPage_PointerReleased(object sender,
PointerRoutedEventArgs e)
{
// Ignore mouse inputs.
if (e.Pointer.PointerDeviceType !=
Windows.Devices.Input.PointerDeviceType.Mouse)
{
// Remove pointer contacts information.
uint ptrId = e.Pointer.PointerId;
if (_contacts.ContainsKey(ptrId))
{
_contacts[ptrId] = null;
_contacts.Remove(ptrId);
}
}
e.Handled = true;
}
}
}
//</snippetCode>