public void UpdateNotificationCount() { SerializableDictionary <string, GenericNotificationItem> notificationItems = GenericNotificationManager.GetNotificationItems((Predicate <GenericNotificationItem>)(x => !x.IsDeleted && !x.IsRead && string.Equals(x.VmName, this.ParentWindow.mVmName, StringComparison.InvariantCulture))); if (notificationItems.Count > 0 && !this.ParentWindow.mTopBar.mNotificationCentrePopup.IsOpen) { Border border1 = new Border(); border1.VerticalAlignment = VerticalAlignment.Center; border1.Height = 14.0; border1.MaxWidth = 24.0; Border border2 = border1; TextBlock textBlock1 = new TextBlock(); textBlock1.Text = notificationItems.Count.ToString((IFormatProvider)CultureInfo.InvariantCulture); textBlock1.FontSize = 10.0; textBlock1.MaxWidth = 24.0; textBlock1.FontWeight = FontWeights.Bold; textBlock1.VerticalAlignment = VerticalAlignment.Center; textBlock1.HorizontalAlignment = HorizontalAlignment.Center; textBlock1.Padding = new Thickness(3.0, 0.0, 3.0, 1.0); TextBlock textBlock2 = textBlock1; if (notificationItems.Count > 99) { textBlock2.Text = "99+"; } BlueStacksUIBinding.BindColor((DependencyObject)textBlock2, Control.ForegroundProperty, "SettingsWindowTitleBarForeGround"); BlueStacksUIBinding.BindColor((DependencyObject)border2, Control.BackgroundProperty, "XPackPopupColor"); border2.CornerRadius = new CornerRadius(7.0); border2.Child = (UIElement)textBlock2; Canvas.SetLeft((UIElement)border2, 20.0); Canvas.SetTop((UIElement)border2, 9.0); if (this.ParentWindow.mTopBar.mNotificationCountBadge == null) { return; } if (GenericNotificationManager.GetNotificationItems((Predicate <GenericNotificationItem>)(x => !x.IsRead && !x.IsDeleted && x.Priority == NotificationPriority.Important)).Count > 0) { this.ParentWindow.mTopBar.mNotificationCountBadge.Visibility = Visibility.Collapsed; } else { this.ParentWindow.mTopBar.mNotificationCountBadge.Visibility = Visibility.Visible; } this.ParentWindow.mTopBar.mNotificationCountBadge.Children.Clear(); this.ParentWindow.mTopBar.mNotificationCountBadge.Children.Add((UIElement)border2); } else { this.ParentWindow.mTopBar.mNotificationCountBadge.Visibility = Visibility.Collapsed; } }
internal GenericNotificationItem GetNotificationItem(string id) { return GenericNotificationManager.GetNotificationItems((Predicate<GenericNotificationItem>) (_ => _.Id == id)).FirstOrDefault<KeyValuePair<string, GenericNotificationItem>>().Value; }