/// <summary> /// Associates the instance with the specified storyboard and element. /// </summary> /// <param name="storyboard">The <see cref="Storyboard"/> with which to associate the instance.</param> /// <param name="clock">The <see cref="StoryboardClock"/> with which to associate the instance.</param> /// <param name="target">The <see cref="UIElement"/> with which is targeted by the instance.</param> internal void AssociateWith(Storyboard storyboard, UpfPool<StoryboardClock>.PooledObject clock, UIElement target) { Contract.Require(storyboard, nameof(storyboard)); Contract.Require(clock, nameof(clock)); Contract.Require(target, nameof(target)); if (this.storyboard != null) throw new InvalidOperationException(); this.storyboard = storyboard; this.clock = clock; this.target = target; }
/// <summary> /// Reifies an instance of the <see cref="UvssStoryboard"/> class into a new instance of the <see cref="Storyboard"/> class. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="storyboardDefinition">The storyboard definition to reify.</param> /// <returns>The new instance of <see cref="Storyboard"/> that was created.</returns> public static Storyboard ReifyStoryboard(UltravioletContext uv, UvssStoryboard storyboardDefinition) { Contract.Require(uv, "uv"); Contract.Require(storyboardDefinition, "storyboardDefinition"); var storyboard = new Storyboard(uv); storyboard.LoopBehavior = storyboardDefinition.LoopBehavior; foreach (var targetDefinition in storyboardDefinition.Targets) { var target = ReifyStoryboardTarget(uv, targetDefinition); storyboard.Targets.Add(target); } return storyboard; }
/// <summary> /// Adds a storyboard target to the collection. /// </summary> /// <param name="target">The storyboard target to add to the collection.</param> /// <returns><see langword="true"/> if the target was added to the collection; otherwise, <see langword="false"/>.</returns> public Boolean Add(StoryboardTarget target) { Contract.Require(target, nameof(target)); if (target.Storyboard == Storyboard) { return(false); } if (target.Storyboard != null) { target.Storyboard.Targets.Remove(target); } targets.Add(target); target.Storyboard = Storyboard; Storyboard.RecalculateDuration(); return(true); }
/// <summary> /// Disassociates the instance from its current storyboard and element. /// </summary> internal void Disassociate() { if (this.storyboard == null) return; Stop(); if (this.clock != null) StoryboardClockPool.Instance.Release(this.clock); this.storyboard = null; this.clock = null; this.target = null; this.enlistedDependencyProperties.Clear(); }
/// <summary> /// Initializes a new instance of the <see cref="StoryboardTargetCollection"/> class. /// </summary> /// <param name="storyboard">The storyboard that owns the collection.</param> internal StoryboardTargetCollection(Storyboard storyboard) { Contract.Require(storyboard, nameof(storyboard)); this.storyboard = storyboard; }
/// <summary> /// Creates a new <see cref="Storyboard"/> instance from the specified storyboard definition. /// </summary> /// <param name="storyboardDefinition">The storyboard definition to instantiate.</param> /// <returns>The <see cref="Storyboard"/> instance that was created.</returns> private Storyboard InstantiateStoryboard(UvssStoryboard storyboardDefinition) { var storyboardInstance = new Storyboard( Ultraviolet, storyboardDefinition.LoopBehavior); foreach (var targetDefinition in storyboardDefinition.Targets) { var targetInstance = InstantiateStoryboardTarget(targetDefinition); storyboardInstance.Targets.Add(targetInstance); } return storyboardInstance; }