public StorageEntry(StorageFile file, StorageEntryUsage usage) { this.EntryType = StorageEntryType.File; this.ContentType = SEContentAgency.AnyalizeStorageEntryContent(file); this._storageItem = file; this.LoadThumbnail(usage); }
// Constructor public StorageEntry(StorageFolder folder, StorageEntryUsage usage) { this.EntryType = StorageEntryType.Folder; this.ContentType = SEContent.Folder; this._storageItem = folder; this.LoadThumbnail(usage); }
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); } }
public static async Task <StorageEntryLoadInfo> LoadMoreStorageItemAsync(StorageFolder destFolder, ObservableCollection <StorageEntry> collection, StorageEntryUsage usage, StorageEntryLoadInfo info) { IReadOnlyList <IStorageItem> storageItems = null; if (info.LeavingCount < PreferenceAgency.Default.MaxLoadCount) { storageItems = await destFolder.GetItemsAsync(info.loadedCount, info.LeavingCount); info.loadedCount = info.entriesCount; info.isLoadedAll = true; } else { storageItems = await destFolder.GetItemsAsync(info.loadedCount, PreferenceAgency.Default.MaxLoadCount); info.loadedCount += PreferenceAgency.Default.MaxLoadCount; } foreach (var eachItem in storageItems) { var newEntry = new StorageEntry(eachItem, usage); collection.Add(newEntry); } return(info); }
public static async Task <StorageEntryLoadInfo> LoadStorageFolderAsync(StorageFolder destFolder, ObservableCollection <StorageEntry> collection, StorageEntryUsage usage) { var itemsCount = Directory.GetFileSystemEntries(destFolder.Path, "*", SearchOption.TopDirectoryOnly).Length; StorageEntryLoadInfo info; info.entriesCount = (uint)itemsCount; info.path = destFolder.Path; IReadOnlyList <IStorageItem> storageItems = null; if (itemsCount > PreferenceAgency.Default.InitialMaxLoadCount) { storageItems = await destFolder.GetItemsAsync(0, PreferenceAgency.Default.InitialMaxLoadCount); info.isLoadedAll = false; info.loadedCount = PreferenceAgency.Default.InitialMaxLoadCount; } else { storageItems = await destFolder.GetItemsAsync(); info.isLoadedAll = true; info.loadedCount = info.entriesCount; } foreach (var eachItem in storageItems) { var newEntry = new StorageEntry(eachItem, usage); collection.Add(newEntry); } return(info); }
// 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; } }