/// <summary> /// Method for loading library folders. /// </summary> /// <returns></returns> public async Task LoadFoldersAsync() { // Library var libraryFolders = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music); foreach (var folder in libraryFolders.Folders) { LibraryFolders.Add(new FolderModel { Path = folder.Path, Name = folder.Name, RemoveFolderButtonClickedRelayCommand = _removeFolderButtonClickedRelayCommand }); } var excludedFolders = PathExclusion.GetExcludedPath(); foreach (var folder in excludedFolders) { var folderModel = new FolderModel { Path = folder, Name = Path.GetDirectoryName(folder) }; folderModel.RemoveFolderButtonClickedRelayCommand = new RelayCommand <RoutedEventArgs>(e => { PathExclusion.RemoveExcludedPath(folder); ExcludedFolders.Remove(folderModel); }); ExcludedFolders.Add(folderModel); } var accessFolders = await FutureAccessListHelper.Instance.GetAuthroizedStorageItemsAsync(); foreach (var item in accessFolders) { var folderModel = new FolderModel { Path = item.Item2.Path, Name = item.Item2.Name }; var token = item.Item1; folderModel.RemoveFolderButtonClickedRelayCommand = new RelayCommand <RoutedEventArgs>( async(e) => { await FutureAccessListHelper.Instance.RemoveAuthorizedItemAsync(token); AccessFolders.Remove(folderModel); }); AccessFolders.Add(folderModel); } }
/// <summary> /// Handle adding folders. /// </summary> private async void AddFolderStub() { // Select a folder. var libraryFolders = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music); var folder = await libraryFolders.RequestAddFolderAsync(); if (folder == null || LibraryFolders.Any((c) => c.Path == folder.Path)) { return; } // Add folder to library. LibraryFolders.Add(new FolderModel { Name = folder.Name, Path = folder.Path, RemoveFolderButtonClickedRelayCommand = _removeFolderButtonClickedRelayCommand }); }