public override void RefreshProfiles(string selectedProfileName) { var oldProfile = SelectedProfile != null ? SelectedProfile.ProfilePath : null; ProfileItem _selectedProfile = null; try { Profiles.Clear(); // ALWAYS on the first position insert the default profile (ThumbGen.tgp, ex config.xml) Profiles.Add(new ProfileItem(Configuration.ConfigFilePath, GetProfileName(Configuration.ConfigFilePath))); // now add the rest string _ProfilesFolder = FileManager.GetProfilesFolder(); if (Directory.Exists(_ProfilesFolder)) { string[] _Profiles = Directory.GetFiles(_ProfilesFolder, "*.tgp", SearchOption.TopDirectoryOnly); if (_Profiles != null && _Profiles.Count() != 0) { foreach (string _ProfilePath in _Profiles) { ProfileItem _Profile = new ProfileItem(_ProfilePath, GetProfileName(_ProfilePath)); Profiles.Add(_Profile); if (!string.IsNullOrEmpty(selectedProfileName) && string.Compare(_Profile.ProfileName, selectedProfileName, true) == 0) { _selectedProfile = _Profile; } } } } if (_selectedProfile == null && selectedProfileName == DefaultProfileName) { _selectedProfile = Profiles[0] as ProfileItem; } } catch (Exception ex) { Loggy.Logger.DebugException("Refresh Profiles", ex); } if (_selectedProfile != null) { _selectedProfile.IsSelected = false; _selectedProfile.IsSelected = true; SelectedProfile = _selectedProfile; OnSelectedProfileChanged(oldProfile, SelectedProfile.ProfilePath); FileManager.Configuration.LoadConfiguration(_selectedProfile.ProfilePath); } }
public override void RefreshProfiles(string selectedProfileName) { // if selectedProfileName is null, select the first one (that should always be there as it is generated by default when loading ResultsPage ProfileItem _selectedProfile = null; try { Profiles.Clear(); // ALWAYS on the first position insert the default profile Profiles.Add(new ProfileItem(DefaultLayoutPath, GetProfileName(DefaultLayoutPath))); // now add the rest string _ProfilesFolder = FileManager.GetMovieLayoutsFolder(); if (Directory.Exists(_ProfilesFolder)) { string[] _Profiles = Directory.GetFiles(_ProfilesFolder, "*.tgl", SearchOption.TopDirectoryOnly); if (_Profiles != null && _Profiles.Count() != 0) { foreach (string _ProfilePath in _Profiles) { string _profileName = GetProfileName(_ProfilePath); if (_profileName.ToLowerInvariant() != DefaultProfileName.ToLowerInvariant()) { ProfileItem _Profile = new ProfileItem(_ProfilePath, GetProfileName(_ProfilePath)); Profiles.Add(_Profile); if (!string.IsNullOrEmpty(selectedProfileName) && string.Compare(_Profile.ProfileName, selectedProfileName, true) == 0) { _selectedProfile = _Profile; } } } } } if (_selectedProfile == null || selectedProfileName == DefaultProfileName) { _selectedProfile = Profiles[0] as ProfileItem; } } catch (Exception ex) { Loggy.Logger.DebugException("Refresh Layouts", ex); } if (_selectedProfile != null) { this.SelectedProfile = null; this.SelectedProfile = _selectedProfile; this.SelectedProfile.IsSelected = false; this.SelectedProfile.IsSelected = true; Helpers.DoEvents(); if (!File.Exists(_selectedProfile.ProfilePath)) { SaveLayout(_selectedProfile.ProfilePath); } else { try { DockManager.RestoreLayout(_selectedProfile.ProfilePath); } catch (Exception ex) { Loggy.Logger.DebugException("Cannot restore results layout", ex); } } } }