Exemplo n.º 1
0
        private void populateCombo()
        {
            if (_enumType == null || _setting == null)
            {
                return;
            }

            // add all items
            foreach (Enum currValue in Enum.GetValues(_enumType))
            {
                FormatedComboBoxItem newItem = new FormatedComboBoxItem();
                newItem.Value         = currValue;
                comboItems[currValue] = newItem;
                Items.Add(newItem);
            }

            // set selected item
            try {
                Enum value = (Enum)Enum.Parse(_enumType, _setting.StringValue);
                SelectedItem = comboItems[value];
            }
            catch {
                SelectedIndex = 0;
            }
        }
        private void updateControls()
        {
            bool active = settings != null;

            // reset enabled status for all controls
            randomBackdropRadioButton.Enabled = active;
            specificBackdropRadioButton.Enabled = active;
            fileBackdropRadioButton.Enabled = active;
            backdropMovieCombo.Enabled = active;
            backdropFileTextBox.Enabled = active;
            fileBrowserButton.Enabled = active;
            defaultSortRadioButton.Enabled = active;
            customSortRadioButton.Enabled = active;
            sortDirectionCombo.Enabled = active;
            sortFieldCombo.Enabled = active;

            // if we dont have any settings to modify, exit
            if (!active)
                return;

            updating = true;

            // set the checked status for backdrop options
            switch (settings.BackdropType) {
                case MenuBackdropType.RANDOM:
                    randomBackdropRadioButton.Checked = true;
                    break;
                case MenuBackdropType.MOVIE:
                    specificBackdropRadioButton.Checked = true;
                    break;
                case MenuBackdropType.FILE:
                    fileBackdropRadioButton.Checked = true;
                    break;
            }

            if (settings.UseDefaultSorting)
                defaultSortRadioButton.Checked = true;
            else
                customSortRadioButton.Checked = true;

            // set the sort options radio buttons appropriately
            switch (settings.SortDirection) {
                case MediaPortal.Plugins.MovingPictures.MainUI.SortingDirections.Ascending:
                    sortDirectionCombo.SelectedItem = "Ascending";
                    break;
                case MediaPortal.Plugins.MovingPictures.MainUI.SortingDirections.Descending:
                    sortDirectionCombo.SelectedItem = "Descending";
                    break;
            }

            // set enabled status for sub controls
            setSubControlAccessibility();

            // clear and add all sorting options to combo
            sortFieldCombo.Items.Clear();
            Dictionary<Enum, FormatedComboBoxItem> comboItems = new Dictionary<Enum, FormatedComboBoxItem>();
            foreach (Enum currValue in Enum.GetValues(typeof(SortingFields))) {
                FormatedComboBoxItem newItem = new FormatedComboBoxItem();
                newItem.Value = currValue;
                comboItems[currValue] = newItem;
                sortFieldCombo.Items.Add(newItem);
            }
            sortFieldCombo.SelectedItem = comboItems[settings.SortField];

            // clear backdrop movie combo and set the selected movie. when user clicks it will be populated
            backdropMovieCombo.Items.Clear();
            if (settings.BackdropMovie != null) {
                backdropMovieCombo.Items.Add(settings.BackdropMovie);
                backdropMovieCombo.SelectedItem = settings.BackdropMovie;
            }

            backdropFileTextBox.Text = settings.BackdropFilePath;

            switch (settings.MovieView) {
                case BrowserViewMode.LASTUSED:
                    viewComboBox.SelectedIndex = 1;
                    break;
                case BrowserViewMode.LIST:
                    viewComboBox.SelectedIndex = 2;
                    break;
                case BrowserViewMode.SMALLICON:
                    viewComboBox.SelectedIndex = 3;
                    break;
                case BrowserViewMode.LARGEICON:
                    viewComboBox.SelectedIndex = 4;
                    break;
                case BrowserViewMode.FILMSTRIP:
                    viewComboBox.SelectedIndex = 5;
                    break;
                case BrowserViewMode.COVERFLOW:
                    viewComboBox.SelectedIndex = 6;
                    break;
                case BrowserViewMode.PARENT:
                default:
                    viewComboBox.SelectedIndex = 0;
                    break;
            }

            updating = false;
        }
        private void populateCombo()
        {
            if (_enumType == null || _setting == null)
                return;

            // add all items
            foreach (Enum currValue in Enum.GetValues(_enumType)) {
                FormatedComboBoxItem newItem = new FormatedComboBoxItem();
                newItem.Value = currValue;
                comboItems[currValue] = newItem;
                Items.Add(newItem);
            }

            // set selected item
            try {
                Enum value = (Enum)Enum.Parse(_enumType, _setting.StringValue);
                SelectedItem = comboItems[value];
            }
            catch {
                SelectedIndex = 0;
            }
        }