private void ManageSpecificationsButton_Click(object sender, RoutedEventArgs e) { var viewModel = new ManageSymbolSpecificationsDialogViewModel(_viewModel.Specifications, _viewModel.CodeStyleItems.ToList(), _languageName, _notificationService); var dialog = new ManageNamingStylesInfoDialog(viewModel); if (dialog.ShowDialog().Value == true) { _viewModel.UpdateSpecificationList(viewModel); } }
internal void UpdateSpecificationList(ManageSymbolSpecificationsDialogViewModel viewModel) { var symbolSpecifications = viewModel.Items.Cast<SymbolSpecificationViewModel>().Select(n => new SymbolSpecification( n.ID, n.ItemName, n.SymbolKindList.Where(s => s.IsChecked).Select(k => k.CreateSymbolKindOrTypeKind()).ToList(), n.AccessibilityList.Where(s => s.IsChecked).Select(a => new SymbolSpecification.AccessibilityKind(a._accessibility)).ToList(), n.ModifierList.Where(s => s.IsChecked).Select(m => new SymbolSpecification.ModifierKind(m._modifier)).ToList())); Specifications.Clear(); foreach (var specification in symbolSpecifications) { Specifications.Add(specification); } // The existing rules have had their Specifications pulled out from underneath them, so // this goes through and resets them. foreach (var rule in CodeStyleItems) { var selectedSpecification = rule.SelectedSpecification; rule.Specifications.Clear(); foreach (var specification in symbolSpecifications) { rule.Specifications.Add(specification); } // Set the SelectedSpecification to null and then back to the actual selected // specification to trigger the INotifyPropertyChanged event. rule.SelectedSpecification = null; if (selectedSpecification != null) { rule.SelectedSpecification = rule.Specifications.Single(s => s.ID == selectedSpecification.ID); } } }