/// <summary> /// 刷新照片列表 /// </summary> /// <param name="imageFolderList"></param> /// <returns></returns> public async Task <ImageFolderList> RefreshAsync(ImageFolderList imageFolderList) { var folder = await _folderModelService.GetFolder(imageFolderList.FolderModel.AccessToken); // TODO 这里文件夹可能为空 // 找到全部文件 var files = await folder.GetFilesAsync(); foreach (var file in files) { // 确认后缀名必须是图片 if (file.FileType != ".jpg" && file.FileType != ".png" && file.FileType != ".jpeg") { continue; } var accessToken = StorageApplicationPermissions.FutureAccessList.Add(file); var imageModel = await _imageModelService.GetInstanceAsync(imageFolderList.FolderModel.KeyNo, file.Path, accessToken); if (imageFolderList.ImageModels.Contains(imageModel)) { continue; } imageFolderList.DatabaseHelper.ImageDatabase.Insert(imageModel.FolderKeyNo, imageModel.ImagePath, imageModel.AccessToken); imageFolderList.ImageModels.Add(imageModel); } var x = imageFolderList.GetHashCode(); return(imageFolderList); }
/// <summary> /// 异步获得实例 /// </summary> /// <returns></returns> public async Task <ImageFolderList> GetInstanceAsync(FolderModel folderModel) { var imageFolderList = new ImageFolderList(folderModel); // 初始化list var query = imageFolderList.DatabaseHelper.ImageDatabase.GetQuery(folderModel.KeyNo); while (query.Read()) { var imagePath = query.GetString(2); var accessToken = query.GetString(3); var imageModel = await _imageModelService.GetInstanceAsync(query.GetInt32(1), imagePath, accessToken); // 查下这个图片还在不在 if (imageModel != null) { imageModel.KeyNo = query.GetInt32(0); imageFolderList.ImageModels.Add(imageModel); } else { // 从数据库里删掉这个图片 imageFolderList.DatabaseHelper.ImageDatabase.Delete(imagePath); // 从使用list里删掉这个文件夹 StorageApplicationPermissions.FutureAccessList.Remove(accessToken); } } return(imageFolderList); }
/// <summary> /// 刷新文件夹list,但不刷新图片list /// </summary> /// <returns></returns> public async Task RefreshFolderListAsync() { _imageFolderLists.Clear(); _folderList = await FolderList.GetInstanceAsync(); foreach (var folderModel in _folderList.FolderModels) { var imageFolderList = await ImageFolderList.GetInstanceAsync(folderModel); _imageFolderLists.Add(imageFolderList); } }
//for the tostring thing public override string ToString() { return(string.Format("NativeProcessingFile: {0}\nActualPatchName: {1}\nPkg: {2}\nDirectoryInArchive: {3}\nAtlasFile: {4}\nStlasSaveDirectory: {5}\nSltas width: {6}\nSltas hight: {7}\nPadding: {8}\nPowOf2: {9}\nSquare: {10}\nFastImagePacker: {11}\nGenerateMap: {12}\nMapTypeName: {13}\nImageFolderList: {14}\nTexturelist: {15}\nAllowToAddNewPictures: {16}", NativeProcessingFile.Equals("") ? "(empty)" : NativeProcessingFile, ActualPatchName.Equals("") ? "(empty)" : ActualPatchName, Pkg.Equals("") ? "(empty)" : Pkg, DirectoryInArchive.Equals("") ? "(empty)" : DirectoryInArchive, AtlasFile.Equals("") ? "(empty)" : AtlasFile, AtlasSaveDirectory.Equals("") ? "(empty)" : AtlasSaveDirectory, AtlasWidth == 0 ? "(empty)" : "" + AtlasWidth, AtlasHeight == 0 ? "(empty)" : "" + AtlasHeight, Padding == 0 ? "(empty)" : "" + Padding, PowOf2 == State.None ? "(empty)" : PowOf2 == State.True ? "True" : "False", Square == State.None ? "(empty)" : Square == State.True ? "True" : "False", FastImagePacker ? "True" : "False", GenerateMap == State.None ? "(empty)" : GenerateMap == State.True ? "True" : "False", MapType == MapTypes.None ? "(none selected)" : MapTypeName(MapType), ImageFolderList.Count == 0 ? "(empty)" : ImageFolderList.ToString(), TextureList.Count == 0 ? "(empty)" : TextureList.Count.ToString(), AllowToAddAdditionalImages ? "True" : "False")); }