Ejemplo n.º 1
0
        public static async Task <Storyboard> FrameSwipe_Base(Frame frame, object content, ExpandDirection direction, bool useFade, bool fadeIn)
        {
            return(await Application.Current.Dispatcher.InvokeAsync(() =>
            {
                AnimationArgs animationArgs = new AnimationArgs();

                SetCurrentPage(animationArgs, frame, content);
                StorePageValues(animationArgs);
                SetPageValuesForAnimation(animationArgs);

                Storyboard storyboard = new Storyboard();
                Duration duration = new Duration(TimeSpan.FromMilliseconds(GetSwipeSpeed()));

                if (useFade)
                {
                    var fadeAnim = GetFadeAnimation(duration, fadeIn);
                    storyboard.Children.Add(fadeAnim);
                    Storyboard.SetTargetProperty(fadeAnim, new PropertyPath(Frame.OpacityProperty));
                    Storyboard.SetTarget(fadeAnim, frame);
                }

                var swipeAnim = GetSwipeAnimation(animationArgs, GetSwipeSize(), duration, direction);
                storyboard.Children.Add(swipeAnim);
                Storyboard.SetTargetProperty(swipeAnim, new PropertyPath(Frame.MarginProperty));
                Storyboard.SetTarget(swipeAnim, frame);
                return storyboard;
            }));
        }
Ejemplo n.º 2
0
        private static ThicknessAnimation GetSwipeAnimation(AnimationArgs animationArgs, double size, Duration duration, ExpandDirection direction)
        {
            ThicknessAnimation animation0 = new ThicknessAnimation();

            switch (direction)
            {
            case ExpandDirection.Left:
                animation0.From = new Thickness(-size, 0, size, 0);
                break;

            case ExpandDirection.Right:
                animation0.From = new Thickness(size, 0, -size, 0);
                break;

            case ExpandDirection.Up:
                animation0.From = new Thickness(0, -size, 0, size);
                break;

            case ExpandDirection.Down:
                animation0.From = new Thickness(0, size, 0, -size);
                break;
            }

            animation0.To         = new Thickness(0, 0, 0, 0);
            animation0.Completed += (sender, e) =>
            {
                ResetPageValues(animationArgs);
            };
            animation0.Duration       = duration;
            animation0.EasingFunction = GetSwipeAnimationEasingFunction();
            return(animation0);
        }
Ejemplo n.º 3
0
        private void OnUnitsFull(AnimationArgs args)
        {
            unitCountText.fontSize = args.fontSize.active;
            unitCountText.DOFontSize(args.fontSize.inactive, args.animTime)
            .Replace(ref fontSizeTween);

            unitCountText.color = args.color.active;
            unitCountText.DOColor(args.color.inactive, args.animTime)
            .Replace(ref colorTween);
        }
Ejemplo n.º 4
0
 private static void ResetPageValues(AnimationArgs args)
 {
     if (args.CurrentContent == null)
     {
         return;
     }
     args.CurrentContent.MinWidth  = args.stored_min_width;
     args.CurrentContent.MinHeight = args.stored_min_height;
     args.CurrentContent.MaxWidth  = args.stored_max_width;
     args.CurrentContent.MaxHeight = args.stored_max_height;
 }
Ejemplo n.º 5
0
        protected virtual void Animate(AnimationArgs args, Vector2 initialPos, Vector2 targetPos)
        {
            canvasGroup.DOFade(args.targetAlpha, duration)
            .SetEase(args.ease)
            .Replace(ref alphaTween);

            rectTransform.anchoredPosition = initialPos;
            rectTransform.DOAnchorPos(targetPos, duration)
            .SetEase(args.ease)
            .Replace(ref positionTween);
        }
Ejemplo n.º 6
0
        private static void SetCurrentPage(AnimationArgs animationArgs, Frame frame, object content)
        {
            if (content is Page)
            {
                animationArgs.CurrentContent = content as Page;
            }
            else
            {
                animationArgs.CurrentContent = null;
            }

            animationArgs.stored_width  = frame.ActualWidth;
            animationArgs.stored_height = frame.ActualHeight;
        }
Ejemplo n.º 7
0
 void OnAnimationStart(object sender, AnimationArgs args)
 {
     //Debug.Log(name + ": Starting animation.");
 }
Ejemplo n.º 8
0
 void OnAnimationEnd(object sender, AnimationArgs args)
 {
     //Debug.Log(name + ": Done animating.");
 }