Skip to content

Commit b21d965

Browse files
committed
Handle compatibility with win7/8
1 parent 6e6db2c commit b21d965

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Flow.Launcher/Notification.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Text;
88
using System.Threading.Tasks;
9+
using System.Windows.Forms;
910
using System.Windows.Media;
1011
using Windows.Data.Xml.Dom;
1112
using Windows.UI.Notifications;
@@ -17,18 +18,32 @@ internal static class Notification
1718
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
1819
public static void Show(string title, string subTitle, string iconPath)
1920
{
20-
/* Using Windows Notification System */
21+
var legacy = Environment.OSVersion.Version.Major < 10;
22+
// Handle notification for win7/8
23+
if (legacy)
24+
{
25+
LegacyShow(title, subTitle, iconPath);
26+
return;
27+
}
28+
29+
// Using Windows Notification System
2130
var Icon = !File.Exists(iconPath)
2231
? Path.Combine(Constant.ProgramDirectory, "Images\\app.png")
2332
: iconPath;
2433

2534
var xml = $"<?xml version=\"1.0\"?><toast><visual><binding template=\"ToastImageAndText04\"><image id=\"1\" src=\"{Icon}\" alt=\"meziantou\"/><text id=\"1\">{title}</text>" +
26-
$"<text id=\"2\">{subTitle}</text></binding></visual></toast>";
35+
$"<text id=\"2\">{subTitle}</text></binding></visual></toast>";
2736
var toastXml = new XmlDocument();
2837
toastXml.LoadXml(xml);
2938
var toast = new ToastNotification(toastXml);
3039
ToastNotificationManager.CreateToastNotifier("Flow Launcher").Show(toast);
3140

3241
}
42+
43+
private static void LegacyShow(string title, string subTitle, string iconPath)
44+
{
45+
var msg = new Msg();
46+
msg.Show(title, subTitle, iconPath);
47+
}
3348
}
34-
}
49+
}

0 commit comments

Comments
 (0)