/// <summary> /// Shows the notification. /// </summary> /// <param name="title">The title.</param> /// <param name="message">The message.</param> /// <param name="notificationType">Type of the notification.</param> /// <param name="timeout">The timeout.</param> /// <param name="onClick">The on click.</param> public void ShowNotification(string title, string message, NotificationType notificationType, int timeout = 5, Action onClick = null) { var type = notificationType switch { NotificationType.Success => Avalonia.Controls.Notifications.NotificationType.Success, NotificationType.Warning => Avalonia.Controls.Notifications.NotificationType.Warning, NotificationType.Error => Avalonia.Controls.Notifications.NotificationType.Error, _ => Avalonia.Controls.Notifications.NotificationType.Information, }; var model = new Notification(title, message, type, TimeSpan.FromSeconds(timeout), onClick); notificationFactory.GetManager().Show(model); }
/// <summary> /// Shows the notification. /// </summary> /// <param name="title">The title.</param> /// <param name="message">The message.</param> /// <param name="notificationType">Type of the notification.</param> /// <param name="timeout">The timeout.</param> /// <param name="onClick">The on click.</param> public void ShowNotification(string title, string message, NotificationType notificationType, int timeout = 5, Action onClick = null) { var type = notificationType switch { NotificationType.Success => Avalonia.Controls.Notifications.NotificationType.Success, NotificationType.Warning => Avalonia.Controls.Notifications.NotificationType.Warning, NotificationType.Error => Avalonia.Controls.Notifications.NotificationType.Error, _ => Avalonia.Controls.Notifications.NotificationType.Information, }; if (Dispatcher.UIThread.CheckAccess()) { var model = new Notification(title, message, type, TimeSpan.FromSeconds(timeout), onClick); notificationFactory.GetManager().Show(model); } else { Dispatcher.UIThread.InvokeAsync(() => { var model = new Notification(title, message, type, TimeSpan.FromSeconds(timeout), onClick); notificationFactory.GetManager().Show(model); }); } }