Exemplo n.º 1
0
        protected IEnumerator PlaySlideOutAnimation(HideAnimation animation)
        {
            var distance = GetDistanceForSlideAnimation(animation.ToSlideDirection());

            if (distance.x != 0)
            {
                yield return(MoveDistanceX(distance.x, AnimationDuration));

                CanvasGroup.alpha = 0;

                yield return(null);

                yield return(MoveDistanceX(-distance.x, 0));
            }
            else if (distance.y != 0)
            {
                yield return(MoveDistanceY(distance.y, AnimationDuration));

                CanvasGroup.alpha = 0;

                yield return(null);

                yield return(MoveDistanceY(-distance.y, 0));
            }
        }
Exemplo n.º 2
0
        protected IEnumerator PlayHideAnimation(HideAnimation animation)
        {
            // Don't start animating if we're already animating (wait for the animation to finish first)
            while (_IsAnimating)
            {
                yield return(new WaitForEndOfFrame());
            }

            _IsAnimating = true;

            if (HideAnimationDelay > 0)
            {
                yield return(new WaitForSeconds(HideAnimationDelay));
            }

            CanvasGroup.blocksRaycasts = false;

            if (animation.IsSlideAnimation())
            {
                m_Animator.enabled = false;
                yield return(PlaySlideOutAnimation(animation));
            }
            else
            {
                m_Animator.enabled = true;
                m_Animator.speed   = 0.25f / AnimationDuration;
                m_Animator.Play(animation.ToString());
                yield return(new WaitForSeconds(m_Animator.GetCurrentAnimatorStateInfo(0).length / m_Animator.speed));

                m_Animator.enabled = false;
            }

            _IsAnimating = false;
        }
Exemplo n.º 3
0
 private void Refresh()
 {
     if (CurrentSong?.Equals(TargetSong) ?? false)
     {
         ShowAnimation.Begin();
     }
     else
     {
         HideAnimation.Begin();
     }
 }
Exemplo n.º 4
0
 private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs args)
 {
     if (args.GetCurrentPoint(this).Properties.MouseWheelDelta >= -20)
     {
         return;
     }
     if (HideAnimation.GetCurrentState() == ClockState.Active)
     {
         return;
     }
     Hide();
 }
Exemplo n.º 5
0
        public async void Hide()
        {
            await SetupCircleCoverAsync();

            if (ViewModel.ActiveSong != null)
            {
                ConnectedAnimationService.GetForCurrentView().DefaultDuration = TimeSpan.FromMilliseconds(500);
                ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(ConnectedAnimationKeys.SpotlightTransition, CircleCover);
            }

            OnHiding();
            HideAnimation.Begin();
        }
