MCPcopy Create free account
hub / github.com/YtFlow/Maple / NotifyUser

Method NotifyUser

Maple.App/UI.cpp:11–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 using Windows::Foundation::Metadata::ApiInformation;
10
11 void UI::NotifyUser(hstring msg, hstring title)
12 {
13 static Windows::UI::Core::CoreDispatcher dispatcher{ Windows::UI::Xaml::Window::Current().Dispatcher() };
14 static std::vector<std::pair<hstring, hstring>> messages{};
15 dispatcher.RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
16 [msg = std::move(msg), title = std::move(title)]() -> fire_and_forget {
17 messages.push_back(std::make_pair(msg, title));
18
19 static bool isQueueRunning{ false };
20 if (std::exchange(isQueueRunning, true))
21 {
22 co_return;
23 }
24
25 // Display all messages until the queue is drained.
26 while (messages.size() > 0)
27 {
28 auto it = messages.begin();
29 auto [message, messageTitle] = std::move(*it);
30 messages.erase(it);
31 ContentDialog dialog;
32 if (messageTitle.size() > 0)
33 {
34 dialog.Title(box_value(std::move(messageTitle)));
35 }
36 if (ApiInformation::IsTypePresent(L"Windows.UI.Xaml.Input.StandardUICommand"))
37 {
38 dialog.CloseButtonCommand(StandardUICommand(StandardUICommandKind::Close));
39 }
40 else if (ApiInformation::IsPropertyPresent(
41 L"Windows.UI.Xaml.Controls.ContentDialog", L"CloseButtonText"))
42 {
43 dialog.CloseButtonText(L"Close");
44 }
45 else
46 {
47 dialog.SecondaryButtonText(L"Close");
48 }
49 dialog.Content(box_value(message));
50
51 co_await dialog.ShowAsync();
52 }
53 isQueueRunning = false;
54 });
55 }
56
57 void UI::NotifyUser(char const* msg, hstring title)
58 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected