6
6
using System . Linq ;
7
7
using System . Text ;
8
8
using System . Threading . Tasks ;
9
+ using System . Windows . Forms ;
9
10
using System . Windows . Media ;
10
11
using Windows . Data . Xml . Dom ;
11
12
using Windows . UI . Notifications ;
@@ -17,18 +18,32 @@ internal static class Notification
17
18
[ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Interoperability" , "CA1416:Validate platform compatibility" , Justification = "<Pending>" ) ]
18
19
public static void Show ( string title , string subTitle , string iconPath )
19
20
{
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
21
30
var Icon = ! File . Exists ( iconPath )
22
31
? Path . Combine ( Constant . ProgramDirectory , "Images\\ app.png" )
23
32
: iconPath ;
24
33
25
34
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>";
27
36
var toastXml = new XmlDocument ( ) ;
28
37
toastXml . LoadXml ( xml ) ;
29
38
var toast = new ToastNotification ( toastXml ) ;
30
39
ToastNotificationManager . CreateToastNotifier ( "Flow Launcher" ) . Show ( toast ) ;
31
40
32
41
}
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
+ }
33
48
}
34
- }
49
+ }
0 commit comments