Ejemplo n.º 1
0
        internal static BehaviorTriggerBaseNode CloneTrigger(BehaviorTriggerBaseNode trigger, SceneViewModel viewModel)
        {
            DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)trigger.DocumentNode.Clone(trigger.DocumentContext);

            documentCompositeNode.Properties[BehaviorTriggerBaseNode.BehaviorActionsProperty] = (DocumentNode)null;
            return((BehaviorTriggerBaseNode)viewModel.GetSceneNode((DocumentNode)documentCompositeNode));
        }
Ejemplo n.º 2
0
        private static void FixUpEventNameImpl(BehaviorEventTriggerNode eventTriggerNode, SceneNode sourceNode)
        {
            if (sourceNode == null)
            {
                return;
            }
            IEnumerable <EventInformation> eventsForType = EventInformation.GetEventsForType((ITypeResolver)eventTriggerNode.ProjectContext, sourceNode.Type, MemberType.LocalEvent);

            if (!Enumerable.Any <EventInformation>(eventsForType, (Func <EventInformation, bool>)(info => info.EventName.Equals(eventTriggerNode.EventName, StringComparison.Ordinal))))
            {
                bool flag = false;
                DefaultEventAttribute defaultEventAttribute = TypeUtilities.GetAttribute <DefaultEventAttribute>(sourceNode.TargetType);
                if (defaultEventAttribute != null && !string.IsNullOrEmpty(defaultEventAttribute.Name) && (TriggerSourceInformation)Enumerable.SingleOrDefault <EventInformation>(eventsForType, (Func <EventInformation, bool>)(eventInfo => eventInfo.EventName == defaultEventAttribute.Name)) != (TriggerSourceInformation)null)
                {
                    eventTriggerNode.SetValue(BehaviorEventTriggerNode.EventNameProperty, (object)defaultEventAttribute.Name);
                    flag = true;
                }
                if (!flag && Enumerable.Any <EventInformation>(eventsForType, (Func <EventInformation, bool>)(info => info.EventName.Equals("Loaded", StringComparison.Ordinal))))
                {
                    eventTriggerNode.SetValue(BehaviorEventTriggerNode.EventNameProperty, (object)"Loaded");
                }
                else
                {
                    eventTriggerNode.ClearValue(BehaviorEventTriggerNode.EventNameProperty);
                }
            }
            ISceneNodeCollection <SceneNode> collectionForProperty = eventTriggerNode.Parent.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
            BehaviorTriggerBaseNode          matchingTriggerNode   = BehaviorHelper.FindMatchingTriggerNode(eventTriggerNode.DocumentNode, collectionForProperty);

            if (matchingTriggerNode == null || matchingTriggerNode.Equals((object)eventTriggerNode))
            {
                return;
            }
            for (int index = eventTriggerNode.Actions.Count - 1; index >= 0; --index)
            {
                BehaviorTriggerActionNode action = (BehaviorTriggerActionNode)eventTriggerNode.Actions[index];
                BehaviorHelper.ReparentAction(collectionForProperty, (BehaviorTriggerBaseNode)eventTriggerNode, matchingTriggerNode, action);
            }
            collectionForProperty.Remove((SceneNode)eventTriggerNode);
        }
Ejemplo n.º 3
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);
        }