mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #758 from onesounds/PopupRedesign
Change the popup to windows notification
This commit is contained in:
commit
76f8121915
3 changed files with 45 additions and 9 deletions
42
Flow.Launcher/Notification.cs
Normal file
42
Flow.Launcher/Notification.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Windows.Data.Xml.Dom;
|
||||
using Windows.UI.Notifications;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
internal static class Notification
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
|
||||
public static void Show(string title, string subTitle, string iconPath)
|
||||
{
|
||||
var legacy = Environment.OSVersion.Version.Major < 10;
|
||||
// Handle notification for win7/8
|
||||
if (legacy)
|
||||
{
|
||||
LegacyShow(title, subTitle, iconPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Using Windows Notification System
|
||||
var Icon = !File.Exists(iconPath)
|
||||
? Path.Combine(Constant.ProgramDirectory, "Images\\app.png")
|
||||
: iconPath;
|
||||
|
||||
var xml = $"<?xml version=\"1.0\"?><toast><visual><binding template=\"ToastImageAndText04\"><image id=\"1\" src=\"{Icon}\" alt=\"meziantou\"/><text id=\"1\">{title}</text>" +
|
||||
$"<text id=\"2\">{subTitle}</text></binding></visual></toast>";
|
||||
var toastXml = new XmlDocument();
|
||||
toastXml.LoadXml(xml);
|
||||
var toast = new ToastNotification(toastXml);
|
||||
ToastNotificationManager.CreateToastNotifier("Flow Launcher").Show(toast);
|
||||
|
||||
}
|
||||
|
||||
private static void LegacyShow(string title, string subTitle, string iconPath)
|
||||
{
|
||||
var msg = new Msg();
|
||||
msg.Show(title, subTitle, iconPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,8 +90,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var msg = useMainWindowAsOwner ? new Msg {Owner = Application.Current.MainWindow} : new Msg();
|
||||
msg.Show(title, subTitle, iconPath);
|
||||
Notification.Show(title, subTitle, iconPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -272,19 +272,14 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
ReloadPluginDataCommand = new RelayCommand(_ =>
|
||||
{
|
||||
var msg = new Msg
|
||||
{
|
||||
Owner = Application.Current.MainWindow
|
||||
};
|
||||
|
||||
Hide();
|
||||
|
||||
|
||||
PluginManager
|
||||
.ReloadData()
|
||||
.ContinueWith(_ =>
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
msg.Show(
|
||||
Notification.Show(
|
||||
InternationalizationManager.Instance.GetTranslation("success"),
|
||||
InternationalizationManager.Instance.GetTranslation("completedSuccessfully"),
|
||||
"");
|
||||
|
|
|
|||
Loading…
Reference in a new issue