Example #1
0
        public static List<SettingsProvider> getEnabledProvidersFromGroup(SettingsGroup settingsGroup)
        {
            List<SettingsProvider> result = new List<SettingsProvider>();
            List<SettingsProvider> toRemove = new List<SettingsProvider>();

            if (settingsGroup == null || settingsGroup.Providers == null || settingsGroup.Providers.Count == 0) return result;

            foreach (SettingsProvider settingsProvider in settingsGroup.Providers) {
                if (settingsProvider.Enabled)
                    result.Add(settingsProvider);
            }

            foreach (SettingsProvider settingsProvider in result) {
                if (!SubsDownloaderNames.Contains(settingsProvider.ID))
                    toRemove.Add(settingsProvider);
            }
            foreach (SettingsProvider settingsProvider in toRemove) {
                result.Remove(settingsProvider);
            }

            return result;
        }
Example #2
0
 public static bool groupHasEnabledProviders(SettingsGroup settingsGroup)
 {
     return getEnabledProvidersFromGroup(settingsGroup).Count > 0;
 }
Example #3
0
        public static List<SettingsGroup> getAllProviderGroups()
        {
            List<SettingsGroup> result = new List<SettingsGroup>();

            // default groups
            SettingsGroup newSettingsGroup = null;

            newSettingsGroup = new SettingsGroup() {
                Title = Localization.AllProviders,
                Providers = getAllProvidersAsEnabledOrDisabled(true),
                Enabled = Settings.SettingsManager.Properties.GeneralSettings.AllProvidersEnabled,
                DefaultForMovies = Settings.SettingsManager.Properties.GeneralSettings.AllProvidersForMovies,
                DefaultForTVShows = Settings.SettingsManager.Properties.GeneralSettings.AllProvidersForTVShows
            };
            result.Add(newSettingsGroup);

            newSettingsGroup = new SettingsGroup() {
                Title = Localization.AllEnabledProviders,
                Providers = getAllProviders(),
                Enabled = Settings.SettingsManager.Properties.GeneralSettings.EnabledProvidersEnabled,
                DefaultForMovies = Settings.SettingsManager.Properties.GeneralSettings.EnabledProvidersForMovies,
                DefaultForTVShows = Settings.SettingsManager.Properties.GeneralSettings.EnabledProvidersForTVShows
            };
            result.Add(newSettingsGroup);

            updateProvidersForSettingGroups();

            result.AddRange(Settings.SettingsManager.Properties.GeneralSettings.Groups);

            if (!groupsHaveDefaultForMovies(result)) {
                result[0].DefaultForMovies = true;
            }

            if (!groupsHaveDefaultForTVShows(result)) {
                result[0].DefaultForTVShows = true;
            }

            return result;
        }
Example #4
0
        private string getDefaultMoviesTVShowsTextFromGroup(SettingsGroup group)
        {
            if (group.DefaultForMovies || group.DefaultForTVShows) {
                string text = string.Empty;
                if (group.DefaultForMovies)
                    text = Localization.Movies;
                if (group.DefaultForTVShows && string.IsNullOrEmpty(text))
                    text = Localization.TVShows;
                else if (group.DefaultForTVShows)
                    text = text + ", " + Localization.TVShows;

                return string.Format(Localization.DefaultFor, text);
            }
            return string.Empty;
        }
Example #5
0
 private void fillEditGroupSettingsFromGroup(SettingsGroup settingsGroup)
 {
     if (settingsGroup != null) {
         checkBoxEditGroupDefaultMovies.Checked = settingsGroup.DefaultForMovies;
         checkBoxEditGroupDefaultTVShows.Checked = settingsGroup.DefaultForTVShows;
     }
     else {
         checkBoxEditGroupDefaultMovies.Checked = false;
         checkBoxEditGroupDefaultTVShows.Checked = false;
     }
 }
Example #6
0
        private void fillEditGroupProvidersFromGroup(SettingsGroup settingsGroup)
        {
            listViewEditGroup.BeginUpdate();
            try {
                listViewEditGroup.Clear();
                if (settingsGroup == null || settingsGroup.Providers == null || settingsGroup.Providers.Count == 0) return;
                foreach (SettingsProvider provider in settingsGroup.Providers) {
                    ListViewItem item = new ListViewItem(provider.Title) {
                        Font = new Font(Font, FontStyle.Regular),
                        Checked = provider.Enabled,
                        Tag = provider
                    };

                    listViewEditGroup.Items.Add(item);
                }
            }
            finally {
                listViewEditGroup.EndUpdate();
            }
        }
Example #7
0
        private int LocateGroupInListControl(SettingsGroup defaultGroup)
        {
            int result = -1;

            if (providerList.ListItems == null || providerList.ListItems.Count == 0) return result;

            for (int i = 0; i < providerList.ListItems.Count; i++) {
                GUIListItem item = providerList.ListItems[i];
                if (item.IsFolder && item.MusicTag != null && item.MusicTag is SettingsGroup && ((SettingsGroup)item.MusicTag).Equals(defaultGroup))
                    return i;
            }

            return result;
        }