@@ -95,69 +95,65 @@ private IHost ConfigureHost()
95
95
{
96
96
return Host . CreateDefaultBuilder ( )
97
97
. UseEnvironment ( ApplicationService . AppEnvironment . ToString ( ) )
98
- . ConfigureLogging ( builder =>
99
- builder
98
+ . ConfigureLogging ( builder => builder
100
99
. AddProvider ( new FileLoggerProvider ( Path . Combine ( ApplicationData . Current . LocalFolder . Path , "debug.log" ) ) )
101
- . SetMinimumLevel ( LogLevel . Information )
102
- )
103
- . ConfigureServices ( services =>
104
- services
105
- . AddSingleton < IUserSettingsService , UserSettingsService > ( )
106
- . AddSingleton < IAppearanceSettingsService , AppearanceSettingsService > ( sp => new AppearanceSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
107
- . AddSingleton < IGeneralSettingsService , GeneralSettingsService > ( sp => new GeneralSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
108
- . AddSingleton < IFoldersSettingsService , FoldersSettingsService > ( sp => new FoldersSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
109
- . AddSingleton < IApplicationSettingsService , ApplicationSettingsService > ( sp => new ApplicationSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
110
- . AddSingleton < IPreviewPaneSettingsService , PreviewPaneSettingsService > ( sp => new PreviewPaneSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
111
- . AddSingleton < ILayoutSettingsService , LayoutSettingsService > ( sp => new LayoutSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
112
- . AddSingleton < IAppSettingsService , AppSettingsService > ( sp => new AppSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
113
- . AddSingleton < IFileTagsSettingsService , FileTagsSettingsService > ( )
114
- . AddSingleton < IPageContext , PageContext > ( )
115
- . AddSingleton < IContentPageContext , ContentPageContext > ( )
116
- . AddSingleton < IDisplayPageContext , DisplayPageContext > ( )
117
- . AddSingleton < IWindowContext , WindowContext > ( )
118
- . AddSingleton < IMultitaskingContext , MultitaskingContext > ( )
119
- . AddSingleton < ITagsContext , TagsContext > ( )
120
- . AddSingleton < IDialogService , DialogService > ( )
121
- . AddSingleton < IImageService , ImagingService > ( )
122
- . AddSingleton < IThreadingService , ThreadingService > ( )
123
- . AddSingleton < ILocalizationService , LocalizationService > ( )
124
- . AddSingleton < ICloudDetector , CloudDetector > ( )
125
- . AddSingleton < IFileTagsService , FileTagsService > ( )
126
- . AddSingleton < ICommandManager , CommandManager > ( )
127
- . AddSingleton < IModifiableCommandManager , ModifiableCommandManager > ( )
128
- . AddSingleton < IApplicationService , ApplicationService > ( )
100
+ . SetMinimumLevel ( LogLevel . Information ) )
101
+ . ConfigureServices ( services => services
102
+ . AddSingleton < IUserSettingsService , UserSettingsService > ( )
103
+ . AddSingleton < IAppearanceSettingsService , AppearanceSettingsService > ( sp => new AppearanceSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
104
+ . AddSingleton < IGeneralSettingsService , GeneralSettingsService > ( sp => new GeneralSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
105
+ . AddSingleton < IFoldersSettingsService , FoldersSettingsService > ( sp => new FoldersSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
106
+ . AddSingleton < IApplicationSettingsService , ApplicationSettingsService > ( sp => new ApplicationSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
107
+ . AddSingleton < IPreviewPaneSettingsService , PreviewPaneSettingsService > ( sp => new PreviewPaneSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
108
+ . AddSingleton < ILayoutSettingsService , LayoutSettingsService > ( sp => new LayoutSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
109
+ . AddSingleton < IAppSettingsService , AppSettingsService > ( sp => new AppSettingsService ( ( sp . GetService < IUserSettingsService > ( ) as UserSettingsService ) . GetSharingContext ( ) ) )
110
+ . AddSingleton < IFileTagsSettingsService , FileTagsSettingsService > ( )
111
+ . AddSingleton < IPageContext , PageContext > ( )
112
+ . AddSingleton < IContentPageContext , ContentPageContext > ( )
113
+ . AddSingleton < IDisplayPageContext , DisplayPageContext > ( )
114
+ . AddSingleton < IWindowContext , WindowContext > ( )
115
+ . AddSingleton < IMultitaskingContext , MultitaskingContext > ( )
116
+ . AddSingleton < ITagsContext , TagsContext > ( )
117
+ . AddSingleton < IDialogService , DialogService > ( )
118
+ . AddSingleton < IImageService , ImagingService > ( )
119
+ . AddSingleton < IThreadingService , ThreadingService > ( )
120
+ . AddSingleton < ILocalizationService , LocalizationService > ( )
121
+ . AddSingleton < ICloudDetector , CloudDetector > ( )
122
+ . AddSingleton < IFileTagsService , FileTagsService > ( )
123
+ . AddSingleton < ICommandManager , CommandManager > ( )
124
+ . AddSingleton < IModifiableCommandManager , ModifiableCommandManager > ( )
125
+ . AddSingleton < IApplicationService , ApplicationService > ( )
129
126
#if UWP
130
- . AddSingleton < IStorageService , WindowsStorageService > ( )
127
+ . AddSingleton < IStorageService , WindowsStorageService > ( )
131
128
#else
132
- . AddSingleton < IStorageService , NativeStorageService > ( )
129
+ . AddSingleton < IStorageService , NativeStorageService > ( )
133
130
#endif
134
- . AddSingleton < IFtpStorageService , FtpStorageService > ( )
135
- . AddSingleton < IAddItemService , AddItemService > ( )
131
+ . AddSingleton < IFtpStorageService , FtpStorageService > ( )
132
+ . AddSingleton < IAddItemService , AddItemService > ( )
136
133
#if STABLE || PREVIEW
137
- . AddSingleton < IUpdateService , SideloadUpdateService > ( )
134
+ . AddSingleton < IUpdateService , SideloadUpdateService > ( )
138
135
#else
139
- . AddSingleton < IUpdateService , UpdateService > ( )
136
+ . AddSingleton < IUpdateService , UpdateService > ( )
140
137
#endif
141
- . AddSingleton < IPreviewPopupService , PreviewPopupService > ( )
142
- . AddSingleton < IDateTimeFormatterFactory , DateTimeFormatterFactory > ( )
143
- . AddSingleton < IDateTimeFormatter , UserDateTimeFormatter > ( )
144
- . AddSingleton < IVolumeInfoFactory , VolumeInfoFactory > ( )
145
- . AddSingleton < ISizeProvider , UserSizeProvider > ( )
146
- . AddSingleton < IQuickAccessService , QuickAccessService > ( )
147
- . AddSingleton < IResourcesService , ResourcesService > ( )
148
- . AddSingleton < IJumpListService , JumpListService > ( )
149
- . AddSingleton < IRemovableDrivesService , RemovableDrivesService > ( )
150
- . AddSingleton < INetworkDrivesService , NetworkDrivesService > ( )
151
- . AddSingleton < MainPageViewModel > ( )
152
- . AddSingleton < PreviewPaneViewModel > ( )
153
- . AddSingleton < SidebarViewModel > ( )
154
- . AddSingleton < SettingsViewModel > ( )
155
- . AddSingleton < DrivesViewModel > ( )
156
- . AddSingleton < NetworkDrivesViewModel > ( )
157
- . AddSingleton < OngoingTasksViewModel > ( )
158
- . AddSingleton < AppearanceViewModel > ( )
159
- )
160
- . Build ( ) ;
138
+ . AddSingleton < IPreviewPopupService , PreviewPopupService > ( )
139
+ . AddSingleton < IDateTimeFormatterFactory , DateTimeFormatterFactory > ( )
140
+ . AddSingleton < IDateTimeFormatter , UserDateTimeFormatter > ( )
141
+ . AddSingleton < IVolumeInfoFactory , VolumeInfoFactory > ( )
142
+ . AddSingleton < ISizeProvider , UserSizeProvider > ( )
143
+ . AddSingleton < IQuickAccessService , QuickAccessService > ( )
144
+ . AddSingleton < IResourcesService , ResourcesService > ( )
145
+ . AddSingleton < IJumpListService , JumpListService > ( )
146
+ . AddSingleton < IRemovableDrivesService , RemovableDrivesService > ( )
147
+ . AddSingleton < INetworkDrivesService , NetworkDrivesService > ( )
148
+ . AddSingleton < MainPageViewModel > ( )
149
+ . AddSingleton < PreviewPaneViewModel > ( )
150
+ . AddSingleton < SidebarViewModel > ( )
151
+ . AddSingleton < SettingsViewModel > ( )
152
+ . AddSingleton < DrivesViewModel > ( )
153
+ . AddSingleton < NetworkDrivesViewModel > ( )
154
+ . AddSingleton < OngoingTasksViewModel > ( )
155
+ . AddSingleton < AppearanceViewModel > ( )
156
+ ) . Build ( ) ;
161
157
}
162
158
163
159
private static async Task InitializeAppComponentsAsync ( )
@@ -207,28 +203,42 @@ static async Task OptionalTask(Task task, bool condition)
207
203
/// <param name="e">Details about the launch request and process.</param>
208
204
protected override void OnLaunched ( LaunchActivatedEventArgs e )
209
205
{
210
- // Get AppActivationArguments
211
- var appActivationArguments = Microsoft . Windows . AppLifecycle . AppInstance . GetCurrent ( ) . GetActivatedEventArgs ( ) ;
206
+ _ = ActivateAsync ( ) ;
212
207
213
- // Start tracking app usage
214
- if ( appActivationArguments . Data is Windows . ApplicationModel . Activation . IActivatedEventArgs activationEventArgs )
215
- SystemInformation . Instance . TrackAppUse ( activationEventArgs ) ;
208
+ async Task ActivateAsync ( )
209
+ {
210
+ // Initialize and activate MainWindow
211
+ EnsureSuperEarlyWindow ( ) ;
212
+
213
+ // Wait for the Window to initialize
214
+ await Task . Delay ( 10 ) ;
215
+
216
+ MainWindow . Instance . ShowSplashScreen ( ) ;
217
+
218
+ // Wait for the UI to update
219
+ await Task . Delay ( 500 ) ;
216
220
217
- // Configure Host and IoC
218
- _host = ConfigureHost ( ) ;
219
- Ioc . Default . ConfigureServices ( _host . Services ) ;
221
+ // Get AppActivationArguments
222
+ var appActivationArguments = Microsoft . Windows . AppLifecycle . AppInstance . GetCurrent ( ) . GetActivatedEventArgs ( ) ;
220
223
221
- EnsureSettingsAndConfigurationAreBootstrapped ( ) ;
224
+ // Start tracking app usage
225
+ if ( appActivationArguments . Data is Windows . ApplicationModel . Activation . IActivatedEventArgs activationEventArgs )
226
+ SystemInformation . Instance . TrackAppUse ( activationEventArgs ) ;
222
227
223
- // Initialize and activate MainWindow
224
- EnsureSuperEarlyWindow ( ) ;
228
+ // Configure Host and IoC
229
+ _host = ConfigureHost ( ) ;
230
+ Ioc . Default . ConfigureServices ( _host . Services ) ;
225
231
226
- // TODO(s)
227
- Logger = Ioc . Default . GetRequiredService < ILogger < App > > ( ) ;
228
- Logger . LogInformation ( $ "App launched. Launch args type: { appActivationArguments . Data . GetType ( ) . Name } ") ;
232
+ EnsureSettingsAndConfigurationAreBootstrapped ( ) ;
229
233
230
- _ = InitializeAppComponentsAsync ( ) . ContinueWith ( t => Logger . LogWarning ( t . Exception , "Error during InitializeAppComponentsAsync()" ) , TaskContinuationOptions . OnlyOnFaulted ) ;
231
- _ = MainWindow . Instance . InitializeApplication ( appActivationArguments . Data ) ;
234
+ // TODO: Remove App.Logger instance and replace with DI
235
+ Logger = Ioc . Default . GetRequiredService < ILogger < App > > ( ) ;
236
+ Logger . LogInformation ( $ "App launched. Launch args type: { appActivationArguments . Data . GetType ( ) . Name } ") ;
237
+
238
+ _ = InitializeAppComponentsAsync ( ) . ContinueWith ( t => Logger . LogWarning ( t . Exception , "Error during InitializeAppComponentsAsync()" ) , TaskContinuationOptions . OnlyOnFaulted ) ;
239
+
240
+ _ = MainWindow . Instance . InitializeApplication ( appActivationArguments . Data ) ;
241
+ }
232
242
}
233
243
234
244
private static void EnsureSettingsAndConfigurationAreBootstrapped ( )
0 commit comments