public void AnimateEntrance() { var sb = new StoryBoard(); foreach (var element in Children.Where(e => e.EntranceAnimation != null)) { sb.AddAnimation(element.EntranceAnimation); } // stub animation for redraw sb.AddAnimation(new FunctionBasedAnimation(FunctionBasedAnimation.Functions.Linear) { From = 0, To = 100, Duration = AnimationDuration, OnAnimation = v => DirectDraw(- _verticalOffset), }); sb.AnimateSync(); // not always animation completes good. after animation correct tiles positions. foreach (var element in Children) element.Location = (element as TileWrapper).GetScreenRect().Location; DirectDraw(- _verticalOffset); FreezeUpdate = true; }
public static void Play(params IAnimation[] animations) { var sb = new StoryBoard(); sb.AddAnimations(animations); sb.AnimateSync(); }
public static void Play(IAnimation animation) { var sb = new StoryBoard(); sb.AddAnimation(animation); sb.AnimateSync(); }
//!! todo - потом переписать не на анимацию каждой плитки, а на централизовано управляемую анимацию //!! todo - и не использовать анимацию контрола, а делать все внутри public void AnimateExit() { FreezeUpdate = false; var scrollRect = new Rectangle(0, _verticalOffset, Bounds.Width, Bounds.Height); var sb = new StoryBoard(); foreach (var curTile in ChildrenEnumerable) { var tileWrapper = curTile as TileWrapper; if (curTile.Bounds.IntersectsWith(scrollRect)) { curTile.ExitAnimation = GetExitAnimation(tileWrapper); curTile.EntranceAnimation = GetEntranceAnimation(tileWrapper); sb.AddAnimation(curTile.ExitAnimation); } else { curTile.EntranceAnimation = null; curTile.ExitAnimation = null; } } // stub animation for redraw sb.AddAnimation(new FunctionBasedAnimation(FunctionBasedAnimation.Functions.Linear) { From = 0, To = 100, Duration = AnimationDuration, OnAnimation = v => DirectDraw(- _verticalOffset), }); sb.AnimateSync(); }