public bool GoToState(VisualState state, bool useTransitions) { if (state == CurrentState) { return true; } string currentStateName = CurrentState != null ? CurrentState.Name : String.Empty; VisualTransition transition = useTransitions ? GetTransition(Transitions, currentStateName, state.Name) : null; Storyboard transitionStoryboard = transition != null ? transition.Storyboard : null; Storyboard storyboard; if (transitionStoryboard != null && state.Storyboard != null) { // create a sequential animation with the transition storyboard first and then the state storyboard SequentialTimeline sequentialTimeline = new SequentialTimeline(); sequentialTimeline.Children.Add(transitionStoryboard); sequentialTimeline.Children.Add(state.Storyboard); storyboard = new Storyboard(); storyboard.Children.Add(sequentialTimeline); } else { storyboard = transitionStoryboard ?? state.Storyboard; } StartNewStoryboard(storyboard); CurrentState = state; return true; }
public void SequentialTimelineClockStoryboardTest() { DoubleAnimation animation1 = new DoubleAnimation { To = 100, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)) }; DoubleAnimation animation2 = new DoubleAnimation { To = 200, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(0)) }; DoubleAnimation animation3 = new DoubleAnimation { To = 300, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)) }; SequentialTimeline sequentialTimeline = new SequentialTimeline(); sequentialTimeline.Children.Add(animation1); sequentialTimeline.Children.Add(animation2); sequentialTimeline.Children.Add(animation3); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(sequentialTimeline); FrameworkElement element = new FrameworkElement { Width = 0, Height = 0 }; Storyboard.SetTarget(animation1, element); Storyboard.SetTargetProperty(animation1, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty)); Storyboard.SetTarget(animation2, element); Storyboard.SetTargetProperty(animation2, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty)); Storyboard.SetTarget(animation3, element); Storyboard.SetTargetProperty(animation3, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty)); TestRootClock rootClock = new TestRootClock(); element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true)); storyboard.Begin(element); rootClock.Tick(TimeSpan.FromSeconds(0)); Assert.AreEqual(0, element.Width); rootClock.Tick(TimeSpan.FromSeconds(0.9)); Assert.AreEqual(90, element.Width); rootClock.Tick(TimeSpan.FromSeconds(1)); Assert.AreEqual(200, element.Width); rootClock.Tick(TimeSpan.FromSeconds(1.5)); Assert.AreEqual(250, element.Width); rootClock.Tick(TimeSpan.FromSeconds(2)); Assert.AreEqual(300, element.Width); }
public SequentialTimelineClock(SequentialTimeline SequentialTimeline, IEnumerable<TimelineClock> children) : base(new SequentialClock(children), SequentialTimeline, children) { // }
public SequentialTimelineClock(SequentialTimeline SequentialTimeline, IEnumerable <TimelineClock> children) : base(new SequentialClock(children), SequentialTimeline, children) { // }