Exemplo n.º 1
0
        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;
        }