mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Handle compatibility with win7/8
This commit is contained in:
parent
6e6db2c67b
commit
b21d965e0b
1 changed files with 18 additions and 3 deletions
|
|
@ -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 = "<Pending>")]
|
||||
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 = $"<?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>";
|
||||
$"<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue