private async void Export_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var backend = new SqLiteBackend(new SqLiteStorageOptions("test"), SystemClock.Instance); var folder = await FileSystemAccess.PickFolderAsync(); var pages = new List <GenericPage>(); if (ExportAllPages.IsChecked == true) { pages.AddRange(await backend.GetAllPagesAsync()); } else if (ExportSinglePage.IsChecked == true) { pages.Add(await backend.GetPageAsync(_id)); } var exportHtml = ExportHtml.IsChecked == true; var exportMarkdown = ExportMarkdown.IsChecked == true; foreach (var page in pages) { if (exportHtml) { var contentRenderer = new ContentRenderer(); var file = await folder.CreateFileAsync($"{page.Link.Replace(':', '_')}.html", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, await contentRenderer.RenderContentAsync(page.Content, ContentType.Markdown), UnicodeEncoding.Utf8); } if (exportMarkdown) { var file = await folder.CreateFileAsync($"{page.Link.Replace(':', '_')}.md", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, page.Content, UnicodeEncoding.Utf8); } } Hide(); }
private async void LoadPages(SqLiteBackend storage) { var pages = await storage.GetAllPagesAsync(); Pages = new ObservableCollection <GenericPage>(pages); }