public void notify(Notification notification) { filterNotification(notification); var notificationViewModel = new NotificationViewModel(notification); var notificationWindow = new NotificationWindow(notificationViewModel); var screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; var screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight; var nHeight = notificationWindow.Height; var nWidth = notificationWindow.Width; var notificationSpot = -1; for (int i = 0; i < _maxNumNotifications; ++i) { if (_availableNotificationSpots[i]) { notificationSpot = i; break; } } if(notificationSpot == -1) { for (int i = 0; i < _maxNumNotifications; ++i) { _availableNotificationSpots[i] = true; } notificationSpot = 0; } notificationWindow.Left = screenWidth - nWidth - _rightOffset; notificationWindow.Top = _topOffset + notificationSpot * 90; notificationWindow.Opacity = 0; notificationWindow.Show(); _availableNotificationSpots[notificationSpot] = false; var showAnimation = new DoubleAnimation(0, 1, (Duration)_fadeInDuration); showAnimation.Completed += (s1, e1) => { var waitAnimation = new DoubleAnimation(1, _displayDuration); waitAnimation.Completed += (s2, e2) => { var hideAnimation = new DoubleAnimation(0, (Duration)_fadeOutDuration); hideAnimation.Completed += (s3, e3) => { notificationWindow.Hide(); notificationWindow.Close(); _availableNotificationSpots[notificationSpot] = true; }; notificationWindow.BeginAnimation(UIElement.OpacityProperty, hideAnimation); }; notificationWindow.BeginAnimation(UIElement.OpacityProperty, waitAnimation); }; notificationWindow.BeginAnimation(UIElement.OpacityProperty, showAnimation); }
public NotificationWindow(NotificationViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }