@@ -39,26 +39,8 @@ namespace Files
39
39
{
40
40
sealed partial class App : Application
41
41
{
42
- public static IMultitaskingControl MultitaskingControl = null ;
43
-
44
- private static IShellPage currentInstance ;
45
42
private static bool ShowErrorNotification = false ;
46
43
47
- public static IShellPage CurrentInstance
48
- {
49
- get
50
- {
51
- return currentInstance ;
52
- }
53
- set
54
- {
55
- if ( value != currentInstance && value != null )
56
- {
57
- currentInstance = value ;
58
- }
59
- }
60
- }
61
-
62
44
public static SettingsViewModel AppSettings { get ; set ; }
63
45
public static InteractionViewModel InteractionViewModel { get ; set ; }
64
46
public static JumpListManager JumpList { get ; } = new JumpListManager ( ) ;
@@ -73,6 +55,7 @@ public App()
73
55
InitializeComponent ( ) ;
74
56
Suspending += OnSuspending ;
75
57
LeavingBackground += OnLeavingBackground ;
58
+
76
59
// Initialize NLog
77
60
StorageFolder storageFolder = ApplicationData . Current . LocalFolder ;
78
61
LogManager . Configuration . Variables [ "LogPath" ] = storageFolder . Path ;
@@ -99,92 +82,9 @@ private async void StartAppCenter()
99
82
100
83
private void OnLeavingBackground ( object sender , LeavingBackgroundEventArgs e )
101
84
{
102
- // Need to reinitialize AppService when app is resuming
103
- InitializeAppServiceConnection ( ) ;
104
85
AppSettings ? . DrivesManager ? . ResumeDeviceWatcher ( ) ;
105
86
}
106
87
107
- public static AppServiceConnection Connection ;
108
-
109
- private async void InitializeAppServiceConnection ( )
110
- {
111
- Connection = new AppServiceConnection ( ) ;
112
- Connection . AppServiceName = "FilesInteropService" ;
113
- Connection . PackageFamilyName = Package . Current . Id . FamilyName ;
114
- Connection . RequestReceived += Connection_RequestReceived ;
115
- Connection . ServiceClosed += Connection_ServiceClosed ;
116
-
117
- AppServiceConnectionStatus status = await Connection . OpenAsync ( ) ;
118
- if ( status != AppServiceConnectionStatus . Success )
119
- {
120
- // TODO: error handling
121
- Connection . Dispose ( ) ;
122
- Connection = null ;
123
- }
124
-
125
- // Launch fulltrust process
126
- await FullTrustProcessLauncher . LaunchFullTrustProcessForCurrentAppAsync ( ) ;
127
- }
128
-
129
- private void Connection_ServiceClosed ( AppServiceConnection sender , AppServiceClosedEventArgs args )
130
- {
131
- Connection = null ;
132
- }
133
-
134
- private async void Connection_RequestReceived ( AppServiceConnection sender , AppServiceRequestReceivedEventArgs args )
135
- {
136
- // Get a deferral because we use an awaitable API below to respond to the message
137
- // and we don't want this call to get cancelled while we are waiting.
138
- var messageDeferral = args . GetDeferral ( ) ;
139
-
140
- // The fulltrust process signaled that something in the recycle bin folder has changed
141
- if ( args . Request . Message . ContainsKey ( "FileSystem" ) )
142
- {
143
- var folderPath = ( string ) args . Request . Message [ "FileSystem" ] ;
144
- var itemPath = ( string ) args . Request . Message [ "Path" ] ;
145
- var changeType = ( string ) args . Request . Message [ "Type" ] ;
146
- var newItem = JsonConvert . DeserializeObject < ShellFileItem > ( args . Request . Message . Get ( "Item" , "" ) ) ;
147
- Debug . WriteLine ( "{0}: {1}" , folderPath , changeType ) ;
148
- await CoreApplication . MainView . ExecuteOnUIThreadAsync ( async ( ) =>
149
- {
150
- // If we are currently displaying the reycle bin lets refresh the items
151
- if ( CurrentInstance . FilesystemViewModel ? . CurrentFolder ? . ItemPath == folderPath )
152
- {
153
- switch ( changeType )
154
- {
155
- case "Created" :
156
- CurrentInstance . FilesystemViewModel . AddFileOrFolderFromShellFile ( newItem ) ;
157
- break ;
158
-
159
- case "Deleted" :
160
- await CurrentInstance . FilesystemViewModel . RemoveFileOrFolder ( itemPath ) ;
161
- break ;
162
-
163
- default :
164
- CurrentInstance . FilesystemViewModel . RefreshItems ( ) ;
165
- break ;
166
- }
167
- }
168
- } ) ;
169
- }
170
-
171
- // Complete the deferral so that the platform knows that we're done responding to the app service call.
172
- // Note for error handling: this must be called even if SendResponseAsync() throws an exception.
173
- messageDeferral . Complete ( ) ;
174
- }
175
-
176
- private void CoreWindow_PointerPressed ( CoreWindow sender , PointerEventArgs args )
177
- {
178
- if ( args . CurrentPoint . Properties . IsXButton1Pressed )
179
- {
180
- NavigationActions . Back_Click ( null , null ) ;
181
- }
182
- else if ( args . CurrentPoint . Properties . IsXButton2Pressed )
183
- {
184
- NavigationActions . Forward_Click ( null , null ) ;
185
- }
186
- }
187
-
188
88
public static INavigationControlItem rightClickedItem ;
189
89
190
90
public static void UnpinItem_Click ( object sender , RoutedEventArgs e )
@@ -256,10 +156,7 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e)
256
156
257
157
// Ensure the current window is active
258
158
Window . Current . Activate ( ) ;
259
- Window . Current . CoreWindow . PointerPressed += CoreWindow_PointerPressed ;
260
159
Window . Current . CoreWindow . Activated += CoreWindow_Activated ;
261
- var currentView = SystemNavigationManager . GetForCurrentView ( ) ;
262
- currentView . BackRequested += Window_BackRequested ;
263
160
}
264
161
}
265
162
@@ -273,19 +170,6 @@ private void CoreWindow_Activated(CoreWindow sender, WindowActivatedEventArgs ar
273
170
}
274
171
}
275
172
276
- private void Window_BackRequested ( object sender , BackRequestedEventArgs e )
277
- {
278
- if ( CurrentInstance . ContentFrame . CanGoBack )
279
- {
280
- e . Handled = true ;
281
- NavigationActions . Back_Click ( null , null ) ;
282
- }
283
- else
284
- {
285
- e . Handled = false ;
286
- }
287
- }
288
-
289
173
protected override async void OnActivated ( IActivatedEventArgs args )
290
174
{
291
175
Logger . Info ( "App activated" ) ;
@@ -316,9 +200,7 @@ protected override async void OnActivated(IActivatedEventArgs args)
316
200
317
201
// Ensure the current window is active.
318
202
Window . Current . Activate ( ) ;
319
- Window . Current . CoreWindow . PointerPressed += CoreWindow_PointerPressed ;
320
203
Window . Current . CoreWindow . Activated += CoreWindow_Activated ;
321
- currentView . BackRequested += Window_BackRequested ;
322
204
return ;
323
205
324
206
case ActivationKind . CommandLineLaunch :
@@ -340,9 +222,7 @@ protected override async void OnActivated(IActivatedEventArgs args)
340
222
341
223
// Ensure the current window is active.
342
224
Window . Current . Activate ( ) ;
343
- Window . Current . CoreWindow . PointerPressed += CoreWindow_PointerPressed ;
344
225
Window . Current . CoreWindow . Activated += CoreWindow_Activated ;
345
- currentView . BackRequested += Window_BackRequested ;
346
226
return ;
347
227
348
228
case ParsedCommandType . OpenPath :
@@ -355,9 +235,7 @@ protected override async void OnActivated(IActivatedEventArgs args)
355
235
356
236
// Ensure the current window is active.
357
237
Window . Current . Activate ( ) ;
358
- Window . Current . CoreWindow . PointerPressed += CoreWindow_PointerPressed ;
359
238
Window . Current . CoreWindow . Activated += CoreWindow_Activated ;
360
- currentView . BackRequested += Window_BackRequested ;
361
239
362
240
return ;
363
241
}
@@ -377,9 +255,8 @@ protected override async void OnActivated(IActivatedEventArgs args)
377
255
rootFrame . Navigate ( typeof ( MainPage ) , null , new SuppressNavigationTransitionInfo ( ) ) ;
378
256
// Ensure the current window is active.
379
257
Window . Current . Activate ( ) ;
380
- Window . Current . CoreWindow . PointerPressed += CoreWindow_PointerPressed ;
381
258
Window . Current . CoreWindow . Activated += CoreWindow_Activated ;
382
- currentView . BackRequested += Window_BackRequested ;
259
+
383
260
return ;
384
261
}
385
262
}
@@ -401,7 +278,6 @@ protected override async void OnActivated(IActivatedEventArgs args)
401
278
402
279
// Ensure the current window is active.
403
280
Window . Current . Activate ( ) ;
404
- Window . Current . CoreWindow . PointerPressed += CoreWindow_PointerPressed ;
405
281
Window . Current . CoreWindow . Activated += CoreWindow_Activated ;
406
282
}
407
283
@@ -433,11 +309,7 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
433
309
434
310
var deferral = e . SuspendingOperation . GetDeferral ( ) ;
435
311
//TODO: Save application state and stop any background activity
436
- if ( Connection != null )
437
- {
438
- Connection . Dispose ( ) ;
439
- Connection = null ;
440
- }
312
+
441
313
AppSettings ? . Dispose ( ) ;
442
314
deferral . Complete ( ) ;
443
315
}
0 commit comments