Exemplo n.º 1
0
        public void TimeoutNotification(GrowlNotification notification)
        {
            if (!Notifications.Contains(notification))
                return;

            BeginTimeoutAnimation(notification);
        }
Exemplo n.º 2
0
 protected void StartNotificationTimeout(GrowlNotification notification, TimeSpan duration)
 {
     // Don't look! This code is ugly!
     _timeouts.AddTimeout(
         duration,
         delegate { Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <GrowlNotification>(TimeoutNotification), notification); },
         notification);
 }
Exemplo n.º 3
0
 protected virtual void CloseNotification(GrowlNotification notification)
 {
     if (notification == null)
         throw new ArgumentNullException("notification");
     notification.Status = GrowlNotificationStatus.Closing;
     CancelNotificationTimeout(notification);
     OnNotificationClosed(notification);
 }
Exemplo n.º 4
0
 public void RemoveNotification(GrowlNotification notification)
 {
     Notifications.Remove(notification);
     if (Notifications.Count == 0)
     {
         IsOpen = false;
     }
 }
Exemplo n.º 5
0
 public void CloseNotification(GrowlNotification notification)
 {
     if (!Notifications.Contains(notification))
     {
         return;
     }
     BeginCloseAnimation(notification);
 }
Exemplo n.º 6
0
        public void TimeoutNotification(GrowlNotification notification)
        {
            if (!Notifications.Contains(notification))
            {
                return;
            }

            BeginTimeoutAnimation(notification);
        }
 protected override void OpenNotification(GrowlNotification notification)
 {
     if (notification == null)
         throw new ArgumentNullException("notification");
     EnsurePopup();
     notification.Status = GrowlNotificationStatus.Opening;
     if (notification.TimeoutDuration != TimeSpan.Zero)
         StartNotificationTimeout(notification, notification.TimeoutDuration);
     NotificationsPopup.OpenNotification(notification);
 }
Exemplo n.º 8
0
 protected virtual void TimeoutNotification(GrowlNotification notification)
 {
     if (notification == null)
     {
         throw new ArgumentNullException("notification");
     }
     notification.Status = GrowlNotificationStatus.Timingout;
     CancelNotificationTimeout(notification);
     OnNotificationTimedout(notification);
 }
Exemplo n.º 9
0
 protected virtual void CloseNotification(GrowlNotification notification)
 {
     if (notification == null)
     {
         throw new ArgumentNullException("notification");
     }
     notification.Status = GrowlNotificationStatus.Closing;
     CancelNotificationTimeout(notification);
     OnNotificationClosed(notification);
 }
 protected override void CloseNotification(GrowlNotification notification)
 {
     if (notification == null)
         throw new ArgumentNullException("notification");
     if (NotificationsPopup == null)
         return;
     CancelNotificationTimeout(notification);
     notification.Status = GrowlNotificationStatus.Closing;
     NotificationsPopup.CloseNotification(notification);
 }
Exemplo n.º 11
0
 protected virtual void OpenNotification(GrowlNotification notification)
 {
     if (notification == null)
     {
         throw new ArgumentNullException("notification");
     }
     notification.Status = GrowlNotificationStatus.Opening;
     if (notification.TimeoutDuration != TimeSpan.Zero)
     {
         StartNotificationTimeout(notification, notification.TimeoutDuration);
     }
     OnNotificationOpened(notification);
 }
 protected override void OpenNotification(GrowlNotification notification)
 {
     if (notification == null)
     {
         throw new ArgumentNullException("notification");
     }
     EnsurePopup();
     notification.Status = GrowlNotificationStatus.Opening;
     if (notification.TimeoutDuration != TimeSpan.Zero)
     {
         StartNotificationTimeout(notification, notification.TimeoutDuration);
     }
     NotificationsPopup.OpenNotification(notification);
 }
 protected override void TimeoutNotification(GrowlNotification notification)
 {
     if (notification == null)
     {
         throw new ArgumentNullException("notification");
     }
     if (NotificationsPopup == null)
     {
         return;
     }
     CancelNotificationTimeout(notification);
     notification.Status = GrowlNotificationStatus.Timingout;
     NotificationsPopup.TimeoutNotification(notification);
 }
