예제 #1
0
        private void RemoveMaterial()
        {
            MaterialBaseEditor materialEditor    = this.materialListView.CurrentItem as MaterialBaseEditor;
            SceneNodeProperty  propertyForParent = this.GetSceneNodePropertyForParent(materialEditor);

            using (this.ViewModel.ForceBaseValue())
            {
                if (propertyForParent == null)
                {
                    this.editingProperty.ClearValue();
                }
                else
                {
                    int index = ((IndexedClrPropertyReferenceStep)materialEditor.MaterialProperty.Reference.LastStep).Index;
                    propertyForParent.RemoveValueAt(index);
                    propertyForParent.OnRemoveFromCategory();
                }
            }
            this.Rebuild();
        }
예제 #2
0
        private void AddMaterial()
        {
            MaterialBaseEditor materialEditor = this.materialListView.CurrentItem as MaterialBaseEditor;

            if (materialEditor != null)
            {
                DocumentNode      documentNode      = this.ViewModel.CreateSceneNode(materialEditor.Type).DocumentNode;
                SceneNodeProperty propertyForParent = this.GetSceneNodePropertyForParent(materialEditor);
                using (this.ViewModel.ForceBaseValue())
                {
                    if (propertyForParent == null)
                    {
                        bool         isMixed;
                        DocumentNode valueAsDocumentNode = this.editingProperty.GetLocalValueAsDocumentNode(true, out isMixed);
                        if (!isMixed)
                        {
                            this.editingProperty.SetValue((object)this.ViewModel.CreateSceneNode(typeof(MaterialGroup)).DocumentNode);
                            SceneNodeProperty sceneNodeProperty = this.editingProperty.SceneNodeObjectSet.CreateSceneNodeProperty(this.editingProperty.Reference.Append(MaterialGroupNode.ChildrenProperty), (AttributeCollection)null);
                            sceneNodeProperty.SetValue((object)this.ViewModel.CreateSceneNode(typeof(MaterialCollection)).DocumentNode);
                            sceneNodeProperty.AddValue((object)valueAsDocumentNode);
                            sceneNodeProperty.AddValue((object)documentNode);
                            sceneNodeProperty.OnRemoveFromCategory();
                        }
                    }
                    else
                    {
                        int index = ((IndexedClrPropertyReferenceStep)materialEditor.MaterialProperty.Reference.LastStep).Index;
                        propertyForParent.InsertValue(index + 1, (object)documentNode);
                        propertyForParent.OnRemoveFromCategory();
                    }
                }
                this.Rebuild();
                this.materialListView.MoveCurrentToNext();
            }
            else
            {
                using (this.ViewModel.ForceBaseValue())
                    this.editingProperty.SetValue((object)this.ViewModel.CreateSceneNode(typeof(DiffuseMaterial)).DocumentNode);
                this.Rebuild();
            }
        }