using Avalonia.Controls.Notifications; using Avalonia.Threading; using Serilog; namespace DispenserCommon.Utils; public class ToastUtil { private static WindowNotificationManager? _manager; public static void SetManager(WindowNotificationManager manager) { _manager = manager; } public static void Info(string msg) { Log.Information(msg); Dispatcher.UIThread.Invoke(() => { _manager?.Show(new Notification("", msg)); }); } public static void Error(string msg) { Log.Error(msg); Dispatcher.UIThread.Invoke(() => { _manager?.Show(new Notification("", msg, NotificationType.Error)); }); } public static void Warn(string msg) { Log.Warning(msg); Dispatcher.UIThread.Invoke(() => { _manager?.Show(new Notification("", msg, NotificationType.Warning)); }); } public static void Success(string msg) { Log.Information(msg); Dispatcher.UIThread.Invoke(() => { _manager?.Show(new Notification("", msg, NotificationType.Success)); }); } }