@@ -254,10 +254,10 @@ public SettingsGeneralImportExportViewModel(IDialogCoordinator instance)
254254 {
255255 dialogCoordinator = instance ;
256256
257- LoadSettings ( ) ;
257+ CheckFilesExist ( ) ;
258258 }
259259
260- private void LoadSettings ( )
260+ private void CheckFilesExist ( )
261261 {
262262 ApplicationSettingsExists = File . Exists ( SettingsManager . GetSettingsFilePath ( ) ) ;
263263 NetworkInterfaceProfilesExists = File . Exists ( NetworkInterfaceProfileManager . GetProfilesFilePath ( ) ) ;
@@ -318,7 +318,12 @@ private async void ImportSettingsAction()
318318
319319 settings . DefaultButtonFocus = MessageDialogResult . Affirmative ;
320320
321- if ( await dialogCoordinator . ShowMessageAsync ( this , Application . Current . Resources [ "String_Header_AreYouSure" ] as string , Application . Current . Resources [ "String_SelectedSettingsAreOverwritten" ] as string , MessageDialogStyle . AffirmativeAndNegative , settings ) == MessageDialogResult . Affirmative )
321+ string message = Application . Current . Resources [ "String_SelectedSettingsAreOverwritten" ] as string ;
322+
323+ if ( ImportApplicationSettingsExists && ( ImportEverything || ImportApplicationSettings ) )
324+ message += Environment . NewLine + Environment . NewLine + string . Format ( "* {0}" , Application . Current . Resources [ "String_ApplicationIsRestartedAfterwards" ] as string ) ;
325+
326+ if ( await dialogCoordinator . ShowMessageAsync ( this , Application . Current . Resources [ "String_Header_AreYouSure" ] as string , message , MessageDialogStyle . AffirmativeAndNegative , settings ) == MessageDialogResult . Affirmative )
322327 {
323328 List < ImportExportManager . ImportExportOptions > importOptions = new List < ImportExportManager . ImportExportOptions > ( ) ;
324329
@@ -333,7 +338,33 @@ private async void ImportSettingsAction()
333338
334339 ImportExportManager . Import ( ImportLocationSelectedPath , importOptions ) ;
335340
336- CloseAction ( ) ;
341+ // Restart if application settings are changed
342+ if ( ImportExportManager . ForceRestart )
343+ {
344+ CloseAction ( ) ;
345+ }
346+ else
347+ {
348+ settings . AffirmativeButtonText = Application . Current . Resources [ "String_Button_OK" ] as string ;
349+
350+ message = Application . Current . Resources [ "String_SettingsSuccessfullyImported" ] as string + Environment . NewLine ;
351+
352+ if ( importOptions . Contains ( ImportExportManager . ImportExportOptions . NetworkInterfaceProfiles ) )
353+ {
354+ NetworkInterfaceProfileManager . Reload ( ) ;
355+
356+ message += Environment . NewLine + string . Format ( "* {0}" , Application . Current . Resources [ "String_NetworkInterfaceProfilesReloaded" ] as string ) ;
357+ }
358+
359+ if ( importOptions . Contains ( ImportExportManager . ImportExportOptions . WakeOnLANClients ) )
360+ {
361+ WakeOnLANClientManager . Reload ( ) ;
362+
363+ message += Environment . NewLine + string . Format ( "* {0}" , Application . Current . Resources [ "String_WakeOnLANClientsReloaded" ] as string ) ;
364+ }
365+
366+ await dialogCoordinator . ShowMessageAsync ( this , Application . Current . Resources [ "String_Header_Success" ] as string , message , MessageDialogStyle . Affirmative , settings ) ;
367+ }
337368 }
338369 }
339370
@@ -347,22 +378,39 @@ private async void ExportSettingsAction()
347378 List < ImportExportManager . ImportExportOptions > exportOptions = new List < ImportExportManager . ImportExportOptions > ( ) ;
348379
349380 if ( ApplicationSettingsExists && ( ExportEverything || ExportApplicationSettings ) )
381+ {
382+ // Save them, before export
383+ if ( SettingsManager . Current . SettingsChanged )
384+ SettingsManager . Save ( ) ;
385+
386+ // Add to export
350387 exportOptions . Add ( ImportExportManager . ImportExportOptions . ApplicationSettings ) ;
388+ }
351389
352390 if ( NetworkInterfaceProfilesExists && ( ExportEverything || ExportNetworkInterfaceProfiles ) )
391+ {
392+ // Save them, before export
393+ if ( NetworkInterfaceProfileManager . ProfilesChanged )
394+ NetworkInterfaceProfileManager . Save ( ) ;
395+
396+ // Add to export
353397 exportOptions . Add ( ImportExportManager . ImportExportOptions . NetworkInterfaceProfiles ) ;
398+ }
354399
355400 if ( WakeOnLANClientsExists && ( ExportEverything || ExportWakeOnLANClients ) )
356- exportOptions . Add ( ImportExportManager . ImportExportOptions . WakeOnLANClients ) ;
357-
358- // Save the settings before exporting them
359- if ( SettingsManager . Current . SettingsChanged )
360- SettingsManager . Save ( ) ;
401+ {
402+ // Save them, before export
403+ if ( WakeOnLANClientManager . ClientsChanged )
404+ WakeOnLANClientManager . Save ( ) ;
361405
406+ // Add to export
407+ exportOptions . Add ( ImportExportManager . ImportExportOptions . WakeOnLANClients ) ;
408+ }
409+
362410 System . Windows . Forms . SaveFileDialog saveFileDialog = new System . Windows . Forms . SaveFileDialog ( )
363411 {
364412 Filter = ImportExportFileExtensionFilter ,
365- FileName = string . Format ( "{0}_{1}_{2}{3}" , Application . Current . Resources [ "String_ProductName" ] as string , Application . Current . Resources [ "String_Backup" ] as string , TimestampHelper . GetTimestamp ( ) , ImportExportManager . ImportExportFileExtension )
413+ FileName = string . Format ( "{0}_{1}_{2}{3}" , Application . Current . Resources [ "String_ProductName" ] as string , Application . Current . Resources [ "String_Backup" ] as string , TimestampHelper . GetTimestamp ( ) , ImportExportManager . ImportExportFileExtension )
366414 } ;
367415
368416 if ( saveFileDialog . ShowDialog ( ) == System . Windows . Forms . DialogResult . OK )
0 commit comments