Skip to content

Commit dcdd0fc

Browse files
committed
feat(swipecontrol): Implement SwipeTestHooks
1 parent bb90161 commit dcdd0fc

File tree

2 files changed

+86
-83
lines changed

2 files changed

+86
-83
lines changed
Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,126 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using Windows.Foundation;
5+
using Windows.UI.Xaml.Controls;
6+
47
namespace Windows.UI.Xaml.Controls
58
{
69
internal partial class SwipeTestHooks
710
{
8-
com_ptr<SwipeTestHooks> SwipeTestHooks.s_testHooks { };
11+
//com_ptr<SwipeTestHooks> SwipeTestHooks.s_testHooks { };
912

10-
com_ptr<SwipeTestHooks> EnsureGlobalTestHooks()
13+
public static SwipeTestHooks EnsureGlobalTestHooks()
1114
{
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();
2316
}
2417

25-
winrt.SwipeControl GetLastInteractedWithSwipeControl()
18+
public SwipeControl GetLastInteractedWithSwipeControl()
2619
{
2720
return SwipeControl.GetLastInteractedWithSwipeControl();
2821
}
2922

30-
bool GetIsOpen(winrt.SwipeControl& swipeControl)
23+
public bool GetIsOpen(SwipeControl swipeControl)
3124
{
32-
if (swipeControl)
25+
if (swipeControl is { })
3326
{
34-
return winrt.get_self<SwipeControl>(swipeControl).GetIsOpen();
27+
return ((SwipeControl)swipeControl).GetIsOpen();
3528
}
3629
else
3730
{
38-
if (var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl())
31+
var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl();
32+
if (lastInteractedWithSwipeControl is {})
3933
{
40-
return winrt.get_self<SwipeControl>(lastInteractedWithSwipeControl).GetIsOpen();
34+
return ((SwipeControl)lastInteractedWithSwipeControl).GetIsOpen();
4135
}
4236
return false;
4337
}
4438
}
4539

46-
bool GetIsIdle(winrt.SwipeControl& swipeControl)
40+
public bool GetIsIdle(SwipeControl swipeControl)
4741
{
48-
if (swipeControl)
42+
if (swipeControl is {})
4943
{
50-
return winrt.get_self<SwipeControl>(swipeControl).GetIsIdle();
44+
return ((SwipeControl)swipeControl).GetIsIdle();
5145
}
5246
else
5347
{
54-
if (var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl())
48+
var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl();
49+
if (lastInteractedWithSwipeControl is { })
5550
{
56-
return winrt.get_self<SwipeControl>(lastInteractedWithSwipeControl).GetIsIdle();
51+
return ((SwipeControl)lastInteractedWithSwipeControl).GetIsIdle();
5752
}
5853
return false;
5954
}
6055
}
6156

62-
void NotifyLastInteractedWithSwipeControlChanged()
57+
public void NotifyLastInteractedWithSwipeControlChanged()
6358
{
6459
var hooks = EnsureGlobalTestHooks();
65-
if (hooks.m_lastInteractedWithSwipeControlChangedEventSource)
60+
if (hooks.m_lastInteractedWithSwipeControlChangedEventSource is {})
6661
{
6762
hooks.m_lastInteractedWithSwipeControlChangedEventSource(null, null);
6863
}
6964
}
7065

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
7867
{
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+
}
8178
}
8279

83-
void NotifyOpenedStatusChanged(winrt.SwipeControl& sender)
80+
public void NotifyOpenedStatusChanged(SwipeControl sender)
8481
{
8582
var hooks = EnsureGlobalTestHooks();
86-
if (hooks.m_openedStatusChangedEventSource)
83+
if (hooks.m_openedStatusChangedEventSource is {})
8784
{
8885
hooks.m_openedStatusChangedEventSource(sender, null);
8986
}
9087
}
9188

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
9990
{
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+
}
102101
}
103102

104-
void NotifyIdleStatusChanged(winrt.SwipeControl& sender)
103+
public void NotifyIdleStatusChanged(SwipeControl sender)
105104
{
106105
var hooks = EnsureGlobalTestHooks();
107-
if (hooks.m_idleStatusChangedEventSource)
106+
if (hooks.m_idleStatusChangedEventSource is {})
108107
{
109108
hooks.m_idleStatusChangedEventSource(sender, null);
110109
}
111110
}
112111

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
120113
{
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+
}
123124
}
124125
}
125126
}
Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,60 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using Windows.Foundation;
5+
46
#pragma once
57

