protected override void BeginTimeoutAnimation(GrowlNotification notification)
        {
            if (DontCloseOnMouseOver && IsMouseOver)
            {
                _waitingNotifications.Enqueue(notification);
                return;
            }

            Duration timeoutDuration = new Duration(TimeSpan.FromSeconds(0.5));

            if (UseFadeAnimation && (from n in Notifications where n.Status <= GrowlNotificationStatus.Opened select n).Count() < 1)
            {
                var animation = new DoubleAnimation(0, timeoutDuration);
                animation.Completed += delegate { EndTimeoutAnimation(notification); };
                border.BeginAnimation(OpacityProperty, animation);
            }
            else
            {
                var notificationBorder         = GetNotificationElement(notification);
                var notificationTransformation = notificationBorder.RenderTransform;
                AnimationTimeline   animation;
                HorizontalAlignment horizontal = PopupDocker.GetDockHorizontal(this);
                if (horizontal == HorizontalAlignment.Left)
                {
                    animation = new DoubleAnimation(0.0, -notificationBorder.ActualWidth, timeoutDuration);
                }
                else
                {
                    animation = new DoubleAnimation(0.0, notificationBorder.ActualWidth, timeoutDuration);
                }
                animation.Completed += delegate { EndTimeoutAnimation(notification); };
                notificationTransformation.BeginAnimation(TranslateTransform.XProperty, animation);
            }
        }
        protected FrameworkElement GetNotificationElement(GrowlNotification notification)
        {
            // HACK: Update the layout to make sure the containers are generated.
            notificationsControl.UpdateLayout();
            var container = notificationsControl.ItemContainerGenerator.ContainerFromItem(notification) as ContentPresenter;

            return((FrameworkElement)container.ContentTemplate.FindName("border", container));
        }
Exemplo n.º 3
0
        public static T WithGrowlMessage <T>(this T response, string heading, string message, GrowlNotificationStyle style)
            where T : FormResponse <MyFormResponseMetadata>
        {
            response.Metadata = response.Metadata ?? new MyFormResponseMetadata();
            response.Metadata.FunctionsToRun = response.Metadata.FunctionsToRun ?? new List <ClientFunctionMetadata>();

            var growlFunction = new GrowlNotification(heading, message, style).GetClientFunctionMetadata();

            response.Metadata.FunctionsToRun.Add(growlFunction);

            return(response);
        }
 private void QueueNotification(GrowlNotification notification)
 {
     lock (PendingNotifications)
     {
         notification.Status = GrowlNotificationStatus.Pending;
         PendingNotifications.Add(notification);
         if (_pendingTimer == null)
         {
             _pendingTimer = new Timer(PendingTimerCallback, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));
         }
     }
 }
        protected override void OpenNotification(GrowlNotification notification)
        {
            var settings = new TranslucentDarkSettings(SettingsCollection);

            if (settings.PauseOnFullscreen && FullscreenDetector.IsFullscreen())
            {
                QueueNotification(notification);
            }
            else
            {
                base.OpenNotification(notification);
            }
        }
        protected override void BeginOpenAnimation(GrowlNotification notification)
        {
            var openDuration = new Duration(TimeSpan.FromSeconds(0.5));

            if (UseFadeAnimation && Notifications.Count <= 1)
            {
                var animation = new DoubleAnimation(0, 1, openDuration);
                animation.Completed += delegate { EndOpenAnimation(notification); };
                border.BeginAnimation(OpacityProperty, animation);
            }
            else
            {
                var container = GetNotificationElement(notification);
                VerticalAlignment vertical = PopupDocker.GetDockVertical(this);
                if (vertical == VerticalAlignment.Bottom ||
                    vertical == VerticalAlignment.Top)
                {
                    var animation = new DoubleAnimation((vertical == VerticalAlignment.Top ? -1.0 : 1.0) * container.DesiredSize.Height + borderTranslation.Y, 0, new Duration(TimeSpan.FromSeconds(0.5)));
                    animation.Completed += delegate { EndOpenAnimation(notification); };
                    borderTranslation.BeginAnimation(TranslateTransform.YProperty, animation);
                }
            }
        }