2025-06-23 17:01:06 +08:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2025-06-23 13:42:02 +08:00
|
|
|
|
using CommunityToolkit.Mvvm.Messaging;
|
2025-07-18 22:21:16 +08:00
|
|
|
|
using DMS.Core.Enums;
|
2025-07-18 19:56:00 +08:00
|
|
|
|
using DMS.Message;
|
2025-06-23 13:42:02 +08:00
|
|
|
|
using HandyControl.Controls;
|
2025-06-14 19:34:12 +08:00
|
|
|
|
|
2025-07-28 13:06:36 +08:00
|
|
|
|
namespace DMS.WPF.Services;
|
2025-06-14 19:34:12 +08:00
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
public class GrowlNotificationService : ObservableRecipient, IRecipient<NotificationMessage>
|
2025-06-14 19:34:12 +08:00
|
|
|
|
{
|
2025-06-23 13:42:02 +08:00
|
|
|
|
public GrowlNotificationService()
|
|
|
|
|
|
{
|
|
|
|
|
|
IsActive = true;
|
|
|
|
|
|
}
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
|
|
public void Receive(NotificationMessage message)
|
|
|
|
|
|
{
|
2025-07-28 13:06:36 +08:00
|
|
|
|
Show(message.Value, message.Type, message.IsGlobal);
|
2025-06-23 13:42:02 +08:00
|
|
|
|
}
|
2025-07-28 13:06:36 +08:00
|
|
|
|
|
|
|
|
|
|
public void Show(string message, NotificationType type = NotificationType.Info, bool IsGlobal = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (IsGlobal)
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case NotificationType.Info:
|
|
|
|
|
|
Growl.InfoGlobal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Error:
|
|
|
|
|
|
Growl.ErrorGlobal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Warning:
|
|
|
|
|
|
Growl.WarningGlobal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Success:
|
|
|
|
|
|
Growl.SuccessGlobal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Fatal:
|
|
|
|
|
|
Growl.FatalGlobal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Clear:
|
|
|
|
|
|
Growl.ClearGlobal();
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
Growl.InfoGlobal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case NotificationType.Info:
|
|
|
|
|
|
Growl.Info(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Error:
|
|
|
|
|
|
Growl.Error(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Warning:
|
|
|
|
|
|
Growl.Warning(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Success:
|
|
|
|
|
|
Growl.Success(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Fatal:
|
|
|
|
|
|
Growl.Fatal(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NotificationType.Clear:
|
|
|
|
|
|
Growl.Clear();
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
Growl.Info(message);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-14 19:34:12 +08:00
|
|
|
|
}
|