添加消息通知功能,使用Handy Control的Grow来实现的

This commit is contained in:
2025-06-14 19:34:12 +08:00
parent 1fbf8b8fa6
commit 5dfce624c4
10 changed files with 195 additions and 81 deletions

View File

@@ -0,0 +1,77 @@
using HandyControl.Controls;
using PMSWPF.Enums;
using Notification = PMSWPF.Models.Notification;
namespace PMSWPF.Services;
public class GrowlNotificationService : INotificationService
{
public void Show(Notification notification)
{
if (notification == null )
{
return;
}
if (notification.IsGlobal)
{
switch (notification.Type)
{
case NotificationType.Info:
Growl.InfoGlobal(notification.Message);
break;
case NotificationType.Error:
Growl.ErrorGlobal(notification.Message);
break;
case NotificationType.Warning:
Growl.WarningGlobal(notification.Message);
break;
case NotificationType.Success:
Growl.SuccessGlobal(notification.Message);
break;
case NotificationType.Fatal:
Growl.FatalGlobal(notification.Message);
break;
case NotificationType.Clear:
Growl.ClearGlobal();
break;
default:
Growl.InfoGlobal(notification.Message);
break;
}
}
else
{
switch (notification.Type)
{
case NotificationType.Info:
Growl.Info(notification.Message);
break;
case NotificationType.Error:
Growl.Error(notification.Message);
break;
case NotificationType.Warning:
Growl.Warning(notification.Message);
break;
case NotificationType.Success:
Growl.Success(notification.Message);
break;
case NotificationType.Fatal:
Growl.Fatal(notification.Message);
break;
case NotificationType.Clear:
Growl.Clear();
break;
default:
Growl.Info(notification.Message);
break;
}
}
}
public void Show(string message, NotificationType type=NotificationType.Info,bool IsGlobal=true)
{
Show(new Notification(){Message = message,Type = type,IsGlobal = IsGlobal});
}
}

View File

@@ -0,0 +1,10 @@
using PMSWPF.Enums;
using PMSWPF.Models;
namespace PMSWPF.Services;
public interface INotificationService
{
void Show(Notification notification);
void Show(string message, NotificationType type, bool IsGlobal);
}