|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
2 | 2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
|
3 | 3 |
|
| 4 | +using Windows.Foundation; |
| 5 | +using Windows.UI.Xaml.Controls; |
| 6 | + |
4 | 7 | namespace Windows.UI.Xaml.Controls
|
5 | 8 | {
|
6 | 9 | internal partial class SwipeTestHooks
|
7 | 10 | {
|
8 |
| - com_ptr<SwipeTestHooks> SwipeTestHooks.s_testHooks { }; |
| 11 | + //com_ptr<SwipeTestHooks> SwipeTestHooks.s_testHooks { }; |
9 | 12 |
|
10 |
| - com_ptr<SwipeTestHooks> EnsureGlobalTestHooks() |
| 13 | + public static SwipeTestHooks EnsureGlobalTestHooks() |
11 | 14 | {
|
12 |
| - static bool s_initialized = |
13 |
| - |
14 |
| - [] |
15 |
| - () |
16 |
| - |
17 |
| - { |
18 |
| - s_testHooks = winrt.new SwipeTestHooks(); |
19 |
| - return true; |
20 |
| - } |
21 |
| - (); |
22 |
| - return s_testHooks; |
| 15 | + return s_testHooks ?? new SwipeTestHooks(); |
23 | 16 | }
|
24 | 17 |
|
25 |
| - winrt.SwipeControl GetLastInteractedWithSwipeControl() |
| 18 | + public SwipeControl GetLastInteractedWithSwipeControl() |
26 | 19 | {
|
27 | 20 | return SwipeControl.GetLastInteractedWithSwipeControl();
|
28 | 21 | }
|
29 | 22 |
|
30 |
| - bool GetIsOpen(winrt.SwipeControl& swipeControl) |
| 23 | + public bool GetIsOpen(SwipeControl swipeControl) |
31 | 24 | {
|
32 |
| - if (swipeControl) |
| 25 | + if (swipeControl is { }) |
33 | 26 | {
|
34 |
| - return winrt.get_self<SwipeControl>(swipeControl).GetIsOpen(); |
| 27 | + return ((SwipeControl)swipeControl).GetIsOpen(); |
35 | 28 | }
|
36 | 29 | else
|
37 | 30 | {
|
38 |
| - if (var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl()) |
| 31 | + var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl(); |
| 32 | + if (lastInteractedWithSwipeControl is {}) |
39 | 33 | {
|
40 |
| - return winrt.get_self<SwipeControl>(lastInteractedWithSwipeControl).GetIsOpen(); |
| 34 | + return ((SwipeControl)lastInteractedWithSwipeControl).GetIsOpen(); |
41 | 35 | }
|
42 | 36 | return false;
|
43 | 37 | }
|
44 | 38 | }
|
45 | 39 |
|
46 |
| - bool GetIsIdle(winrt.SwipeControl& swipeControl) |
| 40 | + public bool GetIsIdle(SwipeControl swipeControl) |
47 | 41 | {
|
48 |
| - if (swipeControl) |
| 42 | + if (swipeControl is {}) |
49 | 43 | {
|
50 |
| - return winrt.get_self<SwipeControl>(swipeControl).GetIsIdle(); |
| 44 | + return ((SwipeControl)swipeControl).GetIsIdle(); |
51 | 45 | }
|
52 | 46 | else
|
53 | 47 | {
|
54 |
| - if (var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl()) |
| 48 | + var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl(); |
| 49 | + if (lastInteractedWithSwipeControl is { }) |
55 | 50 | {
|
56 |
| - return winrt.get_self<SwipeControl>(lastInteractedWithSwipeControl).GetIsIdle(); |
| 51 | + return ((SwipeControl)lastInteractedWithSwipeControl).GetIsIdle(); |
57 | 52 | }
|
58 | 53 | return false;
|
59 | 54 | }
|
60 | 55 | }
|
61 | 56 |
|
62 |
| - void NotifyLastInteractedWithSwipeControlChanged() |
| 57 | + public void NotifyLastInteractedWithSwipeControlChanged() |
63 | 58 | {
|
64 | 59 | var hooks = EnsureGlobalTestHooks();
|
65 |
| - if (hooks.m_lastInteractedWithSwipeControlChangedEventSource) |
| 60 | + if (hooks.m_lastInteractedWithSwipeControlChangedEventSource is {}) |
66 | 61 | {
|
67 | 62 | hooks.m_lastInteractedWithSwipeControlChangedEventSource(null, null);
|
68 | 63 | }
|
69 | 64 | }
|
70 | 65 |
|
71 |
| - winrt.event_token LastInteractedWithSwipeControlChanged(winrt.TypedEventHandler<winrt.DependencyObject, winrt.DependencyObject> & value) |
72 |
| - { |
73 |
| - var hooks = EnsureGlobalTestHooks(); |
74 |
| - return hooks.m_lastInteractedWithSwipeControlChangedEventSource.add(value); |
75 |
| - } |
76 |
| - |
77 |
| - void LastInteractedWithSwipeControlChanged(winrt.event_token & token) |
| 66 | + public event TypedEventHandler<DependencyObject, DependencyObject> LastInteractedWithSwipeControlChanged |
78 | 67 | {
|
79 |
| - var hooks = EnsureGlobalTestHooks(); |
80 |
| - hooks.m_lastInteractedWithSwipeControlChangedEventSource.remove(token); |
| 68 | + add |
| 69 | + { |
| 70 | + var hooks = EnsureGlobalTestHooks(); |
| 71 | + hooks.m_lastInteractedWithSwipeControlChangedEventSource += value; |
| 72 | + } |
| 73 | + remove |
| 74 | + { |
| 75 | + var hooks = EnsureGlobalTestHooks(); |
| 76 | + hooks.m_lastInteractedWithSwipeControlChangedEventSource -= value; |
| 77 | + } |
81 | 78 | }
|
82 | 79 |
|
83 |
| - void NotifyOpenedStatusChanged(winrt.SwipeControl& sender) |
| 80 | + public void NotifyOpenedStatusChanged(SwipeControl sender) |
84 | 81 | {
|
85 | 82 | var hooks = EnsureGlobalTestHooks();
|
86 |
| - if (hooks.m_openedStatusChangedEventSource) |
| 83 | + if (hooks.m_openedStatusChangedEventSource is {}) |
87 | 84 | {
|
88 | 85 | hooks.m_openedStatusChangedEventSource(sender, null);
|
89 | 86 | }
|
90 | 87 | }
|
91 | 88 |
|
92 |
| - winrt.event_token OpenedStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value) |
93 |
| - { |
94 |
| - var hooks = EnsureGlobalTestHooks(); |
95 |
| - return hooks.m_openedStatusChangedEventSource.add(value); |
96 |
| - } |
97 |
| - |
98 |
| - void OpenedStatusChanged(winrt.event_token & token) |
| 89 | + public event TypedEventHandler<SwipeControl, DependencyObject> OpenedStatusChanged |
99 | 90 | {
|
100 |
| - var hooks = EnsureGlobalTestHooks(); |
101 |
| - hooks.m_openedStatusChangedEventSource.remove(token); |
| 91 | + add |
| 92 | + { |
| 93 | + var hooks = EnsureGlobalTestHooks(); |
| 94 | + hooks.m_openedStatusChangedEventSource += value; |
| 95 | + } |
| 96 | + remove |
| 97 | + { |
| 98 | + var hooks = EnsureGlobalTestHooks(); |
| 99 | + hooks.m_openedStatusChangedEventSource-= value; |
| 100 | + } |
102 | 101 | }
|
103 | 102 |
|
104 |
| - void NotifyIdleStatusChanged(winrt.SwipeControl& sender) |
| 103 | + public void NotifyIdleStatusChanged(SwipeControl sender) |
105 | 104 | {
|
106 | 105 | var hooks = EnsureGlobalTestHooks();
|
107 |
| - if (hooks.m_idleStatusChangedEventSource) |
| 106 | + if (hooks.m_idleStatusChangedEventSource is {}) |
108 | 107 | {
|
109 | 108 | hooks.m_idleStatusChangedEventSource(sender, null);
|
110 | 109 | }
|
111 | 110 | }
|
112 | 111 |
|
113 |
| - winrt.event_token IdleStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value) |
114 |
| - { |
115 |
| - var hooks = EnsureGlobalTestHooks(); |
116 |
| - return hooks.m_idleStatusChangedEventSource.add(value); |
117 |
| - } |
118 |
| - |
119 |
| - void IdleStatusChanged(winrt.event_token & token) |
| 112 | + public event TypedEventHandler<SwipeControl, DependencyObject> IdleStatusChanged |
120 | 113 | {
|
121 |
| - var hooks = EnsureGlobalTestHooks(); |
122 |
| - hooks.m_idleStatusChangedEventSource.remove(token); |
| 114 | + add |
| 115 | + { |
| 116 | + var hooks = EnsureGlobalTestHooks(); |
| 117 | + hooks.m_idleStatusChangedEventSource += value; |
| 118 | + } |
| 119 | + remove |
| 120 | + { |
| 121 | + var hooks = EnsureGlobalTestHooks(); |
| 122 | + hooks.m_idleStatusChangedEventSource -= value; |
| 123 | + } |
123 | 124 | }
|
124 | 125 | }
|
125 | 126 | }
|
0 commit comments