예제 #1
0
        /// <summary>
        /// The event handler for the edit group button clicked
        /// </summary>
        private void EditGroupButton_Click(object sender, RoutedEventArgs e)
        {
            var      option       = OptionsList.SelectedItem as ModOption;
            ModGroup editModGroup = null;

            foreach (var modGroup in ModGroupList)
            {
                if (modGroup.GroupName.Equals(option.GroupName))
                {
                    editModGroup = modGroup;
                    break;
                }
            }

            var wizardAddGroupWindow = new WizardAddGroupWindow(ModGroupNames)
            {
                Owner = Window.GetWindow(this),
                Title = UIStrings.Edit_Group
            };

            wizardAddGroupWindow.EditMode(editModGroup);

            var result = wizardAddGroupWindow.ShowDialog();

            if (result == true)
            {
                wizardAddGroupWindow.UpdateModGroup(editModGroup);

                OptionsList.ItemsSource = new List <ModOption>();

                foreach (var modGroup in ModGroupList)
                {
                    if (modGroup.SelectionType.Equals("Single") && modGroup.OptionList.Count(it => it.IsChecked) == 0)
                    {
                        modGroup.OptionList[0].IsChecked = true;
                    }

                    ((List <ModOption>)OptionsList.ItemsSource).AddRange(modGroup.OptionList);

                    var view             = (CollectionView)CollectionViewSource.GetDefaultView(OptionsList.ItemsSource);
                    var groupDescription = new PropertyGroupDescription("GroupName");
                    view.GroupDescriptions.Clear();
                    view.GroupDescriptions.Add(groupDescription);
                }

                OptionsList.SelectedIndex = 0;
            }
            else
            {
                if (((List <ModOption>)OptionsList.ItemsSource).Count < 1)
                {
                    EditGroupButton.IsEnabled   = false;
                    DeleteGroupButton.IsEnabled = false;
                }
                else
                {
                    OptionsList.SelectedIndex = 0;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// The event handler for the add group button clicked
        /// </summary>
        private void AddGroupButton_Click(object sender, RoutedEventArgs e)
        {
            var wizardAddGroupWindow = new WizardAddGroupWindow(ModGroupNames)
            {
                Owner = Window.GetWindow(this)
            };

            var result = wizardAddGroupWindow.ShowDialog();

            if (result == true)
            {
                var results     = wizardAddGroupWindow.GetResults();
                var optionsList = results.OptionList;

                if (optionsList.Count > 0)
                {
                    ModGroupList.Add(results);
                    ModGroupNames.Add(results.GroupName);

                    if (results.SelectionType.Equals("Single") && optionsList.Count(it => it.IsChecked) == 0)
                    {
                        optionsList[0].IsChecked = true;
                    }

                    ((List <ModOption>)OptionsList.ItemsSource).AddRange(optionsList);

                    var view             = (CollectionView)CollectionViewSource.GetDefaultView(OptionsList.ItemsSource);
                    var groupDescription = new PropertyGroupDescription("GroupName");
                    view.GroupDescriptions.Clear();
                    view.GroupDescriptions.Add(groupDescription);
                }

                OptionsList.SelectedIndex = 0;
            }
            else
            {
                if (((List <ModOption>)OptionsList.ItemsSource).Count < 1)
                {
                    EditGroupButton.IsEnabled   = false;
                    DeleteGroupButton.IsEnabled = false;
                }
                else
                {
                    OptionsList.SelectedIndex = 0;
                }
            }
        }