/// <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)); } } }
internal static extern CameraError SupportedEffects(IntPtr handle, EffectCallback callback, IntPtr userData = default);
/// <summary>Starts playing this effect, and invokes the given callback when the effect is completed.</summary> /// <param name="onComplete">An event handler to invoke when the effect is completed.</param> /// <returns>Returns an effect controller that can be used to interactively pause, resume, seek, skip, and stop the effect.</returns> /// <remarks>When the effect is completed the animated properties and are either reset to their original values or kept at their /// destination values, depending on the <see cref="P:InterpolatorEffect.IsTransient"/> property.</remarks> public EffectController Play(EffectCallback onComplete) { return new EffectController(this, onComplete); }