public PropertyEnumerator(CategoryBase category) { this.category = category; this.current = (IEnumerator <PropertyEntry>)null; this.enumeratingBasic = false; this.Reset(); }
private void OnChildrenViewCurrentChanged(object sender, EventArgs e) { this.model.Categories.Clear(); PropertyValue activePropertyValue = this.childrenView.CurrentItem as PropertyValue; this.removeItemCommand.IsEnabled = this.IsRemoveEnabled; this.moveUpCommand.IsEnabled = this.IsMoveUpEnabled; this.moveDownCommand.IsEnabled = this.IsMoveDownEnabled; this.primitiveEditorContent = null; this.primitiveEditorVisibility = Visibility.Collapsed; if (activePropertyValue != null) { Type selectedType = activePropertyValue.get_ParentProperty().get_PropertyType(); object obj = activePropertyValue.get_Value(); if (obj != null) { selectedType = obj.GetType(); } if (selectedType.IsPrimitive || selectedType == typeof(string) || activePropertyValue.get_SubProperties().get_Count() == 0) { this.primitiveEditorVisibility = Visibility.Visible; PropertyValueEditor propertyValueEditor = activePropertyValue.get_ParentProperty().get_PropertyValueEditor(); this.primitiveEditorContent = (object)activePropertyValue; this.primitiveEditorTemplate = propertyValueEditor == null?this.TryFindResource((object)"PropertyContainerDefaultInlineTemplate") as DataTemplate : propertyValueEditor.get_InlineEditorTemplate(); } else { using (IEnumerator <PropertyEntry> enumerator = activePropertyValue.get_SubProperties().GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { PropertyEntry current = enumerator.Current; CategoryBase orCreateCategory = this.model.FindOrCreateCategory(current.get_CategoryName(), selectedType); if (current.get_IsAdvanced()) { orCreateCategory.AdvancedProperties.Add(current); } else { orCreateCategory.BasicProperties.Add(current); } } } } } this.OnPropertyChanged("PrimitiveEditorVisibility"); this.OnPropertyChanged("PrimitiveEditorContent"); this.OnPropertyChanged("PrimitiveEditorTemplate"); this.model.OnRebuildComplete(activePropertyValue); this.indexToSelect = this.childrenView.CurrentPosition; }
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 void OnChildrenViewCurrentChanged(object sender, EventArgs e) { this.model.Categories.Clear(); Microsoft.Windows.Design.PropertyEditing.PropertyValue activePropertyValue = this.childrenView.CurrentItem as Microsoft.Windows.Design.PropertyEditing.PropertyValue; this.removeItemCommand.IsEnabled = this.IsRemoveEnabled; this.moveUpCommand.IsEnabled = this.IsMoveUpEnabled; this.moveDownCommand.IsEnabled = this.IsMoveDownEnabled; this.primitiveEditorContent = (object)null; this.primitiveEditorVisibility = Visibility.Collapsed; if (activePropertyValue != null) { Type selectedType = activePropertyValue.ParentProperty.PropertyType; object obj = activePropertyValue.Value; if (obj != null) { selectedType = obj.GetType(); } if (selectedType.IsPrimitive || selectedType == typeof(string) || activePropertyValue.SubProperties.Count == 0) { this.primitiveEditorVisibility = Visibility.Visible; PropertyValueEditor propertyValueEditor = activePropertyValue.ParentProperty.PropertyValueEditor; this.primitiveEditorContent = (object)activePropertyValue; this.primitiveEditorTemplate = propertyValueEditor == null?this.TryFindResource((object)"PropertyContainerDefaultInlineTemplate") as DataTemplate : propertyValueEditor.InlineEditorTemplate; } else { foreach (PropertyEntry propertyEntry in activePropertyValue.SubProperties) { CategoryBase orCreateCategory = this.model.FindOrCreateCategory(propertyEntry.CategoryName, selectedType); if (propertyEntry.IsAdvanced) { orCreateCategory.AdvancedProperties.Add(propertyEntry); } else { orCreateCategory.BasicProperties.Add(propertyEntry); } } } } this.OnPropertyChanged("PrimitiveEditorVisibility"); this.OnPropertyChanged("PrimitiveEditorContent"); this.OnPropertyChanged("PrimitiveEditorTemplate"); this.model.OnRebuildComplete(activePropertyValue); this.indexToSelect = this.childrenView.CurrentPosition; }
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); }