private void StoryBoardPlay(IAnimation animation) { if (this.animation != null) { this.animation.Cancel(); } this.animation = animation; sb.CancelAsyncAnimate(); sb.Clear(); sb.AddAnimations(this.animation, // hack? implement it better? new CommitStoryboardAnimation() { StartsAt = 400, Duration = 500, CommitAction = () => { this.IsPanoramaAnimating = false; } } ); sb.BeginAnimate(); }
public void AnimateEntrance() { var entranceSb = new StoryBoard(); foreach (var element in this.elements.Where(e => e.EntranceAnimation != null)) { element.EntranceAnimation.Duration = this.EntranceDuration; entranceSb.AddAnimation(element.EntranceAnimation); } if (this.ShadowedAnimationMode != ShadowedAnimationOptions.None) { entranceSb.AddAnimation(new FunctionBasedAnimation(FunctionBasedAnimation.Functions.Linear) { Duration = this.EntranceDuration, To = this.ShadowedAnimationMode == ShadowedAnimationOptions.FromRight ? this.offBmp.Width : -this.offBmp.Width * 3, From = this.ShadowedAnimationMode == ShadowedAnimationOptions.FromRight ? -this.offBmp.Width : -this.offBmp.Width * 1, OnAnimation = v => this.shadowImageX = v }); } entranceSb.AddAnimation(new CommitStoryboardAnimation { Duration = this.EntranceDuration, CommitAction = () => this.ForcedInvalidate() }); entranceSb.BeginAnimate(); }