Exemple #1
0
 public LocalFoldersPage()
 {
     this.InitializeComponent();
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
     LocalPage.FolderListener = this;
     MusicInfoControl.MusicModifiedListeners.Add((before, after) =>
     {
         if (CurrentTree.Contains(before))
         {
             CurrentTree = Settings.settings.Tree.FindTree(CurrentTree);
             foreach (var node in LocalFoldersTreeView.RootNodes)
             {
                 if (node.Content is Music music)
                 {
                     if (music == before)
                     {
                         music.CopyFrom(after);
                         break;
                     }
                 }
                 else if (node.Content is FolderTree tree)
                 {
                     if (tree.FindMusic(before) is Music m)
                     {
                         m.CopyFrom(after);
                         break;
                     }
                 }
             }
             if (GridItems.FirstOrDefault(item => item.Tree.Contains(before)) is GridFolderView gridItem)
             {
                 gridItem.Tree.FindMusic(before).CopyFrom(after);
             }
         }
     });
 }
        /// <summary>
        ///     Will retrieve the full folder and file tree for a folder from the internal storage.
        /// </summary>
        /// <param name="folder">The instance of the folder for which the tree will be retrieved.</param>
        private async void GetTreeForFolder(IStorageFolderEx folder)
        {
            if (!FolderTree.Contains(folder))
            {
                FolderTree.Push(folder);
            }

            ProcessSelectedItems();

            CurrentItems.Clear();

            IEnumerable <IStorageFolderEx> folderList = await folder.GetFoldersAsync();

            foreach (IStorageFolderEx _folder in folderList)
            {
                FileExplorerItem item =
                    (from c in SelectedItems where c.Path == _folder.Path select c).FirstOrDefault();

                var _addItem = new FileExplorerItem
                {
                    IsFolder    = true,
                    Name        = _folder.Name,
                    DisplayName = _folder.DisplayName,
                    Path        = _folder.Path,
                    Selected    = false
                };

                CurrentItems.Add(_addItem);
            }

            IEnumerable <IStorageFileEx> fileList = await folder.GetFilesAsync();

            if (fileList != null)
            {
                foreach (IStorageFileEx _file in fileList)
                {
                    //FileExplorerItem item = GetItemFromPath(_file.Path);

                    if (((ExtensionRestrictions & (ExtensionRestrictions.Custom | ExtensionRestrictions.InheritManifest)) !=
                         0) && (Extensions.Count != 0))
                    {
                        string extension = Path.GetExtension(_file.Name);
                        if (Extensions.FindIndex(x => x.Equals(extension, StringComparison.OrdinalIgnoreCase)) != -1)
                        {
                            CurrentItems.Add(new FileExplorerItem
                            {
                                IsFolder    = false,
                                Name        = _file.Name,
                                DisplayName = _file.Name,
                                Path        = _file.Path,
                                Selected    = false
                            });
                        }
                    }
                    else
                    {
                        CurrentItems.Add(new FileExplorerItem
                        {
                            IsFolder    = false,
                            Name        = _file.Name,
                            Path        = _file.Path,
                            DisplayName = _file.Name,
                            Selected    = false
                        });
                    }
                }
            }

            CurrentPath = FolderTree.First()
                          .Path;
        }