private static void OnCategoryPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CategoryContainer categoryContainer = (CategoryContainer)d; if (e.NewValue == null) { return; } CategoryBase categoryBase1 = (CategoryBase)e.NewValue; categoryContainer.SetValue(AutomationElement.IdProperty, (object)(categoryBase1.get_CategoryName() + "Category")); CategoryBase categoryBase2 = (CategoryBase)e.OldValue; if (categoryBase2 != null) { categoryBase2.remove_FilterApplied(new EventHandler <PropertyFilterAppliedEventArgs>(categoryContainer.OnFilterApplied)); categoryBase1.CategoryEditors.CollectionChanged -= new NotifyCollectionChangedEventHandler(categoryContainer.CategoryEditors_CollectionChanged); categoryContainer.basicCategoryEditors.Clear(); categoryContainer.advancedCategoryEditors.Clear(); categoryBase1.BasicProperties.CollectionChanged -= new NotifyCollectionChangedEventHandler(categoryContainer.BasicProperties_CollectionChanged); categoryBase1.AdvancedProperties.CollectionChanged -= new NotifyCollectionChangedEventHandler(categoryContainer.AdvancedProperties_CollectionChanged); categoryContainer.unconsumedBasicProperties.Clear(); categoryContainer.unconsumedAdvancedProperties.Clear(); } if (categoryBase1 != null) { categoryBase1.add_FilterApplied(new EventHandler <PropertyFilterAppliedEventArgs>(categoryContainer.OnFilterApplied)); categoryContainer.AddCategoryEditors((IList)categoryBase1.CategoryEditors); categoryBase1.CategoryEditors.CollectionChanged += new NotifyCollectionChangedEventHandler(categoryContainer.CategoryEditors_CollectionChanged); using (IEnumerator <PropertyEntry> enumerator = categoryBase1.BasicProperties.GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { PropertyEntry current = enumerator.Current; categoryContainer.AddProperty(current, categoryContainer.unconsumedBasicProperties, categoryContainer.Category.BasicProperties, categoryContainer.basicCategoryEditors); } } using (IEnumerator <PropertyEntry> enumerator = categoryBase1.AdvancedProperties.GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { PropertyEntry current = enumerator.Current; categoryContainer.AddProperty(current, categoryContainer.unconsumedAdvancedProperties, categoryContainer.Category.AdvancedProperties, categoryContainer.advancedCategoryEditors); } } categoryBase1.BasicProperties.CollectionChanged += new NotifyCollectionChangedEventHandler(categoryContainer.BasicProperties_CollectionChanged); categoryBase1.AdvancedProperties.CollectionChanged += new NotifyCollectionChangedEventHandler(categoryContainer.AdvancedProperties_CollectionChanged); } categoryContainer.CoerceValue(CategoryContainer.ShowAdvancedHeaderProperty); }
private static void OnCategoryPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CategoryContainer categoryContainer = (CategoryContainer)d; if (e.NewValue == null) { return; } CategoryBase categoryBase1 = (CategoryBase)e.NewValue; categoryContainer.SetValue(AutomationElement.IdProperty, (object)(categoryBase1.CategoryName + "Category")); CategoryBase categoryBase2 = (CategoryBase)e.OldValue; if (categoryBase2 != null) { categoryBase2.FilterApplied -= new EventHandler <PropertyFilterAppliedEventArgs>(categoryContainer.OnFilterApplied); categoryBase1.CategoryEditors.CollectionChanged -= new NotifyCollectionChangedEventHandler(categoryContainer.CategoryEditors_CollectionChanged); categoryContainer.basicCategoryEditors.Clear(); categoryContainer.advancedCategoryEditors.Clear(); categoryBase1.BasicProperties.CollectionChanged -= new NotifyCollectionChangedEventHandler(categoryContainer.BasicProperties_CollectionChanged); categoryBase1.AdvancedProperties.CollectionChanged -= new NotifyCollectionChangedEventHandler(categoryContainer.AdvancedProperties_CollectionChanged); categoryContainer.unconsumedBasicProperties.Clear(); categoryContainer.unconsumedAdvancedProperties.Clear(); } if (categoryBase1 != null) { categoryBase1.FilterApplied += new EventHandler <PropertyFilterAppliedEventArgs>(categoryContainer.OnFilterApplied); categoryContainer.AddCategoryEditors((IList)categoryBase1.CategoryEditors); categoryBase1.CategoryEditors.CollectionChanged += new NotifyCollectionChangedEventHandler(categoryContainer.CategoryEditors_CollectionChanged); foreach (PropertyEntry property in (Collection <PropertyEntry>)categoryBase1.BasicProperties) { categoryContainer.AddProperty(property, categoryContainer.unconsumedBasicProperties, categoryContainer.Category.BasicProperties, categoryContainer.basicCategoryEditors); } foreach (PropertyEntry property in (Collection <PropertyEntry>)categoryBase1.AdvancedProperties) { categoryContainer.AddProperty(property, categoryContainer.unconsumedAdvancedProperties, categoryContainer.Category.AdvancedProperties, categoryContainer.advancedCategoryEditors); } categoryBase1.BasicProperties.CollectionChanged += new NotifyCollectionChangedEventHandler(categoryContainer.BasicProperties_CollectionChanged); categoryBase1.AdvancedProperties.CollectionChanged += new NotifyCollectionChangedEventHandler(categoryContainer.AdvancedProperties_CollectionChanged); } categoryContainer.CoerceValue(CategoryContainer.ShowAdvancedHeaderProperty); }