68
namespace Windows.UI.Xaml.Controls
79
{
810
internal partial class SwipeTestHooks
911
{
12+
//class SwipeTestHooks :
1013

11-
class SwipeTestHooks :
12-
13-
public winrt.implementation.SwipeTestHooksT<SwipeTestHooks>
14-
{
14+
//public implementation.SwipeTestHooksT<SwipeTestHooks>
15+
//{
1516

16-
public:
17+
//public:
1718

18-
static com_ptr<SwipeTestHooks> GetGlobalTestHooks()
19+
public static SwipeTestHooks GetGlobalTestHooks()
1920
{
2021
return s_testHooks;
2122
}
2223

23-
static com_ptr<SwipeTestHooks> EnsureGlobalTestHooks();
24+
//static com_ptr<SwipeTestHooks> EnsureGlobalTestHooks();
25+
26+
//static SwipeControl GetLastInteractedWithSwipeControl();
2427

25-
static winrt.SwipeControl GetLastInteractedWithSwipeControl();
28+
//static bool GetIsOpen(SwipeControl& swipeControl);
2629

27-
static bool GetIsOpen(winrt.SwipeControl& swipeControl);
30+
//static bool GetIsIdle(SwipeControl& swipeControl);
2831

29-
static bool GetIsIdle(winrt.SwipeControl& swipeControl);
32+
//static void NotifyLastInteractedWithSwipeControlChanged();
3033

31-
static void NotifyLastInteractedWithSwipeControlChanged();
34+
//static event_token LastInteractedWithSwipeControlChanged(TypedEventHandler<DependencyObject, DependencyObject> & value);
3235

33-
static winrt.event_token LastInteractedWithSwipeControlChanged(winrt.TypedEventHandler<winrt.DependencyObject, winrt.DependencyObject> & value);
36+
//static void LastInteractedWithSwipeControlChanged(event_token & token);
3437

35-
static void LastInteractedWithSwipeControlChanged(winrt.event_token & token);
38+
//static void NotifyOpenedStatusChanged(SwipeControl& sender);
3639

37-
static void NotifyOpenedStatusChanged(winrt.SwipeControl& sender);
40+
//static event_token OpenedStatusChanged(TypedEventHandler<SwipeControl, DependencyObject> & value);
3841

39-
static winrt.event_token OpenedStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value);
42+
//static void OpenedStatusChanged(event_token & token);
4043

41-
static void OpenedStatusChanged(winrt.event_token & token);
44+
//static void NotifyIdleStatusChanged(SwipeControl& sender);
4245

43-
static void NotifyIdleStatusChanged(winrt.SwipeControl& sender);
46+
//static event_token IdleStatusChanged(TypedEventHandler<SwipeControl, DependencyObject> & value);
4447

45-
static winrt.event_token IdleStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value);
48+
//static void IdleStatusChanged(event_token & token);
4649

47-
static void IdleStatusChanged(winrt.event_token & token);
50+
//private:
4851

49-
private:
52+
private static SwipeTestHooks s_testHooks;
5053

51-
static com_ptr<SwipeTestHooks> s_testHooks;
52-
winrt.event<winrt.TypedEventHandler<winrt.DependencyObject, winrt.DependencyObject>> m_lastInteractedWithSwipeControlChangedEventSource;
54+
private event TypedEventHandler<DependencyObject, DependencyObject> m_lastInteractedWithSwipeControlChangedEventSource;
5355

54-
winrt.event<winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject>> m_openedStatusChangedEventSource;
56+
private event TypedEventHandler<SwipeControl, DependencyObject> m_openedStatusChangedEventSource;
5557

56-
winrt.event<winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject>> m_idleStatusChangedEventSource;
57-
};
58-
}}
58+
private event TypedEventHandler<SwipeControl, DependencyObject> m_idleStatusChangedEventSource;
59+
}
60+
}

0 commit comments

Comments
 (0)