From b21d965e0baa54b707f12d248309a4b1bc3e4f98 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 26 Oct 2021 21:26:08 -0500 Subject: [PATCH] Handle compatibility with win7/8 --- Flow.Launcher/Notification.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/Notification.cs b/Flow.Launcher/Notification.cs index b6aba7727..6b571b467 100644 --- a/Flow.Launcher/Notification.cs +++ b/Flow.Launcher/Notification.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; using System.Windows.Media; using Windows.Data.Xml.Dom; using Windows.UI.Notifications; @@ -17,18 +18,32 @@ namespace Flow.Launcher [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "")] public static void Show(string title, string subTitle, string iconPath) { - /* Using Windows Notification System */ + 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 = $"\"meziantou\"/{title}" + - $"{subTitle}"; + $"{subTitle}"; 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); + } } -} +} \ No newline at end of file