File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 55using DevCLT . Infrastructure . Data ;
66using DevCLT . WindowsApp . Services ;
77using DevCLT . WindowsApp . ViewModels ;
8+ using Microsoft . Toolkit . Uwp . Notifications ;
89
910namespace DevCLT . WindowsApp ;
1011
@@ -44,6 +45,27 @@ protected override async void OnStartup(StartupEventArgs e)
4445 var window = new MainWindow ( ) ;
4546 window . Initialize ( mainVM ) ;
4647 window . Show ( ) ;
48+
49+ // Handle Notification Clicks
50+ ToastNotificationManagerCompat . OnActivated += toastArgs =>
51+ {
52+ // Runs on a background thread
53+ Application . Current . Dispatcher . Invoke ( delegate
54+ {
55+ var win = Application . Current . MainWindow ;
56+ if ( win != null )
57+ {
58+ if ( win . WindowState == WindowState . Minimized )
59+ win . WindowState = WindowState . Normal ;
60+
61+ win . Show ( ) ;
62+ win . Activate ( ) ;
63+ win . Topmost = true ; // Hack to bring to front
64+ win . Topmost = false ;
65+ win . Focus ( ) ;
66+ }
67+ } ) ;
68+ } ;
4769 }
4870 catch ( Exception ex )
4971 {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public void NotifyBreakEnded()
1010 try
1111 {
1212 new ToastContentBuilder ( )
13+ . AddArgument ( "action" , "viewApp" )
1314 . AddText ( "Pausa concluída" )
1415 . AddText ( "Clique para retomar o trabalho" )
1516 . Show ( ) ;
@@ -25,6 +26,7 @@ public void NotifyWorkCompleted()
2526 try
2627 {
2728 new ToastContentBuilder ( )
29+ . AddArgument ( "action" , "viewApp" )
2830 . AddText ( "Jornada concluída! 🎉" )
2931 . AddText ( "Você completou suas horas de trabalho." )
3032 . Show ( ) ;
@@ -37,6 +39,7 @@ public void NotifyOvertime(TimeSpan elapsed)
3739 try
3840 {
3941 new ToastContentBuilder ( )
42+ . AddArgument ( "action" , "viewApp" )
4043 . AddText ( "Hora extra em andamento" )
4144 . AddText ( $ "Já são { elapsed : hh\\:mm\\:ss} de hora extra.")
4245 . Show ( ) ;
You can’t perform that action at this time.
0 commit comments