Esempio n. 1
0
        public static Notification Show(object content, ShowAnimation showAnimation = ShowAnimation.None, bool staysOpen = false)
        {
            var notification = new Notification
            {
                Content       = content,
                Opacity       = 0,
                ShowAnimation = showAnimation
            };

            notification.Show();

            var desktopWorkingArea = SystemParameters.WorkArea;
            var leftMax            = desktopWorkingArea.Width - notification.ActualWidth;
            var topMax             = desktopWorkingArea.Height - notification.ActualHeight;

            switch (showAnimation)
            {
            case ShowAnimation.None:
                notification.Opacity = 1;
                notification.Left    = leftMax;
                notification.Top     = topMax;
                break;

            case ShowAnimation.HorizontalMove:
                notification.Opacity = 1;
                notification.Left    = desktopWorkingArea.Width;
                notification.Top     = topMax;
                notification.BeginAnimation(LeftProperty, AnimationHelper.CreateAnimation(leftMax));
                break;

            case ShowAnimation.verticalMove:
                notification.Opacity = 1;
                notification.Left    = leftMax;
                notification.Top     = desktopWorkingArea.Height;
                notification.BeginAnimation(TopProperty, AnimationHelper.CreateAnimation(topMax));
                break;

            case ShowAnimation.Fade:
                notification.Left = leftMax;
                notification.Top  = topMax;
                notification.BeginAnimation(OpacityProperty, AnimationHelper.CreateAnimation(1));
                break;

            default:
                notification.Opacity = 1;
                notification.Left    = leftMax;
                notification.Top     = topMax;
                break;
            }

            if (!staysOpen)
            {
                notification.StartTimer();
            }

            return(notification);
        }
Esempio n. 2
0
 public void Show()
 {
     if (FrameX == null)
     {
         return;
     }
     FrameX.Attach(this);
     PopupRoot.Open();
     ShowAnimation.Begin();
 }
Esempio n. 3
0
 private void Refresh()
 {
     if (CurrentSong?.Equals(TargetSong) ?? false)
     {
         ShowAnimation.Begin();
     }
     else
     {
         HideAnimation.Begin();
     }
 }
Esempio n. 4
0
        public static bool IsSlideAnimation(this ShowAnimation showAnimation)
        {
            switch (showAnimation)
            {
            case ShowAnimation.SlideIn_Bottom:
            case ShowAnimation.SlideIn_Top:
            case ShowAnimation.SlideIn_Left:
            case ShowAnimation.SlideIn_Right:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 5
0
        public async void Show()
        {
            Cover.CurrentUri  = ViewModel.ActiveSong?.CoverUri;
            Cover.PreviousUri = ViewModel.PreviousSong?.CoverUri;
            Cover.NextUri     = ViewModel.NextSong?.CoverUri;

            await SetupCircleCoverAsync();

            Window.Current.SetTitleBar(TitleBarHolder);
            App.SetTitleBarInDarkBackground();
            ShowAnimation.Begin();

            ConnectedAnimationService.GetForCurrentView().GetAnimation(ConnectedAnimationKeys.SpotlightTransition)?.TryStart(CircleCover);
        }
Esempio n. 6
0
        public static SlideDirection ToSlideDirection(this ShowAnimation showAnimation)
        {
            switch (showAnimation)
            {
            case ShowAnimation.SlideIn_Bottom: return(SlideDirection.Bottom);

            case ShowAnimation.SlideIn_Top: return(SlideDirection.Top);

            case ShowAnimation.SlideIn_Left: return(SlideDirection.Left);

            case ShowAnimation.SlideIn_Right: return(SlideDirection.Right);

            default: return(SlideDirection.Top);
            }
        }
Esempio n. 7
0
        protected IEnumerator PlayShowAnimation(ShowAnimation animation, Action onCompleteCallback = null)
        {
            // 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 (!xmlLayout.IsReady)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (ShowAnimationDelay > 0)
            {
                CanvasGroup.alpha = 0;
                yield return(new WaitForSeconds(ShowAnimationDelay));
            }

            CanvasGroup.alpha          = DefaultOpacity;
            CanvasGroup.blocksRaycasts = true;

            if (animation.IsSlideAnimation())
            {
                m_Animator.enabled = false;
                yield return(PlaySlideInAnimation(animation));
            }
            else
            {
                m_Animator.enabled = true;
                m_Animator.speed   = 0.25f / AnimationDuration;
                m_Animator.Play(animation.ToString());

                var delay = m_Animator.GetCurrentAnimatorStateInfo(0).length / m_Animator.speed;

                // If we disable the animator immediately after the animation is complete, things get a bit wonky
                XmlLayoutTimer.DelayedCall(delay, () => { m_Animator.enabled = false; }, this);

                yield return(new WaitForSeconds(delay * 0.25f));
            }

            _IsAnimating = false;

            StartCoroutine(WaitForShowAnimationToComplete(onCompleteCallback));
        }
Esempio n. 8
0
        protected IEnumerator PlaySlideInAnimation(ShowAnimation animation)
        {
            var distance = GetDistanceForSlideAnimation(animation.ToSlideDirection());

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

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

                yield return(MoveDistanceY(-distance.y, AnimationDuration));
            }
        }
Esempio n. 9
0
    /// <summary>
    /// 播放展示动画
    /// </summary>
    private void PlayShowAnimation()
    {
        ShowAnimation showAnimation = gameObject.GetComponentInChildren <ShowAnimation>();

        if (showAnimation == null)
        {
            showAnimation = gameObject.GetComponent <ShowAnimation>();
        }
        if (showAnimation != null)
        {
            showAnimation.Show(ShowAnimaitionFinish);
        }
        else
        {
            ShowAnimaitionFinish();
        }
    }
        public void Show(bool force = false)
        {
            if (force)
            {
                AlwaysHidden = false;
            }

            if (AlwaysHidden)
            {
                return;
            }
            if (Song == null)
            {
                return;
            }
            if (IsHidden == false)
            {
                return;
            }

            ShowAnimation.Begin();
            IsHidden = false;
        }