private static void CreateAnimationForViews(object sender) { var autoView = (((((sender as FrameworkElement).Parent) as FrameworkElement).Parent as FrameworkElement).Parent as AutoView); int animationLength = 0; if (autoView.IsAnimated) { animationLength = autoView.AnimationsLengthMilliSecond; } var controlWidth = autoView.autoViewGrid.ActualWidth; var newViewAnimation = new SimpleAnimation(sender as FrameworkElement, TimeSpan.FromMilliseconds(animationLength), 0 - controlWidth, 0, AnimationType.Normal, AnimationOrientation.Horizontal); if (autoView.autoViewGrid.Children.Count > 1) { var unWantedView = autoView.autoViewGrid.Children.FirstOrDefault(i => i != sender && _simpleAnimationList.Any(j => j.AtachedFrameworkElement == i) == false); if (unWantedView != null) { _simpleAnimationList.Add(new SimpleAnimation(unWantedView as FrameworkElement, TimeSpan.FromMilliseconds(animationLength), 0, 0 + controlWidth, AnimationType.Normal, AnimationOrientation.Horizontal, (ss) => { autoView.autoViewGrid.Children.Remove(ss as FrameworkElement); _simpleAnimationList.Remove(_simpleAnimationList.First(i => i.AtachedFrameworkElement == ss)); })); _simpleAnimationList.Last().PlayAnimation(); } newViewAnimation.PlayAnimation(); } }
public void PlayMotion(PetState state) { _animationController.PlayAnimation(PetDefine.GetPetMotion(state)); }