Example #1
0
        private async Task AddItemToRecentListAsync(IStorageItem item, Windows.Storage.AccessCache.AccessListEntry entry)
        {
            BitmapImage      ItemImage;
            string           ItemPath;
            string           ItemName;
            StorageItemTypes ItemType;
            bool             ItemFolderImgVis;
            bool             ItemEmptyImgVis;
            bool             ItemFileIconVis;

            if (item.IsOfType(StorageItemTypes.File))
            {
                // Try to read the file to check if still exists
                // This is only needed to remove files opened from a disconnected android/MTP phone
                if (string.IsNullOrEmpty(item.Path)) // This indicates that the file was open from an MTP device
                {
                    using (var inputStream = await((StorageFile)item).OpenReadAsync())
                        using (var classicStream = inputStream.AsStreamForRead())
                            using (var streamReader = new StreamReader(classicStream))
                            {
                                // NB: this might trigger the download of the file from OneDrive
                                streamReader.Peek();
                            }
                }

                ItemName  = item.Name;
                ItemPath  = string.IsNullOrEmpty(item.Path) ? entry.Metadata : item.Path;
                ItemType  = StorageItemTypes.File;
                ItemImage = new BitmapImage();
                StorageFile file      = (StorageFile)item;
                var         thumbnail = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 24, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);

                if (thumbnail == null)
                {
                    ItemEmptyImgVis = true;
                }
                else
                {
                    await ItemImage.SetSourceAsync(thumbnail);

                    ItemEmptyImgVis = false;
                }
                ItemFolderImgVis = false;
                ItemFileIconVis  = true;
                recentItemsCollection.Add(new RecentItem()
                {
                    RecentPath  = ItemPath,
                    Name        = ItemName,
                    Type        = ItemType,
                    FolderImg   = ItemFolderImgVis,
                    EmptyImgVis = ItemEmptyImgVis,
                    FileImg     = ItemImage,
                    FileIconVis = ItemFileIconVis
                });
            }
        }
Example #2
0
 private async Task AddAUserFolder(AccessListEntry item, StorageFolder retrievedFolder)
 {
     var folderItem = AddNewItem(ExplorerGroups[1], retrievedFolder, item.Token);
     await GetSubImage(folderItem);
 }
Example #3
0
 public HistoryMRUItem(Windows.Storage.AccessCache.AccessListEntry access)
 {
     this.Content = BookViewerApp.Managers.HistoryManager.Metadata.Deserialize(access.Metadata) ?? new BookViewerApp.Managers.HistoryManager.Metadata();
     this.Token   = access.Token;
 }