コード例 #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();
        }
コード例 #2
0
        private SceneNodeProperty GetSceneNodePropertyForParent(MaterialBaseEditor materialEditor)
        {
            PropertyReference reference = materialEditor.MaterialProperty.Reference;
            int endIndex = reference.Count - 2;

            if (endIndex >= this.editingProperty.Reference.Count)
            {
                return(materialEditor.MaterialProperty.SceneNodeObjectSet.CreateSceneNodeProperty(reference.Subreference(0, endIndex), (AttributeCollection)null));
            }
            return((SceneNodeProperty)null);
        }
コード例 #3
0
        private void SwitchMaterialType(Type type)
        {
            MaterialBaseEditor materialBaseEditor = this.materialListView.CurrentItem as MaterialBaseEditor;

            if (materialBaseEditor == null || !(materialBaseEditor.Type != type) || this.isSettingType)
            {
                return;
            }
            this.isSettingType = true;
            materialBaseEditor.MaterialProperty.SetValue((object)this.ViewModel.CreateSceneNode(type).DocumentNode);
            this.Rebuild();
            this.OnMaterialTypeChange();
            this.isSettingType = false;
        }
コード例 #4
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();
        }
コード例 #5
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();
            }
        }