Skip to content

Commit

Permalink
Fix #444, Fix #446 (#448)
Browse files Browse the repository at this point in the history
Co-authored-by: BornToBeRoot <[email protected]>
  • Loading branch information
BornToBeRoot and BornToBeRoot authored Jan 26, 2021
1 parent c5355e0 commit 35444de
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,24 @@ public ICollectionView ProfileFiles
}
}

private ProfileFileInfo _selectedProfileFile;
private ProfileFileInfo _selectedProfileFile = null;
public ProfileFileInfo SelectedProfileFile
{
get => _selectedProfileFile;
set
{
if (value == _selectedProfileFile || (value != null && value.Equals(_selectedProfileFile)))
if (_isProfileLoading || (value != null && value.Equals(_selectedProfileFile)))
return;

_selectedProfileFile = value;

if (!_isProfileLoading && value != null && !value.Equals(ProfileManager.LoadedProfileFile))
// Switch profile...
if (value != null && !value.Equals(ProfileManager.LoadedProfileFile))
{
ProfileManager.SwitchProfile(value);
SettingsManager.Current.Profiles_LastSelected = value.Name;
}

OnPropertyChanged();
}
}
Expand Down Expand Up @@ -368,19 +369,16 @@ private void AfterContentRendered()

// Load profiles
_isProfileLoading = true;

ProfileFiles = new CollectionViewSource { Source = ProfileManager.ProfileFiles }.View;
ProfileFiles.SortDescriptions.Add(new SortDescription(nameof(ProfileFileInfo.Name), ListSortDirection.Ascending));
ProfileManager.OnProfileFileChangedEvent += ProfileManager_OnProfileFileChangedEvent;

_isProfileLoading = false;

// Switch profile
SelectedProfileFile = ProfileFiles.SourceCollection.Cast<ProfileFileInfo>().FirstOrDefault(x => x.Name == SettingsManager.Current.Profiles_LastSelected);

/*
if (SelectedProfileFile == null)
SelectedProfileFile = ProfileFiles.SourceCollection.Cast<ProfileFileInfo>().FirstOrDefault();
*/

// Hide to tray after the window shows up... not nice, but otherwise the hotkeys do not work
if (CommandLineManager.Current.Autostart && SettingsManager.Current.Autostart_StartMinimizedInTray)
Expand Down

0 comments on commit 35444de

Please sign in to comment.