Esempio n. 1
0
        private async Task RebuildSubFolderList(FolderReadingDialog dialog)
        {
            foreach (var item in this.NavigationPane.MenuItems)
            {
                if (item is NavigationViewItem nv)
                {
                    if (nv.Content is FolderListItem fd)
                    {
                        fd.Release();
                    }
                }
            }

            this.NavigationPane.MenuItems.Clear();

            if (this.thumbnailPages != null)
            {
                foreach (var page in this.thumbnailPages)
                {
                    page.Release();
                }
            }

            this.thumbnailPages = new List <ThumbnailPage>();

            var count = MediaManager.FolderEntries.Length;

            dialog.IsIndeterminate = false;
            dialog.Maximum         = count;

            var trees = FolderListItem.BuildTreeString(MediaManager.FolderEntries);

            for (int i = 0; i < count; i++)
            {
                var folder = MediaManager.FolderEntries[i];

                dialog.Value = i;

                var item = new FolderListItem {
                    FolderEntry = folder, TreeText = trees[i]
                };
                var navigationitem = new NavigationViewItem()
                {
                    Content = item
                };

                this.NavigationPane.MenuItems.Add(navigationitem);

                var cover = await MediaManager.FindFolderThumbnailEntry(folder);

                if (cover != null)
                {
                    _ = this.UpdateFolderThumbnail(cover, item);
                }
            }

            dialog.Value = count;

            this.NavigationPane.SelectedItem = this.NavigationPane.MenuItems[0];
        }
Esempio n. 2
0
        private async Task <Exception> ChangeMediaProvider(AbstractMediaProvider provider)
        {
            if (this.NavigationPane.SelectedItem is NavigationViewItem selectedItem)
            {
                if (selectedItem.Content is FolderListItem item)
                {
                    var page = this.thumbnailPages.Find((p) => p.Entry == item.FolderEntry);
                    if (page != null)
                    {
                        page.CancellationToken.Cancel();
                    }
                }
            }

            FolderReadingDialog dialog = new FolderReadingDialog();

            _ = dialog.ShowAsync(ContentDialogPlacement.Popup);

            Exception error;

            error = await MediaManager.ChangeProvider(provider);

            if (error != null)
            {
                dialog.Hide();
                return(error);
            }

            await this.RebuildSubFolderList(dialog);

            GC.Collect();
            this.ThumbnailBorder.Opacity = 0;

            this.HideImageControl();
            this.IsEnabled = true;
            dialog.Hide();
            return(null);
        }