public void TimeoutNotification(GrowlNotification notification) { if (!Notifications.Contains(notification)) return; BeginTimeoutAnimation(notification); }
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); }
protected virtual void CloseNotification(GrowlNotification notification) { if (notification == null) throw new ArgumentNullException("notification"); notification.Status = GrowlNotificationStatus.Closing; CancelNotificationTimeout(notification); OnNotificationClosed(notification); }
public void RemoveNotification(GrowlNotification notification) { Notifications.Remove(notification); if (Notifications.Count == 0) { IsOpen = false; } }
public void CloseNotification(GrowlNotification notification) { if (!Notifications.Contains(notification)) { return; } BeginCloseAnimation(notification); }
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); }
protected virtual void TimeoutNotification(GrowlNotification notification) { if (notification == null) { throw new ArgumentNullException("notification"); } notification.Status = GrowlNotificationStatus.Timingout; CancelNotificationTimeout(notification); OnNotificationTimedout(notification); }
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); }
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); }
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); } })); }
protected virtual void BeginClickAnimation(GrowlNotification notification) { EndClickAnimation(notification); }
protected virtual void EndTimeoutAnimation(GrowlNotification notification) { RemoveNotification(notification); OnNotificationTimedout(new GrowlNotificationEventArgs(notification)); }
protected virtual void BeginTimeoutAnimation(GrowlNotification notification) { EndTimeoutAnimation(notification); }
public void OpenNotification(GrowlNotification notification) { Notifications.Add(notification); IsOpen = true; BeginOpenAnimation(notification); }
public void OpenNotification(GrowlNotification notification) { Notifications.Add(notification); IsOpen = true; BeginOpenAnimation(notification); }
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 virtual void TimeoutNotification(GrowlNotification notification) { if (notification == null) throw new ArgumentNullException("notification"); notification.Status = GrowlNotificationStatus.Timingout; CancelNotificationTimeout(notification); OnNotificationTimedout(notification); }
protected virtual void OnNotificationOpened(GrowlNotification notification) { notification.Status = GrowlNotificationStatus.Opened; }
protected virtual void OnNotificationTimedout(GrowlNotification notification) { notification.Status = GrowlNotificationStatus.Timedout; OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.TIMEDOUT)); }
protected virtual void BeginOpenAnimation(GrowlNotification notification) { EndOpenAnimation(notification); }
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); } } }
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); } }
protected virtual void BeginOpenAnimation(GrowlNotification notification) { EndOpenAnimation(notification); }
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; }
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); }
public void RemoveNotification(GrowlNotification notification) { Notifications.Remove(notification); if (Notifications.Count == 0) IsOpen = false; }
protected void CancelNotificationTimeout(GrowlNotification notification) { _timeouts.RemoveTimeout(notification); }
protected virtual void EndCloseAnimation(GrowlNotification notification) { RemoveNotification(notification); OnNotificationClosed(new GrowlNotificationEventArgs(notification)); }
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); } }
public void CloseNotification(GrowlNotification notification) { if (!Notifications.Contains(notification)) return; BeginCloseAnimation(notification); }
public GrowlNotificationEventArgs(GrowlNotification notification) { _notification = notification; }
protected virtual void EndOpenAnimation(GrowlNotification notification) { OnNotificationOpened(new GrowlNotificationEventArgs(notification)); }
protected virtual void OnNotificationClosed(GrowlNotification notification) { notification.Status = GrowlNotificationStatus.Closed; OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.CLOSE)); }
protected virtual void EndTimeoutAnimation(GrowlNotification notification) { RemoveNotification(notification); OnNotificationTimedout(new GrowlNotificationEventArgs(notification)); }
protected virtual void OnNotificationOpened(GrowlNotification notification) { notification.Status = GrowlNotificationStatus.Opened; }
protected virtual void EndClickAnimation(GrowlNotification notification) { RemoveNotification(notification); OnNotificationClicked(new GrowlNotificationEventArgs(notification)); }
protected virtual void OnNotificationTimedout(GrowlNotification notification) { notification.Status = GrowlNotificationStatus.Timedout; OnNotificationClosed(new NotificationCallbackEventArgs(notification.OriginalNotification.UUID, CallbackResult.TIMEDOUT)); }
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); }
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)); } }
protected virtual void BeginTimeoutAnimation(GrowlNotification notification) { EndTimeoutAnimation(notification); }