Skip to content

Commit 886d7aa

Browse files
taoocerosonesounds
andcommitted
Move the show method to a static class Notification
Co-authored-by: Dobin Park <[email protected]>
1 parent 1317077 commit 886d7aa

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

Flow.Launcher/Notification.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Flow.Launcher.Infrastructure;
2+
using Flow.Launcher.Infrastructure.Image;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Media;
10+
using Windows.Data.Xml.Dom;
11+
using Windows.UI.Notifications;
12+
13+
namespace Flow.Launcher
14+
{
15+
internal static class Notification
16+
{
17+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
18+
public static void Show(string title, string subTitle, string iconPath)
19+
{
20+
/* Using Windows Notification System */
21+
var Icon = !File.Exists(iconPath)
22+
? ImageLoader.Load(Path.Combine(Constant.ProgramDirectory, "Images\\app.png"))
23+
: ImageLoader.Load(iconPath);
24+
25+
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>";
27+
var toastXml = new XmlDocument();
28+
toastXml.LoadXml(xml);
29+
var toast = new ToastNotification(toastXml);
30+
ToastNotificationManager.CreateToastNotifier("Flow Launcher").Show(toast);
31+
32+
}
33+
}
34+
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ public void ShowMsg(string title, string subTitle, string iconPath, bool useMain
9595
{
9696
Application.Current.Dispatcher.Invoke(() =>
9797
{
98-
var msg = useMainWindowAsOwner ? new Msg {Owner = Application.Current.MainWindow} : new Msg();
99-
msg.Show(title, subTitle, iconPath);
98+
Notification.Show(title, subTitle, iconPath);
10099
});
101100
}
102101

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,14 @@ private void InitializeKeyCommands()
239239

240240
ReloadPluginDataCommand = new RelayCommand(_ =>
241241
{
242-
var msg = new Msg
243-
{
244-
Owner = Application.Current.MainWindow
245-
};
246-
247242
MainWindowVisibility = Visibility.Collapsed;
248243

249244
PluginManager
250245
.ReloadData()
251246
.ContinueWith(_ =>
252247
Application.Current.Dispatcher.Invoke(() =>
253248
{
254-
msg.Show(
249+
Notification.Show(
255250
InternationalizationManager.Instance.GetTranslation("success"),
256251
InternationalizationManager.Instance.GetTranslation("completedSuccessfully"),
257252
"");

0 commit comments

Comments
 (0)