public override void AddNewProfile() { SaveFileDialog _sfd = new SaveFileDialog(); _sfd.InitialDirectory = FileManager.GetMovieLayoutsFolder(); _sfd.Title = "Save layout as"; _sfd.DefaultExt = ".tgl"; _sfd.Filter = "ThumbGen Layout (*.tgl)|*.tgl"; if ((bool)_sfd.ShowDialog()) { // save current profile with the new name SaveLayout(_sfd.FileName); // select the new profile as current RefreshProfiles(GetProfileName(_sfd.FileName)); } }
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); } } } }