public static void CreateDefaultTrigger(StoryboardTimelineSceneNode storyboard) { ITriggerContainer triggerContainer = (ITriggerContainer)storyboard.StoryboardContainer ?? storyboard.ViewModel.RootNode as ITriggerContainer; if (triggerContainer == null || !triggerContainer.CanEditTriggers) { return; } SceneViewModel viewModel = storyboard.ViewModel; IProjectContext projectContext = viewModel.ProjectContext; IType type = projectContext.GetType(triggerContainer.TargetElementType); if (type == null) { return; } TriggerSourceInformation triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultEvent((ITypeResolver)projectContext, type); if (!(triggerSource != (TriggerSourceInformation)null)) { return; } TriggerBaseNode orCreateTrigger = TriggersHelper.FindOrCreateTrigger(triggerSource, triggerContainer, viewModel); if (orCreateTrigger == null) { return; } TimelineActionNode timelineActionNode = (TimelineActionNode)BeginActionNode.Factory.Instantiate(viewModel); timelineActionNode.TargetTimeline = storyboard; TriggersHelper.DefaultAddAction(orCreateTrigger, (TriggerActionNode)timelineActionNode); }
public void CreateNewEventTrigger() { if (this.CurrentContainer == null) { return; } SceneViewModel activeSceneViewModel = this.ActiveSceneViewModel; SceneDocument document = activeSceneViewModel.Document; ITriggerContainer currentContainer = this.CurrentContainer; using (SceneEditTransaction editTransaction = document.CreateEditTransaction(StringTable.TriggerChangeUndoUnit)) { IProjectContext projectContext = document.ProjectContext; IType type = projectContext.GetType(currentContainer.TargetElementType); if (type != null) { TriggerSourceInformation triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultEvent((ITypeResolver)projectContext, type); if (triggerSource != (TriggerSourceInformation)null) { TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, activeSceneViewModel); if (trigger != null) { int index = currentContainer.VisualTriggers.Count; if (this.selectedItem != null) { index = this.selectedItem != this.noneTrigger ? currentContainer.VisualTriggers.IndexOf(this.selectedItem.SceneNode) + 1 : 0; } currentContainer.VisualTriggers.Insert(index, trigger); this.TriggerToBeSelected = trigger; } } } editTransaction.Commit(); } }