Esempio n. 1
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();
            }
        }
            public override void SelectElement(SceneElement element, SceneNodeProperty editingProperty)
            {
                if (element == null || editingProperty == null || (editingProperty.SceneNodeObjectSet == null || editingProperty.IsMixedValue))
                {
                    return;
                }
                SceneNodeObjectSet sceneNodeObjectSet = editingProperty.SceneNodeObjectSet;
                BindingSceneNode   bindingSceneNode   = sceneNodeObjectSet.ViewModel.CreateSceneNode(PlatformTypes.Binding) as BindingSceneNode;
                LayoutPathNode     layoutPathNode     = sceneNodeObjectSet.ViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath) as LayoutPathNode;

                using (SceneEditTransaction editTransaction = sceneNodeObjectSet.ViewModel.CreateEditTransaction(StringTable.AddLayoutPathUndo))
                {
                    using (sceneNodeObjectSet.ViewModel.ForceBaseValue())
                    {
                        element.EnsureNamed();
                        editTransaction.Update();
                        bindingSceneNode.ElementName = element.Name;
                        layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode);
                        editingProperty.AddValue((object)layoutPathNode.DocumentNode);
                        editTransaction.Commit();
                    }
                }
            }