-
Notifications
You must be signed in to change notification settings - Fork 878
Expand file tree
/
Copy pathManipulationEvents.xaml.cs
More file actions
59 lines (52 loc) · 1.93 KB
/
Copy pathManipulationEvents.xaml.cs
File metadata and controls
59 lines (52 loc) · 1.93 KB
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
57
58
59
using System;
using System.Linq;
using Windows.UI;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Uno.UI.Samples.Controls;
#if HAS_UNO_WINUI || WINAPPSDK
using Microsoft.UI.Input;
#else
using Windows.Devices.Input;
#endif
namespace UITests.Shared.Windows_UI_Input.GestureRecognizerTests
{
[Sample("Gesture Recognizer", "Pointers", IgnoreInSnapshotTests = true)]
public sealed partial class ManipulationEvents : Page
{
public ManipulationEvents()
{
this.InitializeComponent();
SizeChanged += (snd, e) => System.Diagnostics.Debug.WriteLine($"Size: {e.NewSize}");
PointerMoved += (snd, e) => System.Diagnostics.Debug.WriteLine($"Pointer: {e.GetCurrentPoint(this).Position}");
_thumb.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
_thumb.ManipulationStarted += (snd, e) =>
{
_thumb.Background = new SolidColorBrush(Colors.Blue);
Move(e.Cumulative, e.Cumulative);
};
_thumb.ManipulationDelta += (snd, e) =>
{
Move(e.Delta, e.Cumulative);
};
_thumb.ManipulationCompleted += (snd, e) =>
{
Move(new ManipulationDelta { Scale = 1 }, e.Cumulative);
_thumb.Background = new SolidColorBrush(Colors.Red);
};
}
private void Move(ManipulationDelta delta, ManipulationDelta cumulative)
{
var deltaTransform = _thumbTranslate;
deltaTransform.X -= delta.Translation.X;
deltaTransform.Y -= delta.Translation.Y;
var cumulativeTransform = _thumbShadowTranslate;
cumulativeTransform.X = -cumulative.Translation.X;
cumulativeTransform.Y = -cumulative.Translation.Y;
System.Diagnostics.Debug.WriteLine(
$"X: {cumulative.Translation.X:' '000.00;'-'000.00} (Δ: {delta.Translation.X:' '00.00;'-'00.00} Σ: {deltaTransform.X:' '000.00;'-'000.00}) " +
$"Y: {cumulative.Translation.Y:' '000.00;'-'000.00} (Δ: {delta.Translation.Y:' '00.00;'-'00.00} Σ: {deltaTransform.Y:' '000.00;'-'000.00}) ");
}
}
}