| 110 | const auto _ = winrt::Windows::System::Launcher::LaunchUriAsync(Uri{ L"https://github.com/eycorsican/leaf/blob/master/README.zh.md" }); |
| 111 | } |
| 112 | IAsyncAction EditPage::SaveDocument() |
| 113 | { |
| 114 | try { |
| 115 | const auto lifetime = get_strong(); |
| 116 | if (!SaveButton().IsEnabled()) { |
| 117 | co_return; |
| 118 | } |
| 119 | SaveModifiedContent = nullptr; |
| 120 | SaveButton().IsEnabled(false); |
| 121 | hstring content{}; |
| 122 | EditBox().Document().GetText(TextGetOptions::NoHidden | TextGetOptions::UseCrlf, content); |
| 123 | const auto data = to_string(content); |
| 124 | co_return co_await FileIO::WriteBytesAsync( |
| 125 | m_file, |
| 126 | std::vector<uint8_t>(data.begin(), data.end())); |
| 127 | } |
| 128 | catch (...) |
| 129 | { |
| 130 | UI::NotifyException(L"Saving document"); |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |