/// <summary> /// Override the thumbnail and peek bitmap. /// By providing this bitmap manually, Thumbnail Window manager will provide the /// Desktop Window Manager (DWM) this bitmap instead of rendering one automatically. /// Use this property to update the bitmap whenever the control is updated and the user /// needs to be shown a new thumbnail on the taskbar preview (or aero peek). /// </summary> /// <param name="hBitmap">A bitmap handle for the image to use. /// <para>When the TabbedThumbnail is finalized, this class will delete the provided hBitmap.</para></param> /// <remarks> /// If the bitmap doesn't have the right dimensions, the DWM may scale it or not /// render certain areas as appropriate - it is the user's responsibility /// to render a bitmap with the proper dimensions. /// </remarks> internal void SetImage(IntPtr hBitmap) { // Before we set a new bitmap, dispose the old one if (CurrentHBitmap != IntPtr.Zero) { ShellNativeMethods.DeleteObject(CurrentHBitmap); } // Set the new bitmap CurrentHBitmap = hBitmap; // Let DWM know to invalidate its cached thumbnail/preview and ask us for a new one TaskbarWindowManager.InvalidatePreview(TaskbarWindow); }
// /// <summary> // /// Determines whether the given control has been added to the taskbar's tabbed thumbnail list. // /// </summary> // /// <param name="control">The preview to locate on the taskbar's tabbed thumbnail list</param> // /// <returns>true if the tab is already added on the taskbar; otherwise, false.</returns> // public bool IsThumbnailPreviewAdded(UIElement control) // { // if (control == null) // { // throw new ArgumentNullException("control"); // } // // return _tabbedThumbnailCacheWPF.ContainsKey(control); // } /// <summary> /// Invalidates all the tabbed thumbnails. This will force the Desktop Window Manager /// to not use the cached thumbnail or preview or aero peek and request a new one next time. /// </summary> /// <remarks>This method should not be called frequently. /// Doing so can lead to poor performance as new bitmaps are created and retrieved.</remarks> public void InvalidateThumbnails() { // Invalidate all the previews currently in our cache. // This will ensure we get updated bitmaps next time foreach (TabbedThumbnail thumbnail in _tabbedThumbnailCache.Values) { TaskbarWindowManager.InvalidatePreview(thumbnail.TaskbarWindow); thumbnail.SetImage(IntPtr.Zero); // TODO: Investigate this, and why it needs to be called. } // foreach (TabbedThumbnail thumbnail in _tabbedThumbnailCacheWPF.Values) // { // TaskbarWindowManager.InvalidatePreview(thumbnail.TaskbarWindow); // thumbnail.SetImage(IntPtr.Zero); // } }