private async void OpenComicCollection(StorageFolder chosenFolder, StorageFolder collections) { LoadingGridVisible(true); List <StorageFile> files = await RecursivelySearchForFiles(chosenFolder); StorageFolder collectionFolder = (StorageFolder)await collections.TryGetItemAsync(chosenFolder.Name); if (collectionFolder == null) { collectionFolder = await collections.CreateFolderAsync(chosenFolder.Name); } else { ShowWarning("Collection already exist!", "Adding new comics"); } foreach (StorageFile sourceFile in files) { StorageFolder destFolder = (StorageFolder)await collectionFolder.TryGetItemAsync(sourceFile.Name); if (destFolder == null) { destFolder = await collectionFolder.CreateFolderAsync(sourceFile.Name); try { DefaultViewModel["LoadingFile"] = sourceFile.Name; if (sourceFile.FileType.Equals("cbz") || sourceFile.FileType.Equals(".cbz")) { await FolderZip.UnZipFile(sourceFile, destFolder); } else if (sourceFile.FileType.Equals("cbr") || sourceFile.FileType.Equals(".cbr")) { await FolderZip.UnRarFile(sourceFile, destFolder); } } catch (InvalidFormatException exception) { ShowWarning("Error opening file:" + sourceFile.Name, "Please try again"); } } LoadingBar.Value += (1.0 / files.Count()) * 100; } await CreateCollectionTiles(); CollectionViews.Clear(); foreach (CollectionTile tile in CollectionTiles) { CollectionViews.Add(new CollectionView(tile)); } defaultViewModel["ComicTiles"] = ComicTiles; defaultViewModel["CollectionViews"] = CollectionViews; LoadingGridVisible(false); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { LoadingRing.Visibility = Visibility.Visible; await CreateComicTiles(); await CreateCollectionTiles(); foreach (CollectionTile tile in CollectionTiles) { CollectionViews.Add(new CollectionView(tile)); } defaultViewModel["ComicTiles"] = ComicTiles; defaultViewModel["CollectionViews"] = CollectionViews; LoadingRing.Visibility = Visibility.Collapsed; }