Example #1
0
        public void AddNotice(string message, string title, double?durationSeconds, MessageBoxIcon messageBoxIcon)
        {
            var noticeCard = new NoticeCard(durationSeconds)
            {
                Message        = message,
                Title          = title,
                Background     = Brushes.White,
                MessageBoxIcon = messageBoxIcon,
            };

            Canvas.SetTop(noticeCard, Height - (cvaMain.Children.Count + 1) * 155);
            Canvas.SetLeft(noticeCard, 400);

            noticeCard.Timeup += NoticeCard_Timeup;

            cvaMain.Children.Add(noticeCard);

            BeginAnimation(noticeCard, true);
        }
Example #2
0
        private void BeginAnimation(NoticeCard noticeCard, bool toShow, Action callback = null)
        {
            if (toShow)
            {
                var animaLeft = new DoubleAnimation()
                {
                    To             = 0,
                    EasingFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    },
                    Duration = TimeSpan.FromSeconds(0.4),
                };
                animaLeft.Completed += delegate
                {
                    callback?.Invoke();
                };

                noticeCard.BeginAnimation(Canvas.LeftProperty, animaLeft);
            }
            else
            {
                var anima = new DoubleAnimation()
                {
                    To             = 0,
                    EasingFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    },
                    Duration = TimeSpan.FromSeconds(0.4),
                };
                anima.Completed += delegate
                {
                    callback?.Invoke();
                };
                noticeCard.BeginAnimation(OpacityProperty, anima);
            }
        }