Exemplo n.º 14
0
 public override void CloseLastNotification()
 {
     if (Application.Current == null)
     {
         return;
     }
     Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
     {
         GrowlNotification lastNotification = GetLastNotification();
         if (lastNotification != null)
         {
             CloseNotification(lastNotification);
         }
     }));
 }
Exemplo n.º 15
0
 protected virtual void BeginClickAnimation(GrowlNotification notification)
 {
     EndClickAnimation(notification);
 }
Exemplo n.º 16
0
 protected virtual void EndTimeoutAnimation(GrowlNotification notification)
 {
     RemoveNotification(notification);
     OnNotificationTimedout(new GrowlNotificationEventArgs(notification));
 }
Exemplo n.º 17
0
 protected virtual void BeginTimeoutAnimation(GrowlNotification notification)
 {
     EndTimeoutAnimation(notification);
 }
Exemplo n.º 18
0
 public void OpenNotification(GrowlNotification notification)
 {
     Notifications.Add(notification);
     IsOpen = true;
     BeginOpenAnimation(notification);
 }
Exemplo n.º 19
0
 public void OpenNotification(GrowlNotification notification)
 {
     Notifications.Add(notification);
     IsOpen = true;
     BeginOpenAnimation(notification);
 }
Exemplo n.º 20
0
 protected virtual void OpenNotification(GrowlNotification notification)
 {
     if (notification == null)
         throw new ArgumentNullException("notification");
     notification.Status = GrowlNotificationStatus.Opening;
     if (notification.TimeoutDuration != TimeSpan.Zero)
         StartNotificationTimeout(notification, notification.TimeoutDuration);
     OnNotificationOpened(notification);
 }
Exemplo n.º 21
0
 protected virtual void TimeoutNotification(GrowlNotification notification)
 {
     if (notification == null)
         throw new ArgumentNullException("notification");
     notification.Status = GrowlNotificationStatus.Timingout;
     CancelNotificationTimeout(notification);
     OnNotificationTimedout(notification);
 }
Exemplo n.º 22
0
 protected virtual void OnNotificationOpened(GrowlNotification notification)
 {
     notification.Status = GrowlNotificationStatus.Opened;
 }
Exemplo n.º 23
0
 protected virtual void OnNotificationTimedout(GrowlNotification notification)
 {
     notification.Status = GrowlNotificationStatus.Timedout;
     OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.TIMEDOUT));
 }
Exemplo n.º 24
0
 protected virtual void BeginOpenAnimation(GrowlNotification notification)
 {
     EndOpenAnimation(notification);
 }
Exemplo n.º 25
0
 protected virtual void BeginCloseAnimation(GrowlNotification notification)
 {
     EndCloseAnimation(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);
         }
     }
 }
Exemplo n.º 27
0
 protected void CancelNotificationTimeout(GrowlNotification notification)
 {
     _timeouts.RemoveTimeout(notification);
 }
        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);
            }
        }
Exemplo n.º 29
0
 protected virtual void BeginOpenAnimation(GrowlNotification notification)
 {
     EndOpenAnimation(notification);
 }
Exemplo n.º 30
0
 protected virtual void OnNotificationClosed(GrowlNotification notification)
 {
     notification.Status = GrowlNotificationStatus.Closed;
     OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.CLOSE));
 }
 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);
 }
 public GrowlNotificationEventArgs(GrowlNotification notification)
 {
     _notification = notification;
 }
