Ejemplo n.º 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();
        }
Ejemplo n.º 2
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();
        }