From 35444de83ec017b576a2a7a2ba73a9f8fde07a36 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Tue, 26 Jan 2021 22:21:59 +0100 Subject: [PATCH] Fix #444, Fix #446 (#448) Co-authored-by: BornToBeRoot --- Source/NETworkManager/MainWindow.xaml.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 83669413c5..d25b42eebf 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -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(); } } @@ -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().FirstOrDefault(x => x.Name == SettingsManager.Current.Profiles_LastSelected); - /* if (SelectedProfileFile == null) SelectedProfileFile = ProfileFiles.SourceCollection.Cast().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)