66using System . Linq ;
77using System . Text ;
88using System . Threading . Tasks ;
9+ using System . Windows . Forms ;
910using System . Windows . Media ;
1011using Windows . Data . Xml . Dom ;
1112using 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