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

Method OnNavigatedTo

Maple.App/EditPage.cpp:21–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 }
20
21 fire_and_forget EditPage::OnNavigatedTo(NavigationEventArgs const& e) {
22 try {
23 const auto lifetime = get_strong();
24 const auto& param = e.Parameter().as<Maple_App::ConfigViewModel>();
25
26 m_file = param.File();
27 try {
28 const auto& text = co_await FileIO::ReadTextAsync(param.File(), UnicodeEncoding::Utf8);
29 EditBox().Document().SetText(TextSetOptions::None, text);
30 }
31 catch (const winrt::hresult_error&) {
32 EditBox().Document().SetText(TextSetOptions::None, L"Invalid configuration file");
33 }
34 const auto weakThis = lifetime->get_weak();
35 m_saveModifiedContent = [weakThis]() -> IAsyncAction {
36 if (const auto self{ weakThis.get() }) {
37 return self->SaveDocument();
38 }
39 return {};
40 };
41 }
42 catch (...)
43 {
44 UI::NotifyException(L"Failed to load file");
45 }
46 }
47 void EditPage::OnNavigatingFrom(NavigatingCancelEventArgs const&) {
48 if (m_file == nullptr || !m_file.IsAvailable()) {
49 return;

Callers

nothing calls this directly

Calls 2

SaveDocumentMethod · 0.95
FileMethod · 0.80

Tested by

no test coverage detected