예제 #1
0
 public StorageEntry(StorageFile file, StorageEntryUsage usage)
 {
     this.EntryType    = StorageEntryType.File;
     this.ContentType  = SEContentAgency.AnyalizeStorageEntryContent(file);
     this._storageItem = file;
     this.LoadThumbnail(usage);
 }
예제 #2
0
 public StorageEntry(IStorageItem item, StorageEntryUsage usage)
 {
     if (item is StorageFile file)
     {
         this.EntryType    = StorageEntryType.File;
         this.ContentType  = SEContentAgency.AnyalizeStorageEntryContent(file);
         this._storageItem = item;
         this.LoadThumbnail(usage);
     }
     else
     {
         this.EntryType    = StorageEntryType.Folder;
         this.ContentType  = SEContent.Folder;
         this._storageItem = item;
         this.LoadThumbnail(usage);
     }
 }
예제 #3
0
        // http://www.cnblogs.com/hebeiDGL/archive/2012/09/27/2705478.html
        // Configure Thumbnail
        private async void LoadThumbnail(StorageEntryUsage usage)
        {
            switch (this.EntryType)
            {
            case StorageEntryType.File:
                this.ThumbSource = new BitmapImage();
                StorageItemThumbnail thumbnail = null;
                switch (usage)
                {
                case StorageEntryUsage.TilesFieldItem:
                case StorageEntryUsage.ColumnFieldItem:
                    thumbnail = await File.GetThumbnailAsync(
                        SEContentAgency.FieldItemThumbnailModes[(int)ContentType],
                        60,                                   // Requested size
                        ThumbnailOptions.ReturnOnlyIfCached); // TODO: Test the ThumbnailOptions

                    break;

                case StorageEntryUsage.PanelPreview:
                    thumbnail = await File.GetThumbnailAsync(
                        SEContentAgency.PanelPreviewThumbnailModes[(int)ContentType],
                        150,         // Requested size
                        ThumbnailOptions.UseCurrentScale);

                    break;

                case StorageEntryUsage.ParentFolder:
                    this.ThumbSource = null;
                    return;         // 没有必要加载该文件夹的略缩图,直接结束本方法
                }

                if (thumbnail is null)
                {
                    switch (usage)
                    {
                    case StorageEntryUsage.ColumnFieldItem:
                    case StorageEntryUsage.TilesFieldItem:
                        this.ThumbSource.UriSource = SEContentAgency.GetDefaultThumbnailUri(this.ContentType); break;

                    case StorageEntryUsage.PanelPreview:
                        this.ThumbSource.UriSource = SEContentAgency.GetDefaultPreviewUri(this.ContentType); break;
                    }
                }
                else
                {
                    this.ThumbSource.SetSource(thumbnail);
                }
                break;

            case StorageEntryType.Folder:
                switch (usage)
                {
                case StorageEntryUsage.TilesFieldItem:
                case StorageEntryUsage.ColumnFieldItem:
                    this.ThumbSource = new BitmapImage(new Uri("ms-appx:///Assets/THUMB/Folder_Small.png")); break;

                case StorageEntryUsage.PanelPreview:
                    this.ThumbSource = new BitmapImage(new Uri("ms-appx:///Assets/THUMB/Folder_Medium.png")); break;

                case StorageEntryUsage.ParentFolder:
                    this.ThumbSource = null;
                    return;         // 没有必要加载该文件夹的略缩图,直接结束本方法
                }
                break;
            }
        }