/// <summary>Creates a new <see cref="EffectController"/> instance.</summary> internal EffectController(Effect effect, EffectCallback effectCallback) { SourceEffect = effect; SourceEffect.Validate(); RuntimeEffect = SourceEffect.Decompose(); State = EffectState.Playing; _rootTimeline = new ParallelTimeline(); RuntimeEffect.DefineTimeline(_rootTimeline, TimeSpan.Zero); if (!GlobalSpeedRatio.IsOne()) { _rootTimeline.SpeedRatio = GlobalSpeedRatio; } _rootTimeline.CurrentStateInvalidated += _rootClockStateChanged; _rootTimeline.Completed += _rootClockCompleted; _effectCallback = effectCallback; _rootClock = _rootTimeline.CreateClock(); var count = RuntimeEffect.ApplyClocks(_rootClock, 0); if (count > 0) { _rootClock.Controller.Begin(); } else { State = EffectState.Completed; _rootClock.Controller.Remove(); if (effectCallback != null) { GuiTimer.StartAfterRender(t => effectCallback(this)); } } }
public ReusableFollowTracker() { _timeline = new ParallelTimeline(null, Duration.Forever); _timeClock = _timeline.CreateClock(); _timeClock.Controller?.Begin(); _lastTime = TimeSpan.FromSeconds(0); }