public void ForceShowAlert( string imagePath, string title, string displayMsg, bool autoClose, int duration, MouseButtonEventHandler clickHandler, bool hideMute, string vmName, MouseButtonEventHandler buttonClickHandler = null, MouseButtonEventHandler closeButtonHandler = null, MouseButtonEventHandler muteButtonHandler = null, bool showOnlyMute = false, string buttonText = "", string id = "0", bool showOnlySettings = false) { this.Dispatcher.Invoke((Delegate)(() => { NotificationPopup notificationPopup = NotificationPopup.InitPopup(imagePath, title, displayMsg, autoClose, duration, clickHandler, hideMute, vmName, buttonClickHandler, closeButtonHandler, muteButtonHandler, showOnlyMute, buttonText, id, showOnlySettings, ""); this.mStackPanel.Children.Insert(0, (UIElement)notificationPopup); if (!this.mDictPopups.ContainsKey(title.ToUpper(CultureInfo.InvariantCulture))) { this.mDictPopups.Add(title.ToUpper(CultureInfo.InvariantCulture), notificationPopup); } this.Topmost = false; })); }
public void AddAlert( string imagePath, string title, string displayMsg, bool autoClose, int duration, MouseButtonEventHandler clickHandler, bool hideMute, string vmName, bool isCloudNotification, string package = "", bool isForceNotification = false, string id = "0", bool showOnlySettings = false) { if (!this.mIsPopupsEnabled) { return; } this.Dispatcher.Invoke((Delegate)(() => { MuteState muteState = NotificationManager.Instance.IsShowNotificationForKey(title, vmName); if (((muteState == MuteState.NotMuted ? 1 : (muteState == MuteState.AutoHide ? 1 : 0)) | (isForceNotification ? 1 : 0)) == 0 && !NotificationManager.Instance.IsDesktopNotificationToBeShown(title)) { return; } if (this.Visibility == Visibility.Collapsed || this.Visibility == Visibility.Hidden) { this.Show(); } string upper = (string.IsNullOrEmpty(package) ? title : package).ToUpper(CultureInfo.InvariantCulture); if (this.mDictPopups.ContainsKey(upper)) { this.RemovePopup(this.mDictPopups[upper]); } if (this.mDictPopups.Count >= 3) { this.RemovePopup((NotificationPopup)this.mStackPanel.Children[2]); } if (!isCloudNotification & isForceNotification) { autoClose = true; duration = 5000; } NotificationPopup notificationPopup = NotificationPopup.InitPopup(imagePath, title, displayMsg, autoClose, duration, clickHandler, hideMute, vmName, (MouseButtonEventHandler)null, (MouseButtonEventHandler)null, (MouseButtonEventHandler)null, false, string.Empty, id, showOnlySettings, package); this.mStackPanel.Children.Insert(0, (UIElement)notificationPopup); this.mDictPopups.Add(upper, notificationPopup); })); }