Beispiel #1
0
 public override IAsyncOperation <IDictionary <string, object> > RetrievePropertiesAsync(IEnumerable <string> propertiesToRetrieve)
 {
     return(AsyncInfo.Run <IDictionary <string, object> >(async(cancellationToken) =>
     {
         var props = new Dictionary <string, object>();
         propertiesToRetrieve.ForEach(x => props[x] = null);
         // Fill common poperties
         var ret = item.AsBaseStorageFile()?.GetBasicPropertiesAsync() ?? item.AsBaseStorageFolder()?.GetBasicPropertiesAsync();
         var basicProps = ret != null ? await ret : null;
         props["System.ItemPathDisplay"] = item?.Path;
         props["System.DateCreated"] = basicProps?.ItemDate;
         props["System.DateModified"] = basicProps?.DateModified;
         return props;
     }));
 }
Beispiel #2
0
        public static async Task <byte[]> LoadIconFromStorageItemAsync(IStorageItem item, uint thumbnailSize, ThumbnailMode thumbnailMode)
        {
            if (item.IsOfType(StorageItemTypes.File))
            {
                using var thumbnail = (StorageItemThumbnail) await FilesystemTasks.Wrap(
                          () => item.AsBaseStorageFile ().GetThumbnailAsync (thumbnailMode, thumbnailSize, ThumbnailOptions.ResizeThumbnail).AsTask());

                if (thumbnail != null)
                {
                    return(await thumbnail.ToByteArrayAsync());
                }
            }
            else if (item.IsOfType(StorageItemTypes.Folder))
            {
                using var thumbnail = (StorageItemThumbnail) await FilesystemTasks.Wrap(
                          () => item.AsBaseStorageFolder ().GetThumbnailAsync (thumbnailMode, thumbnailSize, ThumbnailOptions.ResizeThumbnail).AsTask());

                if (thumbnail != null)
                {
                    return(await thumbnail.ToByteArrayAsync());
                }
            }
            return(null);
        }