55#include " resource.h"
66#include " App.h"
77#include < CommCtrl.h>
8+ #include " ScalingService.h"
89
910using namespace winrt ::Magpie::implementation;
11+ using namespace winrt ;
1012
1113namespace Magpie {
1214
@@ -106,14 +108,22 @@ LRESULT NotifyIconService::_NotifyIconWndProc(HWND hWnd, UINT message, WPARAM wP
106108 }
107109 case WM_RBUTTONUP:
108110 {
109- winrt::ResourceLoader resourceLoader =
110- winrt::ResourceLoader::GetForCurrentView (CommonSharedConstants::APP_RESOURCE_MAP_ID);
111- winrt::hstring mainWindowText = resourceLoader.GetString (L" NotifyIcon_MainWindow" );
112- winrt::hstring exitText = resourceLoader.GetString (L" NotifyIcon_Exit" );
113-
114111 wil::unique_hmenu hMenu (CreatePopupMenu ());
112+
113+ ResourceLoader resourceLoader =
114+ ResourceLoader::GetForCurrentView (CommonSharedConstants::APP_RESOURCE_MAP_ID);
115+ hstring mainWindowText = resourceLoader.GetString (L" NotifyIcon_MainWindow" );
115116 AppendMenu (hMenu.get (), MF_STRING, 1 , mainWindowText.c_str ());
116- AppendMenu (hMenu.get (), MF_STRING, 2 , exitText.c_str ());
117+
118+ hstring fmtStr = resourceLoader.GetString (L" Home_Activation_Timer_ButtonText" );
119+ std::wstring timerText = fmt::format (
120+ fmt::runtime (std::wstring_view (fmtStr)),
121+ AppSettings::Get ().CountdownSeconds ()
122+ );
123+ AppendMenu (hMenu.get (), MF_STRING, 2 , timerText.c_str ());
124+
125+ hstring exitText = resourceLoader.GetString (L" NotifyIcon_Exit" );
126+ AppendMenu (hMenu.get (), MF_STRING, 3 , exitText.c_str ());
117127
118128 // hWnd 必须为前台窗口才能正确展示弹出菜单
119129 // 即使 hWnd 是隐藏的
@@ -137,6 +147,11 @@ LRESULT NotifyIconService::_NotifyIconWndProc(HWND hWnd, UINT message, WPARAM wP
137147 break ;
138148 }
139149 case 2 :
150+ {
151+ ScalingService::Get ().StartTimer ();
152+ break ;
153+ }
154+ case 3 :
140155 {
141156 App::Get ().Quit ();
142157 break ;
0 commit comments