Exemplo n.º 1
0
        internal static void ReparentAction(ISceneNodeCollection <SceneNode> triggersCollection, BehaviorTriggerBaseNode oldTrigger, BehaviorTriggerBaseNode newTrigger, BehaviorTriggerActionNode action)
        {
            SceneViewModel viewModel = oldTrigger.ViewModel;

            viewModel.BehaviorSelectionSet.Clear();
            int num = triggersCollection.IndexOf((SceneNode)oldTrigger);

            DocumentNodeHelper.PreserveFormatting(action.DocumentNode);
            oldTrigger.Actions.Remove((SceneNode)action);
            viewModel.Document.OnUpdatedEditTransaction();
            if (oldTrigger.Actions.Count == 0)
            {
                triggersCollection.RemoveAt(num--);
            }
            if (!triggersCollection.Contains((SceneNode)newTrigger))
            {
                triggersCollection.Insert(num + 1, (SceneNode)newTrigger);
            }
            newTrigger.Actions.Add((SceneNode)action);
            viewModel.BehaviorSelectionSet.SetSelection((BehaviorBaseNode)action);
        }
Exemplo n.º 2
0
        public void SetDocumentNodeValue(DocumentCompositeNode compositeNode, IPropertyId propertyKey, DocumentNode valueNode)
        {
            string id = this.GetID(compositeNode);

            if (id != null)
            {
                ISceneNodeCollection <SceneNode> setters = this.Setters;
                int index = 0;
                while (index < setters.Count)
                {
                    if (this.IsSetter((DocumentCompositeNode)setters[index].DocumentNode, id, propertyKey))
                    {
                        setters.RemoveAt(index);
                    }
                    else
                    {
                        ++index;
                    }
                }
                if (valueNode == null)
                {
                    return;
                }
                SetterSceneNode setterSceneNode = (SetterSceneNode)this.ViewModel.CreateSceneNode(typeof(Setter));
                if (!this.IsRootNode((DocumentNode)compositeNode))
                {
                    setterSceneNode.Target = id;
                }
                setterSceneNode.Property = (DependencyPropertyReferenceStep)propertyKey;
                ((DocumentCompositeNode)setterSceneNode.DocumentNode).Properties[SetterSceneNode.ValueProperty] = valueNode;
                setters.Add((SceneNode)setterSceneNode);
            }
            else
            {
                compositeNode.Properties[propertyKey] = valueNode;
            }
        }