Esempio n. 1
0
        public static TriggerNode ConvertToTrigger(MultiTriggerNode multiTrigger)
        {
            TriggerNode triggerNode = TriggerNode.Factory.Instantiate(multiTrigger.ViewModel);

            if (multiTrigger.Conditions.Count > 0)
            {
                ConditionNode conditionNode = multiTrigger.Conditions[0];
                ((ITriggerConditionNode)triggerNode).Value       = conditionNode.Value;
                ((ITriggerConditionNode)triggerNode).PropertyKey = conditionNode.PropertyKey;
                if (conditionNode.SourceName != null)
                {
                    ((ITriggerConditionNode)triggerNode).SourceName = conditionNode.SourceName;
                }
            }
            List <SceneNode> list1 = new List <SceneNode>((IEnumerable <SceneNode>)multiTrigger.Setters);

            while (multiTrigger.Setters.Count > 0)
            {
                multiTrigger.Setters.RemoveAt(0);
            }
            List <TriggerActionNode> list2 = new List <TriggerActionNode>((IEnumerable <TriggerActionNode>)multiTrigger.EnterActions);

            while (multiTrigger.EnterActions.Count > 0)
            {
                multiTrigger.EnterActions.RemoveAt(0);
            }
            List <TriggerActionNode> list3 = new List <TriggerActionNode>((IEnumerable <TriggerActionNode>)multiTrigger.ExitActions);

            while (multiTrigger.ExitActions.Count > 0)
            {
                multiTrigger.ExitActions.RemoveAt(0);
            }
            TriggersHelper.ReplaceSceneNode((SceneNode)multiTrigger, (SceneNode)triggerNode);
            foreach (SceneNode sceneNode in list1)
            {
                triggerNode.Setters.Add(sceneNode);
            }
            foreach (TriggerActionNode triggerActionNode in list2)
            {
                triggerNode.EnterActions.Add(triggerActionNode);
            }
            foreach (TriggerActionNode triggerActionNode in list3)
            {
                triggerNode.ExitActions.Add(triggerActionNode);
            }
            SceneViewModel viewModel = multiTrigger.ViewModel;

            if (viewModel.ActiveVisualTrigger == multiTrigger)
            {
                viewModel.SetActiveTrigger((TriggerBaseNode)triggerNode);
            }
            return(triggerNode);
        }
Esempio n. 2
0
        private void OperationsView_CurrentChanged(object sender, EventArgs e)
        {
            TimelineOperation timelineOperation = (TimelineOperation)this.operationsView.CurrentItem;

            if (timelineOperation == this.TimelineAction.TimelineOperation)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.SceneNode.ViewModel.CreateEditTransaction(StringTable.TriggerChangeUndoUnit))
            {
                TimelineActionNode actionForOperation = TimelineActionNode.CreateActionForOperation(timelineOperation, this.SceneNode.ViewModel);
                actionForOperation.TargetTimeline = this.TimelineAction.TargetTimeline;
                TriggersHelper.ReplaceSceneNode((SceneNode)this.TimelineAction, (SceneNode)actionForOperation);
                actionForOperation.TargetTimeline.UpdateActionNames();
                this.EnsureProperActions(actionForOperation.FindSceneNodeTypeAncestor <TriggerBaseNode>(), actionForOperation.TargetTimeline);
                editTransaction.Commit();
            }
        }