This commit is contained in:
Aigio Liu
2021-08-29 23:54:55 +08:00
parent ac529aa52a
commit 75a3844aa0
3 changed files with 26 additions and 18 deletions
@@ -28,17 +28,6 @@ namespace Microsoft.Extensions.DependencyInjection
return services;
}
/// <summary>
/// 添加适用于桌面端的 <see cref="INotificationService"/>
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddNotificationService(this IServiceCollection services)
{
services.AddSingleton<INotificationService, PlatformNotificationServiceImpl>();
return services;
}
public static IServiceCollection AddFontManager(this IServiceCollection services, bool useGdiPlusFirst)
{
services.AddSingleton<IFontManager>(new AvaloniaFontManagerImpl(useGdiPlusFirst));
@@ -85,7 +85,7 @@ namespace Microsoft.Extensions.DependencyInjection
}
/// <summary>
/// 添加 Window 窗口viewmodel
/// 添加窗口服务
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
@@ -94,5 +94,16 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddSingleton<IWindowService, WindowServiceImpl>();
return services;
}
/// <summary>
/// 添加适用于桌面端的 <see cref="INotificationService"/>
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddNotificationService(this IServiceCollection services)
{
services.AddSingleton<INotificationService, PlatformNotificationServiceImpl>();
return services;
}
}
}
@@ -1,4 +1,3 @@
using System.Application.UI;
using System.Properties;
using System.Windows;
@@ -18,19 +17,28 @@ namespace System.Application.Services.Implementation
void INotificationService<NotificationType, Entrance, INotificationService>.Cancel(NotificationType notificationType)
{
notifyIcon.HideBalloonTip();
if (OperatingSystem2.IsWindows)
{
notifyIcon.HideBalloonTip();
}
}
void INotificationService<NotificationType, Entrance, INotificationService>.CancelAll()
{
notifyIcon.HideBalloonTip();
if (OperatingSystem2.IsWindows)
{
notifyIcon.HideBalloonTip();
}
}
void INotificationService<NotificationType, Entrance, INotificationService>.Notify(string text, NotificationType notificationType, bool autoCancel, string? title, Entrance entrance)
{
title ??= ThisAssembly.AssemblyTrademark;
// 调用托盘显示通知
notifyIcon.ShowBalloonTip(title, text, ToolTipIcon.None);
if (OperatingSystem2.IsWindows)
{
title ??= ThisAssembly.AssemblyTrademark;
// 调用托盘显示通知
notifyIcon.ShowBalloonTip(title, text, ToolTipIcon.None);
}
}
Progress<float> INotificationService<NotificationType, Entrance, INotificationService>.NotifyDownload(Func<string> text, NotificationType notificationType, string? title)