Exemplo n.º 1
0
        private async void AddExcluded()
        {
            var picker = new FolderPicker
            {
                SuggestedStartLocation = PickerLocationId.MusicLibrary,
                ViewMode = PickerViewMode.List
            };

            picker.FileTypeFilter.Add("*");
            var folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                if (!LibraryFolders.Any(f => folder.Path.IsSubPathOf(f.Path)))
                {
                    await new MessageDialog(CommonSharedStrings.SelectionNotInLibraryPrompt).ShowAsync();
                }
                else
                {
                    var folderModel = new FolderModel
                    {
                        Path = folder.Path,
                        Name = folder.Name
                    };
                    PathExclusion.AddExcludedPath(folder.Path);
                    folderModel.RemoveFolderButtonClickedRelayCommand = new RelayCommand <RoutedEventArgs>(e =>
                    {
                        PathExclusion.RemoveExcludedPath(folder.Path);
                        ExcludedFolders.Remove(folderModel);
                    });
                    ExcludedFolders.Add(folderModel);
                }
            }
        }
Exemplo n.º 2
0
        /// <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);
            }
        }