internal static bool IsAnimationValid( DependencyProperty dp, AnimationTimeline animation) { return(dp.PropertyType.IsAssignableFrom(animation.TargetPropertyType) || (animation.TargetPropertyType == typeof(Object))); }
/// <summary> /// Starts an animation for a DependencyProperty. The animation will /// begin when the next frame is rendered. /// </summary> /// <param name="dp"> /// The DependencyProperty to animate. /// </param> /// <param name="animation"> /// <para>The AnimationTimeline to used to animate the property.</para> /// <para>If the AnimationTimeline's BeginTime is null, any current animations /// will be removed and the current value of the property will be held.</para> /// <para>If this value is null, all animations will be removed from the property /// and the property value will revert back to its base value.</para> /// </param> /// <param name="handoffBehavior"> /// Specifies how the new animation should interact with any current /// animations already affecting the property value. /// </param> public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { if (dp == null) { throw new ArgumentNullException("dp"); } if (!AnimationStorage.IsPropertyAnimatable(this, dp)) { #pragma warning disable 56506 // Suppress presharp warning: Parameter 'dp' to this public method must be validated: A null-dereference can occur here. throw new ArgumentException(SR.Get(SRID.Animation_DependencyPropertyIsNotAnimatable, dp.Name, this.GetType()), "dp"); #pragma warning restore 56506 } if (animation != null && !AnimationStorage.IsAnimationValid(dp, animation)) { throw new ArgumentException(SR.Get(SRID.Animation_AnimationTimelineTypeMismatch, animation.GetType(), dp.Name, dp.PropertyType), "animation"); } if (!HandoffBehaviorEnum.IsDefined(handoffBehavior)) { throw new ArgumentException(SR.Get(SRID.Animation_UnrecognizedHandoffBehavior)); } if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.IAnimatable_CantAnimateSealedDO, dp, this.GetType())); } AnimationStorage.BeginAnimation(this, dp, animation, handoffBehavior); }
public bool Contains(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } return(List.Contains(timeline)); }
public int IndexOf(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } return(List.IndexOf(timeline)); }
public void Insert(int index, AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } List.Insert(index, timeline); }
public void Add(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } List.Add(timeline); }
private static IClock CreateAnimationClock(AnimationTimeline timeline) { if (!timeline.Duration.HasTimeSpan) { throw new Granular.Exception("Can't resolve animation duration \"{0}\"", timeline.Duration); } return new AnimationClock(timeline.Duration.TimeSpan); }
private static IClock CreateAnimationClock(AnimationTimeline timeline) { if (!timeline.Duration.HasTimeSpan) { throw new Granular.Exception("Can't resolve animation duration \"{0}\"", timeline.Duration); } return(new AnimationClock(timeline.Duration.TimeSpan)); }
public int IndexOf(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } return List.IndexOf(timeline); }
public void CopyTo(AnimationTimeline[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } List.CopyTo(array, arrayIndex); }
public bool Contains(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } return List.Contains(timeline); }
/// <summary> /// Method to configure and start an animation. /// </summary> private static AnimationClock Animate( DependencyObject animatable, DependencyProperty prop, AnimationTimeline anim, int duration, double? accel, double? decel, EventHandler func, EventHandler durationfunc ) { anim.AccelerationRatio = accel.GetValueOrDefault(0); anim.DecelerationRatio = decel.GetValueOrDefault(0); anim.Duration = TimeSpan.FromMilliseconds(duration); anim.Freeze(); AnimationClock animClock = anim.CreateClock(); // When animation is complete, remove animation and set the animation's "To" // value as the new value of the property. EventHandler eh = null; eh = delegate(object sender, EventArgs e) { animatable.SetValue(prop, animatable.GetValue(prop)); ((IAnimatable)animatable).ApplyAnimationClock(prop, null); animClock.Completed -= eh; }; animClock.Completed += eh; // assign completed eventHandler, if defined if (func != null) { animClock.Completed += func; } else { durationfunc(null,null); } animClock.Controller.Begin(); // goferit ((IAnimatable)animatable).ApplyAnimationClock(prop, animClock); return animClock; }
public bool Remove(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } if (List.Contains(timeline) == false) { return(false); } List.Remove(timeline); return(true); }
public bool Remove(AnimationTimeline timeline) { if (timeline == null) { throw new ArgumentNullException("timeline"); } if (List.Contains(timeline) == false) { return false; } List.Remove(timeline); return true; }
public void BeginAnimation(DependencyProperty property, AnimationTimeline animation, HandoffBehavior handoffBehavior) { if (_animations == null) { _animations = new Hashtable(); } AnimationTimelineCollection timelines = _animations[property.GlobalIndex] as AnimationTimelineCollection; if (timelines == null) { _animations[property.GlobalIndex] = timelines = new AnimationTimelineCollection(); } timelines.Add(animation); }
public static void Add(DependencyObject element, AnimationKind type, AnimationTimeline animation) { switch(type) { case AnimationKind.BackgroundColor: Storyboard.SetTargetProperty(animation, new PropertyPath("Background.Color")); break; case AnimationKind.BorderColor: Storyboard.SetTargetProperty(animation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)")); break; case AnimationKind.BackgroundOpacity: Storyboard.SetTargetProperty(animation, new PropertyPath("Background.Opacity")); break; case AnimationKind.DropShadowOpacity: Storyboard.SetTargetProperty(animation, new PropertyPath("Effect.Opacity")); break; case AnimationKind.DropShadowBlur: Storyboard.SetTargetProperty(animation, new PropertyPath("Effect.BlurRadius")); break; case AnimationKind.Opacity: Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity")); break; case AnimationKind.TranslateX: Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); break; case AnimationKind.TranslateY: Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)")); break; case AnimationKind.Margin: Storyboard.SetTargetProperty(animation, new PropertyPath("Margin")); break; case AnimationKind.Width: Storyboard.SetTargetProperty(animation, new PropertyPath("Width")); break; case AnimationKind.Height: Storyboard.SetTargetProperty(animation, new PropertyPath("Height")); break; default: break; } Storyboard.SetTarget(animation, element); sboard.Children.Add(animation); }
public SbItem(TranslateTransform transform, DependencyProperty dp, AnimationTimeline animation) { this.transform = transform; this.dp = dp; this.animation = animation; }
protected internal AnimationClock(AnimationTimeline animation) : base (default(Timeline)) { }
/// <summary> /// Starts an animation for a DependencyProperty. The animation will /// begin when the next frame is rendered. /// </summary> /// <param name="dp"> /// The DependencyProperty to animate. /// </param> /// <param name="animation"> /// <para>The AnimationTimeline to used to animate the property.</para> /// <para>If the AnimationTimeline's BeginTime is null, any current animations /// will be removed and the current value of the property will be held.</para> /// <para>If this value is null, all animations will be removed from the property /// and the property value will revert back to its base value.</para> /// </param> public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation) { BeginAnimation(dp, animation, HandoffBehavior.SnapshotAndReplace); }
public AnimationTimelineClock(AnimationTimeline timeline) : base(CreateAnimationClock(timeline), timeline) { this.timeline = timeline; }
protected internal AnimationClock(AnimationTimeline animation) : base(default(Timeline)) { }
protected internal AnimationClock(AnimationTimeline timeline) : base(timeline) { myTimeline = timeline; }
public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation);
protected internal AnimationClock(AnimationTimeline animation) : base(animation) { throw new NotImplementedException(); }
public void BeginAnimation (DependencyProperty dp, AnimationTimeline animation) { throw new NotImplementedException (); }
public void BeginAnimation (DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { throw new NotImplementedException (); }
public static void BeginAnimation(this IAnimatable animatable, DependencyProperty dependencyProperty, AnimationTimeline animation, HandoffBehavior handoffBehavior = HandoffBehavior.SnapshotAndReplace, object layerOwner = null) { AnimationTimelineClock animationClock = (AnimationTimelineClock)animation.CreateClock(); animatable.ApplyAnimationClock(dependencyProperty, animationClock, handoffBehavior, layerOwner); animationClock.Begin(animatable.RootClock); }
/// <summary> /// Starts an animation for a DependencyProperty. The animation will /// begin when the next frame is rendered. /// </summary> /// <param name="dp"> /// The DependencyProperty to animate. /// </param> /// <param name="animation"> /// <para>The AnimationTimeline to used to animate the property.</para> /// <para>If the AnimationTimeline's BeginTime is null, any current animations /// will be removed and the current value of the property will be held.</para> /// <para>If this value is null, all animations will be removed from the property /// and the property value will revert back to its base value.</para> /// </param> /// <param name="handoffBehavior"> /// Specifies how the new animation should interact with any current /// animations already affecting the property value. /// </param> public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { if (dp == null) { throw new ArgumentNullException("dp"); } if (!AnimationStorage.IsPropertyAnimatable(this, dp)) { #pragma warning disable 56506 // Suppress presharp warning: Parameter 'dp' to this public method must be validated: A null-dereference can occur here. throw new ArgumentException(SR.Get(SRID.Animation_DependencyPropertyIsNotAnimatable, dp.Name, this.GetType()), "dp"); #pragma warning restore 56506 } if ( animation != null && !AnimationStorage.IsAnimationValid(dp, animation)) { throw new ArgumentException(SR.Get(SRID.Animation_AnimationTimelineTypeMismatch, animation.GetType(), dp.Name, dp.PropertyType), "animation"); } if (!HandoffBehaviorEnum.IsDefined(handoffBehavior)) { throw new ArgumentException(SR.Get(SRID.Animation_UnrecognizedHandoffBehavior)); } if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.IAnimatable_CantAnimateSealedDO, dp, this.GetType())); } AnimationStorage.BeginAnimation(this, dp, animation, handoffBehavior); }
public void BeginAnimation(System.Windows.DependencyProperty dp, AnimationTimeline animation) { }
public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior);
public void BeginAnimation(System.Windows.DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { }
internal static void BeginAnimation( DependencyObject d, DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { // Caller should be validating animation. Debug.Assert(animation == null || IsAnimationValid(dp, animation)); Debug.Assert(IsPropertyAnimatable(d, dp)); Debug.Assert(HandoffBehaviorEnum.IsDefined(handoffBehavior), "Public API caller of this internal method is responsible for validating that the HandoffBehavior value is valid."); AnimationStorage storage = GetStorage(d, dp); if (animation == null) { if (storage == null || handoffBehavior == HandoffBehavior.Compose) { // Composing with a null animation is a no-op. return; } else { // When the incoming animation is passed in as null and // handoffBehavior == HandoffBehavior.SnapshotAndReplace it means // that we should stop any and all animation behavior for // this property. if (storage._hasStickySnapshotValue) { storage._hasStickySnapshotValue = false; storage._animationClocks[0].CurrentStateInvalidated -= new EventHandler(storage.OnCurrentStateInvalidated); } storage._snapshotValue = DependencyProperty.UnsetValue; storage.ClearAnimations(); } } else if (animation.BeginTime.HasValue) { // We have an animation AnimationClock animationClock; animationClock = animation.CreateClock(); // note that CreateClock also calls InternalBeginIn ApplyAnimationClocks(d, dp, new AnimationClock[] { animationClock }, handoffBehavior); // ApplyAnimationClocks has fixed up the storage and called // WritePostscript already so we can just return. return; } else if (storage == null) { // The user gave us an animation with a BeginTime of null which // means snapshot the current value and throw away all animations // for SnapshotAndReplace and means nothing for Compose. // But since we don't have any animations the current we don't // have to do anything for either of these cases. return; } else if (handoffBehavior == HandoffBehavior.SnapshotAndReplace) { // This block handles the case where the user has called // BeginAnimation with an animation that has a null begin time. // We handle this by taking a snapshot value and throwing // out the animation, which is the same as keeping it because // we know it will never start. // // If the handoffBehavior is Compose, we ignore the user's call // because it wouldn't mean anything unless they were planning // on changing the BeginTime of their animation later, which we // don't support. // If _hasStickySnapshotValue is set, unset it and remove our // event handler from the clock. The current snapshot value // will still be used. if (storage._hasStickySnapshotValue) { Debug.Assert(storage._animationClocks != null && storage._animationClocks.Count > 0, "If _hasStickySnapshotValue is set we should have at least one animation clock stored in the AnimationStorage."); storage._hasStickySnapshotValue = false; storage._animationClocks[0].CurrentStateInvalidated -= new EventHandler(storage.OnCurrentStateInvalidated); } // Otherwise take a new snapshot value. else { storage._snapshotValue = d.GetValue(dp); } storage.ClearAnimations(); } // If storage were null we would have returned already. storage.WritePostscript(); }
public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation) { throw new NotImplementedException(); }
public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { throw new NotImplementedException(); }
internal static bool IsAnimationValid( DependencyProperty dp, AnimationTimeline animation) { return dp.PropertyType.IsAssignableFrom(animation.TargetPropertyType) || (animation.TargetPropertyType == typeof(Object)); }
internal static void BeginAnimation( DependencyObject d, DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior) { // Caller should be validating animation. Debug.Assert(animation == null || IsAnimationValid(dp, animation)); Debug.Assert(IsPropertyAnimatable(d, dp)); Debug.Assert(HandoffBehaviorEnum.IsDefined(handoffBehavior), "Public API caller of this internal method is responsible for validating that the HandoffBehavior value is valid." ); AnimationStorage storage = GetStorage(d, dp); if (animation == null) { if ( storage == null || handoffBehavior == HandoffBehavior.Compose) { // Composing with a null animation is a no-op. return; } else { // When the incoming animation is passed in as null and // handoffBehavior == HandoffBehavior.SnapshotAndReplace it means // that we should stop any and all animation behavior for // this property. if (storage._hasStickySnapshotValue) { storage._hasStickySnapshotValue = false; storage._animationClocks[0].CurrentStateInvalidated -= new EventHandler(storage.OnCurrentStateInvalidated); } storage._snapshotValue = DependencyProperty.UnsetValue; storage.ClearAnimations(); } } else if (animation.BeginTime.HasValue) { // We have an animation AnimationClock animationClock; animationClock = animation.CreateClock(); // note that CreateClock also calls InternalBeginIn ApplyAnimationClocks(d, dp, new AnimationClock[] { animationClock }, handoffBehavior); // ApplyAnimationClocks has fixed up the storage and called // WritePostscript already so we can just return. return; } else if (storage == null) { // The user gave us an animation with a BeginTime of null which // means snapshot the current value and throw away all animations // for SnapshotAndReplace and means nothing for Compose. // But since we don't have any animations the current we don't // have to do anything for either of these cases. return; } else if (handoffBehavior == HandoffBehavior.SnapshotAndReplace) { // This block handles the case where the user has called // BeginAnimation with an animation that has a null begin time. // We handle this by taking a snapshot value and throwing // out the animation, which is the same as keeping it because // we know it will never start. // // If the handoffBehavior is Compose, we ignore the user's call // because it wouldn't mean anything unless they were planning // on changing the BeginTime of their animation later, which we // don't support. // If _hasStickySnapshotValue is set, unset it and remove our // event handler from the clock. The current snapshot value // will still be used. if (storage._hasStickySnapshotValue) { Debug.Assert(storage._animationClocks != null && storage._animationClocks.Count > 0, "If _hasStickySnapshotValue is set we should have at least one animation clock stored in the AnimationStorage."); storage._hasStickySnapshotValue = false; storage._animationClocks[0].CurrentStateInvalidated -= new EventHandler(storage.OnCurrentStateInvalidated); } // Otherwise take a new snapshot value. else { storage._snapshotValue = d.GetValue(dp); } storage.ClearAnimations(); } // If storage were null we would have returned already. storage.WritePostscript(); }
protected internal AnimationClock (AnimationTimeline animation) : base (animation) { throw new NotImplementedException (); }
private void ColorAnimationBasicTest(AnimationTimeline animation, Color defaultOriginValue, Color defaultDestinationValue, Color expectedStartValue, Color expectedMiddleValue, Color expectedEndValue) { AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock(); TestRootClock rootClock = new TestRootClock(); clock.Begin(rootClock); rootClock.Tick(TimeSpan.Zero); Assert.AreEqual(expectedStartValue, (Color)animation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, clock)); rootClock.Tick(animation.Duration.TimeSpan.Scale(0.5)); Assert.AreEqual(expectedMiddleValue, (Color)animation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, clock)); rootClock.Tick(animation.Duration.TimeSpan); Assert.AreEqual(expectedEndValue, (Color)animation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, clock)); }