From fd48caaf673a936519703cc2dfb9c9135ea7c18d Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 10 May 2019 17:50:01 +0100 Subject: [PATCH] fix notification event handlers naming. --- .../WindowNotificationManager.cs | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs index bf7a111025..93cb3b96b5 100644 --- a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs +++ b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs @@ -106,28 +106,29 @@ namespace Avalonia.Controls.Notifications if (notification != null) { - notificationControl.NotificationClosed += (sender, args) => notification.OnClose?.Invoke(); - } + notificationControl.NotificationClosed += (sender, args) => + { + notification.OnClose?.Invoke(); - notificationControl.NotificationClosed += OnNotificationClosed; + _items.Remove(notification); + }; + } notificationControl.PointerPressed += (sender, args) => { if (notification != null && notification.OnClick != null) { notification.OnClick.Invoke(); - (sender as NotificationCard)?.Close(); } + + (sender as NotificationCard)?.Close(); }; - lock (_items) - { - _items.Add(notificationControl); + _items.Add(notificationControl); - if (_items.OfType().Count(i => !i.IsClosing) > MaxItems) - { - _items.OfType().First(i => !i.IsClosing).Close(); - } + if (_items.OfType().Count(i => !i.IsClosing) > MaxItems) + { + _items.OfType().First(i => !i.IsClosing).Close(); } if (notification != null && notification.Expiration == TimeSpan.MaxValue) @@ -140,12 +141,6 @@ namespace Avalonia.Controls.Notifications notificationControl.Close(); } - private void OnNotificationClosed(object sender, RoutedEventArgs routedEventArgs) - { - var notification = sender as NotificationCard; - _items.Remove(notification); - } - private void Install(Window host) { var adornerLayer = host.GetVisualDescendants()