protected override void ValueToKey(object value, out string key, out string fastKey, out bool delayLoading) { delayLoading = false; key = ""; fastKey = ""; if (value is IFileSystemInfoExA) { IFileSystemInfoExA entry = value as IFileSystemInfoExA; if (value is IFileInfoExA) { fastKey = PathEx.GetExtension(entry.Name); if (imageFilter.IndexOf(fastKey) == -1) { key = entry.ParseName; } else { key = fastKey; } delayLoading = key != fastKey; } else //IDirectoryInfoExA { IDirectoryInfoExA dirEntry = entry as IDirectoryInfoExA; if (dirEntry.IsFileBasedFS) { fastKey = key = PathEx.GetExtension(entry.Name); } else { fastKey = tempPath; key = fastKey; if (IsSpecialFolder(entry.ParseName)) { key = entry.ParseName; delayLoading = true; } } } } }
//Icon (e.g. exe) private void PollIconCallback(object state) { thumbnailInfo input = state as thumbnailInfo; IFileSystemInfoExA entry = input.entry; if (input.roll != currentRoll) { Debug.Write(entry.Name + " discarded."); return; } getPathLock.TryEnterWriteLock(-1); string fileName = ""; try { fileName = entry.FullName; } finally { getPathLock.ExitWriteLock(); } WriteableBitmap writeBitmap = input.bitmap; IconSize size = input.iconsize; if (input.roll != currentRoll) { Debug.Write(entry.Name + " discarded."); return; } Bitmap origBitmap = KeyToBitmap(fileName, size); Bitmap inputBitmap = origBitmap; if (size == IconSize.jumbo || size == IconSize.thumbnail) { inputBitmap = resizeJumbo(origBitmap, IconSizeToSize(size), 5); } else { inputBitmap = resizeImage(origBitmap, IconSizeToSize(size), 0); } BitmapSource inputBitmapSource = loadBitmap(inputBitmap); origBitmap.Dispose(); inputBitmap.Dispose(); copyBitmap(inputBitmapSource, writeBitmap, true, 0); }
//Thumbnail (for images) private void PollThumbnailCallback(object state) { //Non UIThread thumbnailInfo input = state as thumbnailInfo; IFileSystemInfoExA entry = input.entry; if (input.roll != currentRoll) { Debug.Write(entry.Name + " discarded."); return; } getPathLock.TryEnterWriteLock(-1); string fileName = ""; try { fileName = entry.FullName; } finally { getPathLock.ExitWriteLock(); } WriteableBitmap writeBitmap = input.bitmap; IconSize size = input.iconsize; try { if (input.roll != currentRoll) { Debug.Write(entry.Name + " discarded."); return; } Bitmap origBitmap = new Bitmap(fileName); Bitmap inputBitmap = resizeImage(origBitmap, IconSizeToSize(size), 5); BitmapSource inputBitmapSource = loadBitmap(inputBitmap); origBitmap.Dispose(); inputBitmap.Dispose(); copyBitmap(inputBitmapSource, writeBitmap, true, 0); } catch (Exception ex) { Debug.WriteLine("PollThumbnailCallback " + ex.Message + "(" + fileName + ")"); } }