mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Creation of a notification service
This commit is contained in:
@@ -29,6 +29,7 @@ namespace ModernKeePass.Infrastructure
|
||||
services.AddTransient(typeof(ISettingsProxy), typeof(UwpSettingsClient));
|
||||
services.AddTransient(typeof(IRecentProxy), typeof(UwpRecentFilesClient));
|
||||
services.AddTransient(typeof(IResourceProxy), typeof(UwpResourceClient));
|
||||
services.AddTransient(typeof(INotificationService), typeof(ToastNotificationService));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
@@ -88,6 +88,7 @@
|
||||
<Compile Include="KeePass\KeePassCredentialsClient.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UWP\StorageFileClient.cs" />
|
||||
<Compile Include="UWP\ToastNotificationService.cs" />
|
||||
<Compile Include="UWP\UwpRecentFilesClient.cs" />
|
||||
<Compile Include="UWP\UwpResourceClient.cs" />
|
||||
<Compile Include="UWP\UwpSettingsClient.cs" />
|
||||
|
23
ModernKeePass.Infrastructure/UWP/ToastNotificationService.cs
Normal file
23
ModernKeePass.Infrastructure/UWP/ToastNotificationService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Windows.UI.Notifications;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
|
||||
namespace ModernKeePass.Infrastructure.UWP
|
||||
{
|
||||
public class ToastNotificationService: INotificationService
|
||||
{
|
||||
public void Show(string title, string text)
|
||||
{
|
||||
var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
|
||||
var toastElements = notificationXml.GetElementsByTagName("text");
|
||||
toastElements[0].AppendChild(notificationXml.CreateTextNode(title));
|
||||
toastElements[1].AppendChild(notificationXml.CreateTextNode(text));
|
||||
|
||||
var toast = new ToastNotification(notificationXml)
|
||||
{
|
||||
ExpirationTime = DateTime.Now.AddSeconds(5)
|
||||
};
|
||||
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user