diff --git a/Flow.Launcher/Notification.cs b/Flow.Launcher/Notification.cs new file mode 100644 index 000000000..2c82e1451 --- /dev/null +++ b/Flow.Launcher/Notification.cs @@ -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 = "")] + 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 = $"\"meziantou\"/{title}" + + $"{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 diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 6f995671d..be778d798 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -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); }); } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index e54014110..4588a677f 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -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"), "");