private async void AppBarButton_Click_ReloadBookShelf(object sender, RoutedEventArgs e) { var cbs = (await GetCurrentBookShelf()); if (cbs == null) { return; } var item = await Books.BookManager.StorageItemGet(cbs.GetFirstAccessToken()); var storage = await BookShelfStorage.GetBookShelves(); var target = storage[(await GetActualCurrentIndex())]; if (item is Windows.Storage.StorageFolder) { CurrentOperationCount++; var result = BookShelfStorage.GetFlatBookShelf(await BookShelfStorage.GetFromStorageFolder(item as Windows.Storage.StorageFolder)); result.Secret = target.Secret; var CurrentIndex = storage.IndexOf(target); if (CurrentIndex >= 0) { storage[CurrentIndex] = result; } CurrentOperationCount--; Refresh(); } }
private async void AppBarButton_Click_AddLocalDirectory(object sender, RoutedEventArgs e) { var picker = new Windows.Storage.Pickers.FolderPicker(); foreach (var ext in Books.BookManager.AvailableExtensionsArchive) { picker.FileTypeFilter.Add(ext); } var folder = await picker.PickSingleFolderAsync(); if (folder != null) { var rl = new Windows.ApplicationModel.Resources.ResourceLoader(); var dialog = new Windows.UI.Popups.MessageDialog(rl.GetString("LoadingFolder/Started/Message"), rl.GetString("LoadingFolder/Title")); await dialog.ShowAsync(); var storage = await BookShelfStorage.GetBookShelves(); CurrentOperationCount++; storage.Add(BookShelfStorage.GetFlatBookShelf(await BookShelfStorage.GetFromStorageFolder(folder))); CurrentOperationCount--; Refresh(); if (BookShelfList.Items != null) { BookShelfList.SelectedIndex = BookShelfList.Items.Count - 1; } dialog = new Windows.UI.Popups.MessageDialog(rl.GetString("LoadingFolder/Completed/Message"), rl.GetString("LoadingFolder/Title")); await dialog.ShowAsync(); } await BookShelfStorage.SaveAsync(); }