@@ -257,23 +257,24 @@ public ICollectionView ProfileFiles
257
257
}
258
258
}
259
259
260
- private ProfileFileInfo _selectedProfileFile ;
260
+ private ProfileFileInfo _selectedProfileFile = null ;
261
261
public ProfileFileInfo SelectedProfileFile
262
262
{
263
263
get => _selectedProfileFile ;
264
264
set
265
265
{
266
- if ( value == _selectedProfileFile || ( value != null && value . Equals ( _selectedProfileFile ) ) )
266
+ if ( _isProfileLoading || ( value != null && value . Equals ( _selectedProfileFile ) ) )
267
267
return ;
268
268
269
269
_selectedProfileFile = value ;
270
270
271
- if ( ! _isProfileLoading && value != null && ! value . Equals ( ProfileManager . LoadedProfileFile ) )
271
+ // Switch profile...
272
+ if ( value != null && ! value . Equals ( ProfileManager . LoadedProfileFile ) )
272
273
{
273
274
ProfileManager . SwitchProfile ( value ) ;
274
275
SettingsManager . Current . Profiles_LastSelected = value . Name ;
275
276
}
276
-
277
+
277
278
OnPropertyChanged ( ) ;
278
279
}
279
280
}
@@ -368,19 +369,16 @@ private void AfterContentRendered()
368
369
369
370
// Load profiles
370
371
_isProfileLoading = true ;
371
-
372
372
ProfileFiles = new CollectionViewSource { Source = ProfileManager . ProfileFiles } . View ;
373
373
ProfileFiles . SortDescriptions . Add ( new SortDescription ( nameof ( ProfileFileInfo . Name ) , ListSortDirection . Ascending ) ) ;
374
374
ProfileManager . OnProfileFileChangedEvent += ProfileManager_OnProfileFileChangedEvent ;
375
-
376
375
_isProfileLoading = false ;
377
376
377
+ // Switch profile
378
378
SelectedProfileFile = ProfileFiles . SourceCollection . Cast < ProfileFileInfo > ( ) . FirstOrDefault ( x => x . Name == SettingsManager . Current . Profiles_LastSelected ) ;
379
379
380
- /*
381
380
if ( SelectedProfileFile == null )
382
381
SelectedProfileFile = ProfileFiles . SourceCollection . Cast < ProfileFileInfo > ( ) . FirstOrDefault ( ) ;
383
- */
384
382
385
383
// Hide to tray after the window shows up... not nice, but otherwise the hotkeys do not work
386
384
if ( CommandLineManager . Current . Autostart && SettingsManager . Current . Autostart_StartMinimizedInTray )
0 commit comments