Пример #1
0
        /// <summary>
        /// The event handler for the delete group button clicked
        /// </summary>
        private void DeleteGroupButton_Click(object sender, RoutedEventArgs e)
        {
            if (FlexibleMessageBox.Show(
                    UIMessages.DeleteGroupMessage,
                    UIMessages.DeleteGroupTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                var option = OptionsList.SelectedItem as ModOption;

                ModGroup modGroupToDelete = null;

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

                ModGroupList.Remove(modGroupToDelete);
                ModGroupNames.Remove(option.GroupName);

                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);
                }

                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;
                }
            }
        }