/// <summary> /// Determines if the item should be processed. /// </summary> /// <param name="argument">The event argument.</param> /// <returns>true if the item should be processed; otherwise false.</returns> private void CanContinueProcessing(object argument) { CanContinueProcessingEventArgs arg = argument as CanContinueProcessingEventArgs; CacheRequest request = arg.Request; bool canProcess = true; // Is it in the edit cache? if (canProcess && editCache.ContainsKey(request.Guid)) { canProcess = false; } // Is it already cached? if (canProcess && (request.RequestType == RequestType.Thumbnail)) { thumbCache.TryGetValue(request.Guid, out CacheItem existing); if (existing != null && existing.Size == request.Size && existing.UseEmbeddedThumbnails == request.UseEmbeddedThumbnails && existing.AutoRotate == request.AutoRotate && existing.UseWIC == request.UseWIC) { canProcess = false; } // Is it outside the visible area? if (canProcess && (CacheMode == CacheMode.OnDemand) && mImageListView != null && !mImageListView.IsItemVisible(request.Guid)) { canProcess = false; } } else if (canProcess && (request.RequestType == RequestType.Gallery)) { CacheItem existing = galleryItem; if (existing != null && existing.Guid == request.Guid && existing.Size == request.Size && existing.UseEmbeddedThumbnails == request.UseEmbeddedThumbnails && existing.AutoRotate == request.AutoRotate && existing.UseWIC == request.UseWIC) { canProcess = false; } } else if (canProcess && (request.RequestType == RequestType.Renderer)) { CacheItem existing = rendererItem; if (existing != null && existing.Guid == request.Guid && existing.Size == request.Size && existing.UseEmbeddedThumbnails == request.UseEmbeddedThumbnails && existing.AutoRotate == request.AutoRotate && existing.UseWIC == request.UseWIC) { canProcess = false; } } arg.ContinueProcessing = canProcess; }
/// <summary> /// Handles the RunWorkerCompleted event of the queued background worker. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Manina.Windows.Forms.QueuedWorkerCompletedEventArgs"/> /// instance containing the event data.</param> void bw_RunWorkerCompleted(object sender, QueuedWorkerCompletedEventArgs e) { CacheRequest request = e.UserState as CacheRequest; // We are done processing processing.Remove(request.Guid); // Do not process the result if the cache operation // was cancelled. if (e.Cancelled) { return; } // Get result Utility.Tuple <ColumnType, string, object>[] details = (Utility.Tuple <ColumnType, string, object>[])e.Result; if (details != null && mImageListView != null) { mImageListView.UpdateItemDetailsInternal(request.Guid, details); } // Refresh the control lazily if (mImageListView != null && mImageListView.IsItemVisible(request.Guid)) { mImageListView.Refresh(false, true); } // Raise the CacheError event if (e.Error != null && mImageListView != null) { mImageListView.OnCacheErrorInternal(request.Guid, e.Error, CacheThread.Details); } }
/// <summary> /// Sets the sub item item text corresponding to the custom column with the given index. /// </summary> /// <param name="index">Index of the custom column.</param> /// <param name="text">New sub item text</param> public void SetSubItemText(int index, string text) { int i = 0; Guid found = Guid.Empty; foreach (Guid guid in subItems.Keys) { if (i == index) { found = guid; break; } i++; } if (found != Guid.Empty) { subItems[found] = text; if (mImageListView != null && mImageListView.IsItemVisible(mGuid)) { mImageListView.Refresh(); } } else { throw new IndexOutOfRangeException(); } }