Example #1
0
        private SceneNode InsertTrigger(BehaviorTriggerBaseNode triggerNode)
        {
            BehaviorTriggerActionNode triggerActionNode1    = (BehaviorTriggerActionNode)triggerNode.Actions[0];
            DocumentCompositeNode     documentCompositeNode = (DocumentCompositeNode)triggerNode.DocumentNode;
            IProjectContext           projectContext        = triggerNode.ProjectContext;
            SceneNode sceneNode = this.InsertionPoint.SceneNode;
            ISceneNodeCollection <SceneNode> collectionForProperty   = sceneNode.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
            BehaviorTriggerBaseNode          behaviorTriggerBaseNode = BehaviorHelper.FindMatchingTriggerNode((DocumentNode)documentCompositeNode, collectionForProperty);

            if (behaviorTriggerBaseNode != null)
            {
                BehaviorTriggerActionNode triggerActionNode2 = (BehaviorTriggerActionNode)this.ViewModel.GetSceneNode(triggerActionNode1.DocumentNode.Clone(this.ViewModel.Document.DocumentContext));
                behaviorTriggerBaseNode.Actions.Add((SceneNode)triggerActionNode2);
                triggerActionNode1 = triggerActionNode2;
            }
            else
            {
                behaviorTriggerBaseNode = triggerNode;
                collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode);
            }
            if (projectContext.IsCapabilitySet(PlatformCapability.SupportsAttachingToRootElements) && sceneNode.ViewModel.ActiveEditingContainer.Equals((object)sceneNode))
            {
                IProperty property = projectContext.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetObjectProperty);
                if (property != null)
                {
                    foreach (BehaviorTriggerActionNode triggerActionNode2 in (IEnumerable <SceneNode>)behaviorTriggerBaseNode.Actions)
                    {
                        if (ProjectNeutralTypes.BehaviorTargetedTriggerAction.IsAssignableFrom((ITypeId)triggerActionNode2.Type))
                        {
                            BehaviorHelper.CreateAndSetElementNameBinding((IPropertyId)property, (SceneNode)triggerActionNode2, sceneNode);
                        }
                    }
                }
            }
            BehaviorEventTriggerNode eventTriggerNode = behaviorTriggerBaseNode as BehaviorEventTriggerNode;

            if (eventTriggerNode != null)
            {
                BehaviorEventTriggerNode.FixUpEventName(eventTriggerNode);
            }
            return((SceneNode)triggerActionNode1);
        }
Example #2
0
        private static void PasteChildProperty(SceneViewModel viewModel, SceneNode childProperty, IList <SceneNode> pastedNodes)
        {
            IList <SceneElement> list = (IList <SceneElement>)null;

            DocumentNodeHelper.StripExtraNamespaces(childProperty.DocumentNode);
            if (viewModel.ElementSelectionSet.Selection.Count != 0)
            {
                list = (IList <SceneElement>)viewModel.ElementSelectionSet.Selection;
            }
            else if (viewModel.ChildPropertySelectionSet.Selection.Count != 0 && !(childProperty is BehaviorBaseNode) && !(childProperty is BehaviorTriggerBaseNode))
            {
                list = (IList <SceneElement>) new List <SceneElement>();
                foreach (SceneNode sceneNode in viewModel.ChildPropertySelectionSet.Selection)
                {
                    SceneElement sceneElement = sceneNode.Parent as SceneElement;
                    list.Add(sceneElement);
                }
            }
            if (list == null)
            {
                return;
            }
            IProperty targetProperty = viewModel.ProjectContext.ResolveProperty(PasteCommand.ChildSceneNodeToPropertyId(childProperty));

            foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)list)
            {
                PropertySceneInsertionPoint sceneInsertionPoint = new PropertySceneInsertionPoint(sceneElement, targetProperty);
                if (sceneInsertionPoint.CanInsert((ITypeId)childProperty.Type))
                {
                    if (ProjectNeutralTypes.BehaviorTriggerBase.IsAssignableFrom((ITypeId)childProperty.Type))
                    {
                        BehaviorTriggerBaseNode behaviorTriggerBaseNode1 = (BehaviorTriggerBaseNode)childProperty;
                        bool flag = true;
                        foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)behaviorTriggerBaseNode1.Actions)
                        {
                            if (!sceneInsertionPoint.CanInsert((ITypeId)sceneNode.Type))
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (flag)
                        {
                            ISceneNodeCollection <SceneNode> collectionForProperty    = sceneElement.GetCollectionForProperty((IPropertyId)targetProperty);
                            BehaviorTriggerBaseNode          behaviorTriggerBaseNode2 = BehaviorHelper.FindMatchingTriggerNode(behaviorTriggerBaseNode1.DocumentNode, collectionForProperty);
                            if (behaviorTriggerBaseNode2 == null)
                            {
                                DocumentNode node = behaviorTriggerBaseNode1.DocumentNode.Clone(behaviorTriggerBaseNode1.DocumentContext);
                                behaviorTriggerBaseNode2 = (BehaviorTriggerBaseNode)viewModel.GetSceneNode(node);
                                collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode2);
                            }
                            else
                            {
                                DocumentNode node = behaviorTriggerBaseNode1.Actions[0].DocumentNode.Clone(behaviorTriggerBaseNode1.Actions[0].DocumentNode.Context);
                                BehaviorTriggerActionNode triggerActionNode = (BehaviorTriggerActionNode)viewModel.GetSceneNode(node);
                                behaviorTriggerBaseNode2.Actions.Add((SceneNode)triggerActionNode);
                            }
                            BehaviorEventTriggerNode eventTriggerNode = behaviorTriggerBaseNode2 as BehaviorEventTriggerNode;
                            if (eventTriggerNode != null)
                            {
                                BehaviorEventTriggerNode.FixUpEventName(eventTriggerNode);
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        DocumentNode node      = childProperty.DocumentNode.Clone(childProperty.DocumentNode.Context);
                        SceneNode    sceneNode = viewModel.GetSceneNode(node);
                        sceneInsertionPoint.Insert(sceneNode);
                        if (sceneNode is EffectNode)
                        {
                            pastedNodes.Add(sceneNode);
                        }
                    }
                    TimelineItem timelineItem = viewModel.TimelineItemManager.FindTimelineItem((SceneNode)sceneElement);
                    if (timelineItem != null)
                    {
                        timelineItem.IsExpanded = true;
                    }
                }
            }
        }