Flow.Launcher/Flow.Launcher/Notification.cs
Jeremy Wu 43ac9b4f6d
Release 1.9.5 (#1386)
* Merge pull request #1061 from Flow-Launcher/remove_winget_ci

* Merge pull request #991 from Flow-Launcher/context_menu_plugin_site

* Merge pull request #1080 from gissehel/caret-position-fix

* Caret position fix : Include PR #1074

* Merge pull request #1283 from nachmore/dev

* Merge pull request #1296 from nachmore/bug_1284

* Merge pull request #1294 from Flow-Launcher/pluginInfoMultipleActionKeyword

* Merge pull request #1299 from nachmore/bug_1269

* Plugin Exception Draft (#1147)

* Merge pull request #1355 from onesounds/LimitWidth

* Merge pull request #1088 from Flow-Launcher/add_spanish_latin_america

* Merge pull request #1387 from Flow-Launcher/fix_exception_duplicate_url_opening

* Merge pull request #1390 from Flow-Launcher/issue_1371

* Merge pull request #1391 from Flow-Launcher/issue_1366
2022-09-28 09:39:28 +10:00

48 lines
1.6 KiB
C#

using Flow.Launcher.Infrastructure;
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.IO;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
namespace Flow.Launcher
{
internal static class Notification
{
internal static bool legacy = Environment.OSVersion.Version.Build < 19041;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
internal static void Uninstall()
{
if (!legacy)
ToastNotificationManagerCompat.Uninstall();
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public static void Show(string title, string subTitle, string iconPath = null)
{
// Handle notification for win7/8/early win10
if (legacy)
{
LegacyShow(title, subTitle, iconPath);
return;
}
// Using Windows Notification System
var Icon = !File.Exists(iconPath)
? Path.Combine(Constant.ProgramDirectory, "Images\\app.png")
: iconPath;
new ToastContentBuilder()
.AddText(title, hintMaxLines: 1)
.AddText(subTitle)
.AddAppLogoOverride(new Uri(Icon))
.Show();
}
private static void LegacyShow(string title, string subTitle, string iconPath)
{
var msg = new Msg();
msg.Show(title, subTitle, iconPath);
}
}
}