public void Show(string title, string message, NotificationType type, string areaName = "", TimeSpan?expirationTime = null, Action onClick = null, Action onClose = null) { var content = new NotificationContent { Type = type }; if (message != null) { content.Message = message; } if (title != null) { content.Title = title; } if (!_dispatcher.CheckAccess()) { _dispatcher.BeginInvoke( new Action(() => Show(title, message, type, areaName, expirationTime, onClick, onClose))); return; } expirationTime ??= TimeSpan.FromSeconds(5); if (areaName == string.Empty && _window == null) { var workArea = SystemParameters.WorkArea; _window = new NotificationsOverlayWindow { Left = workArea.Left, Top = workArea.Top, Width = workArea.Width, Height = workArea.Height }; _window.Show(); } if (Areas != null && _window != null && !_window.IsVisible) { _window.Show(); } if (Areas == null) { return; } foreach (var area in Areas.Where(a => a.Name == areaName)) { area.Show(content, (TimeSpan)expirationTime, onClick, onClose); } }
public void Show(string title, string message, string areaName = "", TimeSpan?expirationTime = null, RoutedEventHandler LeftButton = null, string LeftButtonText = null, RoutedEventHandler RightButton = null, string RightButtonText = null) { var content = new NotificationViewModel(); if (message != null) { content.Message = message; } if (title != null) { content.Title = title; } if (LeftButton != null) { content.LeftButtonContent = LeftButtonText ?? "Ok"; content.LeftButtonVisibility = true; } if (RightButton != null) { content.RightButtonContent = RightButtonText ?? "Cancel"; content.RightButtonVisibility = true; } if (!_dispatcher.CheckAccess()) { _dispatcher.BeginInvoke( new Action(() => Show(title, message, areaName, expirationTime, LeftButton, LeftButtonText, RightButton, RightButtonText))); return; } expirationTime ??= TimeSpan.FromSeconds(5); if (areaName == string.Empty && _window == null) { var workArea = SystemParameters.WorkArea; _window = new NotificationsOverlayWindow { Left = workArea.Left, Top = workArea.Top, Width = workArea.Width, Height = workArea.Height }; _window.Show(); } if (Areas != null && _window != null && !_window.IsVisible) { _window.Show(); } if (Areas == null) { return; } foreach (var area in Areas.Where(a => a.Name == areaName)) { area.Show(content, (TimeSpan)expirationTime, LeftButton, RightButton); } }