Exemplo n.º 6
0
        public static bool IsSlideAnimation(this HideAnimation hideAnimation)
        {
            switch (hideAnimation)
            {
            case HideAnimation.SlideOut_Bottom:
            case HideAnimation.SlideOut_Top:
            case HideAnimation.SlideOut_Left:
            case HideAnimation.SlideOut_Right:
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 7
0
        public static SlideDirection ToSlideDirection(this HideAnimation hideAnimation)
        {
            switch (hideAnimation)
            {
            case HideAnimation.SlideOut_Bottom: return(SlideDirection.Bottom);

            case HideAnimation.SlideOut_Top: return(SlideDirection.Top);

            case HideAnimation.SlideOut_Left: return(SlideDirection.Left);

            case HideAnimation.SlideOut_Right: return(SlideDirection.Right);

            default: return(SlideDirection.Top);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it

            Button button1 = FindViewById <Button>(Resource.Id.MyButton1);
            Button button2 = FindViewById <Button>(Resource.Id.MyButton2);

            Button button3 = FindViewById <Button>(Resource.Id.MyButton3);
            Button button4 = FindViewById <Button>(Resource.Id.MyButton4);

            button1.Click += delegate { button1.Text = string.Format("{0} clicks!", count++); };
            button2.Click += delegate { button2.Text = string.Format("{0} clicks!", count++); };
            button3.Click += delegate { button3.Text = string.Format("{0} clicks!", count++); };
            button4.Click += delegate { button4.Text = string.Format("{0} clicks!", count++); };

            button1.SetBackgroundColor(Android.Graphics.Color.Blue);
            button2.SetBackgroundColor(Android.Graphics.Color.Red);
            button3.SetBackgroundColor(Android.Graphics.Color.Green);
            button4.SetBackgroundColor(Android.Graphics.Color.SlateGray);

            JazzHandsHorizontalScrollView scrollView = FindViewById <JazzHandsHorizontalScrollView> (Resource.Id.ScrollView);

            scrollView.Pages = _totalPages;
            scrollView.Views.Add(button1);
            scrollView.Views.Add(button2);
            scrollView.Views.Add(button3);
            scrollView.Views.Add(button4);

            scrollView.PageScroll(FocusSearchDirection.Left);
            scrollView.FillViewport = true;

            Console.WriteLine("Setup Alpha Anim");
            AlphaAnimation button1AlphaAnim = new AlphaAnimation(button1);

            scrollView.Animator.AddAnimation(button1AlphaAnim);

            button1AlphaAnim.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(1),
                Alpha = 0.0f
            });
            button1AlphaAnim.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(2),
                Alpha = 1.0f
            });

            AlphaAnimation button2AlphaAnim = new AlphaAnimation(button2);

            scrollView.Animator.AddAnimation(button2AlphaAnim);

            button2AlphaAnim.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(1),
                Alpha = 0.0f
            });
            button2AlphaAnim.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(2),
                Alpha = 1.0f
            });


            Console.WriteLine("Setup Alpha Anim End");

            Console.WriteLine("Setup Frame Anim");

            var button1FrameAnimation = new FrameAnimation(button1);

            scrollView.Animator.AddAnimation(button1FrameAnimation);

            var newAnimaitons = new List <AnimationFrameBase> ();

            var temp1 = new RectangleF(button1.GetX(), button1.GetY(), button1.Width, button1.Height);

            temp1.Offset(new PointF(0, 0));

            newAnimaitons.Add(new AnimationFrame()
            {
                Time  = TimeForPage(1),
                Frame = temp1
            });

            var temp2 = new RectangleF(button1.GetX(), button1.GetY(), button1.Width, button1.Height);

            temp2.Offset(new PointF(Resources.DisplayMetrics.WidthPixels, dy));

            newAnimaitons.Add(new AnimationFrame()
            {
                Time  = TimeForPage(2),
                Frame = temp2
            });

            var temp3 = new RectangleF(button1.GetX(), button1.GetY(), button1.Width, button1.Height);

            temp3.Offset(new PointF(Resources.DisplayMetrics.WidthPixels / 2, 0));

            newAnimaitons.Add(new AnimationFrame()
            {
                Time  = TimeForPage(3),
                Frame = temp3
            });

            button1FrameAnimation.AddKeyFrames(newAnimaitons);

            // button3

            var button3FrameAnimation = new FrameAnimation(button3);

            scrollView.Animator.AddAnimation(button3FrameAnimation);

            var newAnimaitonsbutton3 = new List <AnimationFrameBase> ();
            //
            //			var temp4 = new RectangleF (button3.GetX(), button3.GetY(), button3.Width, button3.Height);
            //			temp4.Offset (new PointF (button3.GetX(), button3.GetY()));
            //
            //			newAnimaitonsbutton3.Add (new AnimationKeyFrame () {
            //				Time = TimeForPage (1),
            //				Frame = temp4
            //			});
            //
            //			var temp5 = new RectangleF (button3.GetX(), button3.GetY(), button3.Width, button3.Height);
            //			temp5.Offset (new PointF (button3.GetX(),button3.GetY()));
            //
            //			newAnimaitonsbutton3.Add (new AnimationKeyFrame () {
            //				Time = TimeForPage (2),
            //				Frame = temp5
            //			});
            //
            //			var temp6 = new RectangleF (button3.GetX(), button3.GetY(), button3.Width, button3.Height);
            //			temp6.Offset (new PointF (button3.GetX(), button3.GetY()));
            //
            //			newAnimaitonsbutton3.Add (new AnimationKeyFrame () {
            //				Time = TimeForPage (3),
            //				Frame = temp6
            //			});

            var temp7 = new RectangleF(button3.GetX(), button3.GetY(), button3.Width, button3.Height);

            temp7.Offset(new PointF(button3.GetX(), button3.GetY() - 200));

            newAnimaitonsbutton3.Add(new AnimationFrame()
            {
                Time  = TimeForPage(4),
                Frame = temp7
            });


            button3FrameAnimation.AddKeyFrames(newAnimaitonsbutton3);

            Console.WriteLine("Setup Frame Anim End");

            //ToDo: Hide Animation

            HideAnimation button3HideAnimation = new HideAnimation(button3);

            scrollView.Animator.AddAnimation(button3HideAnimation);

            button3HideAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time       = TimeForPage(2),
                Visibility = ViewStates.Invisible
            });

            //ToDo: Angle Animation

            AngleAnimation button2AngleAnimation = new AngleAnimation(button3);

            scrollView.Animator.AddAnimation(button2AngleAnimation);

            button2AngleAnimation.AddKeyFrames(
                new List <AnimationFrameBase>()
            {
                new AnimationFrame()
                {
                    Time  = TimeForPage(2),
                    Angle = 0.0f
                },
                new AnimationFrame()
                {
                    Time  = TimeForPage(3),
                    Angle = Convert.ToSingle(2 * Math.PI)
                },
                new AnimationFrame()
                {
                    Time  = TimeForPage(4),
                    Angle = 60.0f
                }
            });

            //ToDo : Color Animation

            ColorAnimation button3ColorAnimation = new ColorAnimation(button3);

            scrollView.Animator.AddAnimation(button3ColorAnimation);

            button3ColorAnimation.AddKeyFrames(
                new List <AnimationFrameBase>()
            {
                new AnimationFrame()
                {
                    Time  = TimeForPage(2),
                    Color = Android.Graphics.Color.Green
                },
                new AnimationFrame()
                {
                    Time  = TimeForPage(3),
                    Color = Android.Graphics.Color.Blue
                }
            });
        }
 public void Hide()
 {
     HideAnimation.Begin();
     IsHidden = true;
 }
Exemplo n.º 10
0
 private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
 {
     HideAnimation.Begin();
     Refresh();
 }