SetThumbnailPrefetch() public méthode

public SetThumbnailPrefetch ( [ mode, [ requestedSize, [ options ) : void
mode [
requestedSize [
options [
Résultat void
Exemple #1
0
        //public ObservableCollection<ImageItem> Source = new ObservableCollection<ImageItem>();

        public async Task Init()
        {
            var queryOptions = new QueryOptions(CommonFileQuery.OrderByDate,
                new string[] { ".jpg", ".png", ".jpeg", ".bmp" })
            {
                FolderDepth = FolderDepth.Deep,
                IndexerOption = IndexerOption.OnlyUseIndexer,
                UserSearchFilter = "System.Kind:=System.Kind#Picture"
            };
            queryOptions.SetThumbnailPrefetch(ThumbnailMode.SingleItem, 256, ThumbnailOptions.UseCurrentScale);
            var _fileQueryResult = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
            var files = await _fileQueryResult.GetFilesAsync();
            Debug.WriteLine("Count " + files.Count);
            var list = new List<ImageItem>();
            foreach (var f in files)
            {
                list.Add(new ImageItem()
                {
                    LocalPath = f.Path
                });
            }

            Source = new RangeCollection(list);
            Source.Init();
        }
Exemple #2
0
        private async void LoadPhoto()
        {
            var queryOptions = new Windows.Storage.Search.QueryOptions(CommonFileQuery.OrderByDate, null);

            queryOptions.SetThumbnailPrefetch(ThumbnailMode.PicturesView, 100,
                                              ThumbnailOptions.ReturnOnlyIfCached);
            //queryOptions.SetPropertyPrefetch(PropertyPrefetchOptions.ImageProperties, new string[] { "System.Size" });
            queryOptions.SetThumbnailPrefetch(ThumbnailMode.ListView, 80, ThumbnailOptions.ReturnOnlyIfCached);

            StorageFileQueryResult      queryResults = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
            IReadOnlyList <StorageFile> files        = await queryResults.GetFilesAsync();

            foreach (var file in files)
            {
                var thumbnail = await file.GetThumbnailAsync(ThumbnailMode.ListView, 40, ThumbnailOptions.ReturnOnlyIfCached);

                thumbnailList.Add(thumbnail);
                debugText.Text = thumbnailList.Count.ToString();
                //BitmapImage bm = new BitmapImage();
                //bm.SetSource(thumbnail);
                //photoList.Add(bm);

                //ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();

                //// Do something with the date the image was taken.
                //DateTimeOffset dateTaken = imageProperties.DateTaken;

                //// Performance gains increase with the number of properties that are accessed.
                //IDictionary<String, object> propertyResults =
                //    await file.Properties.RetrievePropertiesAsync(
                //          new string[] { "System.Size" });

                //// Get/Set extra properties here
                //var systemSize = propertyResults["System.Size"];
            }
        }
        protected override async void OnInitialize()
        {
            base.OnInitialize();

            var localFolders = new[]
            {
                KnownFolders.MusicLibrary,
                KnownFolders.PicturesLibrary,
                KnownFolders.VideosLibrary
            };

            var serverFolders = await KnownFolders.MediaServerDevices.GetFoldersAsync();

            var queryOptions = new QueryOptions
            {
                FolderDepth = FolderDepth.Deep, 
                UserSearchFilter = Query
            };

            queryOptions.SetThumbnailPrefetch(ThumbnailMode.ListView, 150, ThumbnailOptions.UseCurrentScale);

            foreach (var folder in localFolders.Concat(serverFolders))
            {
                var itemQuery = folder.CreateItemQueryWithOptions(queryOptions);

                var items = await itemQuery.GetItemsAsync();

                if (items.Count == 0)
                    continue;

                var itemViewModels = items.Select<IStorageItem, StorageItemViewModel>(i =>
                {
                    if (i.IsOfType(StorageItemTypes.Folder))
                        return new StorageFolderViewModel((StorageFolder) i);

                    if (i.IsOfType(StorageItemTypes.File))
                        return new StorageFileViewModel((StorageFile) i);

                    return null;
                }).Where(v => v != null);

                GroupedStorageItems.Add(new StorageItemGroupViewModel(folder.DisplayName, itemViewModels));
            }

            await LoadThumbnailsAsync();
        }