Exemplo n.º 33
0
 protected void StartNotificationTimeout(GrowlNotification notification, TimeSpan duration)
 {
     // Don't look! This code is ugly!
     _timeouts.AddTimeout(
         duration,
         delegate { Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action<GrowlNotification>(TimeoutNotification), notification); },
         notification);
 }
Exemplo n.º 34
0
 public void RemoveNotification(GrowlNotification notification)
 {
     Notifications.Remove(notification);
     if (Notifications.Count == 0)
         IsOpen = false;
 }
Exemplo n.º 35
0
 protected void CancelNotificationTimeout(GrowlNotification notification)
 {
     _timeouts.RemoveTimeout(notification);
 }
Exemplo n.º 36
0
 protected virtual void EndCloseAnimation(GrowlNotification notification)
 {
     RemoveNotification(notification);
     OnNotificationClosed(new GrowlNotificationEventArgs(notification));
 }
Exemplo n.º 37
0
        protected virtual GrowlNotification CreateGrowlNotification(Notification notification)
        {
            var growlNotification = new GrowlNotification
                                        {
                                            OriginalNotification = notification,
                                            Title = notification.Title,
                                            Description = notification.Description,
                                            IsSticky = notification.Sticky,
                                            TimeoutDuration = notification.Sticky
                                                                  ? TimeSpan.Zero
                                                                  : notification.Duration == 0
                                                                        ? (TimeSpan)GrowlNotification.TimeoutDurationProperty.DefaultMetadata.DefaultValue
                                                                        : TimeSpan.FromSeconds(notification.Duration)
                                        };

            // Fill the custom attributes.
            if (notification.CustomTextAttributes != null)
            {
                foreach (KeyValuePair<string, string> pair in notification.CustomTextAttributes)
                    growlNotification.CustomTextAttributes.Add(pair);
            }

            // Creating image-source from the supplied url or binary data.
            BitmapImage image = null;
            Uri imageUri;
            if (notification.Image.IsUrl && Uri.TryCreate(notification.Image.Url, UriKind.Absolute, out imageUri))
            {
                image = new BitmapImage();
                image.BeginInit();
                image.UriSource = new Uri(notification.Image.Url);
                image.CacheOption = BitmapCacheOption.OnLoad;
                try
                {
                    image.EndInit();
                }
                    // This is very hacky, but the MSDN documentation does not state all of the possible exceptions.
                catch
                {
                    image = null;
                }
            }
            else if (notification.Image.IsRawData)
            {
                using (var stream = new MemoryStream(notification.Image.Data, 0, notification.Image.Data.Length))
                {
                    image = new BitmapImage();
                    image.BeginInit();
                    image.CacheOption = BitmapCacheOption.OnLoad;
                    image.CreateOptions = BitmapCreateOptions.None;
                    image.StreamSource = stream;
                    try
                    {
                        image.EndInit();
                    }
                        // Again very hacky. Again for the same reason.
                    catch
                    {
                        image = null;
                    }
                }
            }
            growlNotification.Image = image;

            return growlNotification;
        }
 protected override void OpenNotification(GrowlNotification notification)
 {
     var settings = new TranslucentDarkSettings(SettingsCollection);
     if (settings.PauseOnFullscreen && FullscreenDetector.IsFullscreen())
     {
         QueueNotification(notification);
     }
     else
     {
         base.OpenNotification(notification);
     }
 }
Exemplo n.º 39
0
 public void CloseNotification(GrowlNotification notification)
 {
     if (!Notifications.Contains(notification))
         return;
     BeginCloseAnimation(notification);
 }
 public GrowlNotificationEventArgs(GrowlNotification notification)
 {
     _notification = notification;
 }
Exemplo n.º 41
0
 protected virtual void EndOpenAnimation(GrowlNotification notification)
 {
     OnNotificationOpened(new GrowlNotificationEventArgs(notification));
 }
Exemplo n.º 42
0
 protected virtual void OnNotificationClosed(GrowlNotification notification)
 {
     notification.Status = GrowlNotificationStatus.Closed;
     OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.CLOSE));
 }
