using System; using System.Collections.Generic; using System.Text; using System.Properties; using System.Windows; using static System.Application.Services.INotificationService; namespace System.Application.Services.Implementation { /// internal sealed class NotificationServiceImpl : INotificationService { readonly NotifyIcon notifyIcon; public NotificationServiceImpl(NotifyIcon notifyIcon) { this.notifyIcon = notifyIcon; } bool INotificationService.AreNotificationsEnabled() => true; void INotificationService.Cancel(NotificationType notificationType) { if (OperatingSystem2.IsWindows && NotifyIconHelper.IsInitialized) { notifyIcon.HideBalloonTip(); } } void INotificationService.CancelAll() { if (OperatingSystem2.IsWindows && NotifyIconHelper.IsInitialized) { notifyIcon.HideBalloonTip(); } } void INotificationService.Notify(string text, NotificationType notificationType, bool autoCancel, string? title, Entrance entrance) { if (OperatingSystem2.IsWindows && NotifyIconHelper.IsInitialized) { title ??= ThisAssembly.AssemblyTrademark; // 调用托盘显示通知 notifyIcon.ShowBalloonTip(title, text, ToolTipIcon.None); } } Progress INotificationService.NotifyDownload(Func text, NotificationType notificationType, string? title) { // 桌面端不支持带进度的通知,下载新版本改用桌面端的窗口进度条控件,由更新服务桌面端版实现 throw new PlatformNotSupportedException(); } } }