Beispiel #1
0
        private void SwapMaterials(MaterialBaseEditor firstMaterial, MaterialBaseEditor secondMaterial)
        {
            SceneNodeProperty propertyForParent1 = this.GetSceneNodePropertyForParent(firstMaterial);
            SceneNodeProperty propertyForParent2 = this.GetSceneNodePropertyForParent(secondMaterial);
            int          index1 = ((IndexedClrPropertyReferenceStep)firstMaterial.MaterialProperty.Reference.LastStep).Index;
            int          index2 = ((IndexedClrPropertyReferenceStep)secondMaterial.MaterialProperty.Reference.LastStep).Index;
            bool         isMixed;
            DocumentNode valueAsDocumentNode1 = firstMaterial.MaterialProperty.GetLocalValueAsDocumentNode(true, out isMixed);
            DocumentNode valueAsDocumentNode2 = secondMaterial.MaterialProperty.GetLocalValueAsDocumentNode(true, out isMixed);

            if (index1 > index2)
            {
                propertyForParent1.RemoveValueAt(index1);
                propertyForParent2.RemoveValueAt(index2);
                propertyForParent2.InsertValue(index2, (object)valueAsDocumentNode1);
                propertyForParent1.InsertValue(index1, (object)valueAsDocumentNode2);
            }
            else
            {
                propertyForParent2.RemoveValueAt(index2);
                propertyForParent1.RemoveValueAt(index1);
                propertyForParent1.InsertValue(index1, (object)valueAsDocumentNode2);
                propertyForParent2.InsertValue(index2, (object)valueAsDocumentNode1);
            }
            this.Rebuild();
        }
Beispiel #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();
            }
        }