Exemplo n.º 43
0
 protected virtual void EndTimeoutAnimation(GrowlNotification notification)
 {
     RemoveNotification(notification);
     OnNotificationTimedout(new GrowlNotificationEventArgs(notification));
 }
Exemplo n.º 44
0
 protected virtual void OnNotificationOpened(GrowlNotification notification)
 {
     notification.Status = GrowlNotificationStatus.Opened;
 }
Exemplo n.º 45
0
 protected virtual void EndClickAnimation(GrowlNotification notification)
 {
     RemoveNotification(notification);
     OnNotificationClicked(new GrowlNotificationEventArgs(notification));
 }
Exemplo n.º 46
0
 protected virtual void OnNotificationTimedout(GrowlNotification notification)
 {
     notification.Status = GrowlNotificationStatus.Timedout;
     OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.TIMEDOUT));
 }
Exemplo n.º 47
0
 protected virtual void EndOpenAnimation(GrowlNotification notification)
 {
     OnNotificationOpened(new GrowlNotificationEventArgs(notification));
 }
 protected virtual bool CanCloseNotification(GrowlNotification notification)
 {
     return notification.Status != GrowlNotificationStatus.Closing ||
            notification.Status != GrowlNotificationStatus.Closed;
 }
 protected virtual bool CanCloseNotification(GrowlNotification notification)
 {
     return(notification.Status != GrowlNotificationStatus.Closing ||
            notification.Status != GrowlNotificationStatus.Closed);
 }
Exemplo n.º 50
0
        protected virtual GrowlNotification CreateGrowlNotification(Notification notification)
        {
            var growlNotification = new GrowlNotification
            {
                OriginalNotification = notification,
                Title           = notification.Title,
                Description     = notification.Description,
                IsSticky        = notification.Sticky,
                TimeoutDuration = notification.Sticky
                                                                  ? TimeSpan.Zero
                                                                  : notification.Duration == 0
                                                                        ? (TimeSpan)GrowlNotification.TimeoutDurationProperty.DefaultMetadata.DefaultValue
                                                                        : TimeSpan.FromSeconds(notification.Duration)
            };

            // Fill the custom attributes.
            if (notification.CustomTextAttributes != null)
            {
                foreach (KeyValuePair <string, string> pair in notification.CustomTextAttributes)
                {
                    growlNotification.CustomTextAttributes.Add(pair);
                }
            }

            // Creating image-source from the supplied url or binary data.
            BitmapImage image = null;
            Uri         imageUri;

            if (notification.Image.IsUrl && Uri.TryCreate(notification.Image.Url, UriKind.Absolute, out imageUri))
            {
                image = new BitmapImage();
                image.BeginInit();
                image.UriSource   = new Uri(notification.Image.Url);
                image.CacheOption = BitmapCacheOption.OnLoad;
                try
                {
                    image.EndInit();
                }
                // This is very hacky, but the MSDN documentation does not state all of the possible exceptions.
                catch
                {
                    image = null;
                }
            }
            else if (notification.Image.IsRawData)
            {
                using (var stream = new MemoryStream(notification.Image.Data, 0, notification.Image.Data.Length))
                {
                    image = new BitmapImage();
                    image.BeginInit();
                    image.CacheOption   = BitmapCacheOption.OnLoad;
                    image.CreateOptions = BitmapCreateOptions.None;
                    image.StreamSource  = stream;
                    try
                    {
                        image.EndInit();
                    }
                    // Again very hacky. Again for the same reason.
                    catch
                    {
                        image = null;
                    }
                }
            }
            growlNotification.Image = image;

            return(growlNotification);
        }
 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));
     }
 }
Exemplo n.º 52
0
 protected virtual void BeginTimeoutAnimation(GrowlNotification notification)
 {
     EndTimeoutAnimation(notification);
 }