private TriggerModel3 TriggerSubscription_Inserted(object sender, SceneNode basisNode, object basisContent, SceneNode newPathNode) { TriggerBaseNode trigger = (TriggerBaseNode)newPathNode; TriggerModel3 triggerModel3 = TriggerModel3.ConstructModel(trigger, this); if (triggerModel3 != null) { ITriggerContainer currentContainer = this.CurrentContainer; if (currentContainer == null) { return((TriggerModel3)null); } int triggerIndex = this.GetTriggerIndex(currentContainer, trigger); if (triggerIndex == -1) { return((TriggerModel3)null); } if (this.ShouldDisplayNoneTrigger) { ++triggerIndex; } this.triggerModels.Insert(triggerIndex, triggerModel3); if (trigger == this.TriggerToBeSelected) { this.TriggerToBeSelected = (TriggerBaseNode)null; this.SelectedItem = triggerModel3; } } return(triggerModel3); }
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(); } }
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); }
private static void StripStoryboardsAndTriggers(SceneElement element) { BaseFrameworkElement frameworkElement = element as BaseFrameworkElement; if (frameworkElement != null && frameworkElement.Resources != null) { List <DictionaryEntryNode> list = new List <DictionaryEntryNode>(); foreach (DictionaryEntryNode dictionaryEntryNode in frameworkElement.Resources) { if (dictionaryEntryNode.Value != null && PlatformTypes.Storyboard.IsAssignableFrom((ITypeId)dictionaryEntryNode.Value.Type)) { list.Add(dictionaryEntryNode); } } foreach (DictionaryEntryNode dictionaryEntryNode in list) { frameworkElement.Resources.Remove(dictionaryEntryNode); } } ITriggerContainer triggerContainer = (ITriggerContainer)element.StoryboardContainer; if (triggerContainer == null || !triggerContainer.CanEditTriggers) { return; } triggerContainer.VisualTriggers.Clear(); }
private static string CreateBeginActionName(ITriggerContainer storyboardContainer, string timelineName) { string str = timelineName + StringTable.TriggerDefaultActionName; SceneNode sceneNode = (SceneNode)storyboardContainer; SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(sceneNode.ViewModel, sceneNode); if (!sceneNodeIdHelper.IsValidElementID(sceneNode, str)) { str = sceneNodeIdHelper.GetValidElementID(sceneNode, str); } return(str); }
private int GetTriggerIndex(ITriggerContainer container, TriggerBaseNode trigger) { int num = 0; foreach (TriggerBaseNode triggerBaseNode in (IEnumerable <TriggerBaseNode>)container.VisualTriggers) { if (triggerBaseNode == trigger) { return(num); } if (PlatformTypes.Trigger.IsAssignableFrom((ITypeId)triggerBaseNode.Type) || PlatformTypes.MultiTrigger.IsAssignableFrom((ITypeId)triggerBaseNode.Type) || PlatformTypes.EventTrigger.IsAssignableFrom((ITypeId)triggerBaseNode.Type)) { ++num; } } return(-1); }
public void CreateNewPropertyTrigger() { if (this.CurrentContainer == null) { return; } ITriggerContainer currentContainer = this.CurrentContainer; SceneViewModel activeSceneViewModel = this.ActiveSceneViewModel; SceneDocument document = activeSceneViewModel.Document; StyleNode styleNode = currentContainer as StyleNode; FrameworkTemplateElement frameworkTemplateElement = currentContainer as FrameworkTemplateElement; using (SceneEditTransaction editTransaction = document.CreateEditTransaction(StringTable.TriggerChangeUndoUnit)) { TriggerSourceInformation triggerSource = (TriggerSourceInformation)null; if (styleNode != null || frameworkTemplateElement != null) { triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultProperty(currentContainer.TargetElementType, document.DocumentContext); } 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); activeSceneViewModel.SetActiveTrigger(trigger); } } editTransaction.Commit(); } }
internal override void ContainIn(ITriggerContainer container) { container.Schedule = this; }
internal override void WrapInContainer(ITriggerContainer container) => container.Schedule = this;
internal abstract void WrapInContainer(ITriggerContainer container);
internal abstract void ContainIn(ITriggerContainer container);
public static TriggerBaseNode FindOrCreateTrigger(TriggerSourceInformation triggerSource, ITriggerContainer triggerContainer, SceneViewModel viewModel) { RoutedEventInformation eventInformation = triggerSource as RoutedEventInformation; PropertyInformation propertyInformation = triggerSource as PropertyInformation; foreach (TriggerBaseNode triggerBaseNode in (IEnumerable <TriggerBaseNode>)triggerContainer.VisualTriggers) { EventTriggerNode eventTriggerNode = triggerBaseNode as EventTriggerNode; TriggerNode triggerNode = triggerBaseNode as TriggerNode; if (eventTriggerNode != null && (TriggerSourceInformation)eventInformation != (TriggerSourceInformation)null && eventTriggerNode.RoutedEvent == eventInformation.RoutedEvent) { return((TriggerBaseNode)eventTriggerNode); } if (triggerNode != null && (TriggerSourceInformation)propertyInformation != (TriggerSourceInformation)null && ((ITriggerConditionNode)triggerNode).PropertyKey == propertyInformation.DependencyProperty) { return((TriggerBaseNode)triggerNode); } } TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, viewModel); if (trigger != null) { triggerContainer.VisualTriggers.Add(trigger); } return(trigger); }