/// <summary> /// Adds a new tabbed thumbnail to the taskbar. /// </summary> /// <param name="preview">Thumbnail preview for a specific window handle or control. The preview /// object can be initialized with specific properties for the title, bitmap, and tooltip.</param> /// <exception cref="System.ArgumentException">If the tabbed thumbnail has already been added</exception> public void AddThumbnailPreview(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException(nameof(preview)); } // UI Element has a windowHandle of zero. if (preview.WindowHandle == IntPtr.Zero) { if (_tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) { throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewAdded, nameof(preview)); } _tabbedThumbnailCacheWPF.Add(preview.WindowsControl, preview); } else { // Regular control with a valid handle if (_tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewAdded, nameof(preview)); } _tabbedThumbnailCache.Add(preview.WindowHandle, preview); } TaskbarWindowManager.AddTabbedThumbnail(preview); preview.InvalidatePreview(); // Note: Why this here? }
/// <summary> /// Adds a new tabbed thumbnail to the taskbar. /// </summary> /// <param name="preview">Thumbnail preview for a specific window handle or control. The preview /// object can be initialized with specific properties for the title, bitmap, and tooltip.</param> /// <exception cref="System.ArgumentException">If the tabbed thumbnail has already been added</exception> public void AddThumbnailPreview(TabbedThumbnail preview) { if (preview.WindowHandle == IntPtr.Zero) // it's most likely a UI Element { if (tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) { throw new ArgumentException("This preview has already been added"); } } else { // Regular control with a valid handle if (tabbedThumbnailList.ContainsKey(preview.WindowHandle)) { throw new ArgumentException("This preview has already been added"); } } TaskbarWindowManager.Instance.AddTabbedThumbnail(preview); // Add the preview and window manager to our cache // Probably a UIElement control if (preview.WindowHandle == IntPtr.Zero) { tabbedThumbnailListWPF.Add(preview.WindowsControl, preview); } else { tabbedThumbnailList.Add(preview.WindowHandle, preview); } preview.InvalidatePreview(); }
/// <summary> /// Adds a new tabbed thumbnail to the taskbar. /// </summary> /// <param name="preview">Thumbnail preview for a specific window handle or control. The preview /// object can be initialized with specific properties for the title, bitmap, and tooltip.</param> /// <exception cref="System.ArgumentException">If the tabbed thumbnail has already been added</exception> public void AddThumbnailPreview(TabbedThumbnail preview) { if (preview.WindowHandle == IntPtr.Zero) // it's most likely a UI Element { if (tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) throw new ArgumentException("This preview has already been added"); } else { // Regular control with a valid handle if (tabbedThumbnailList.ContainsKey(preview.WindowHandle)) throw new ArgumentException("This preview has already been added"); } TaskbarWindowManager.Instance.AddTabbedThumbnail(preview); // Add the preview and window manager to our cache // Probably a UIElement control if (preview.WindowHandle == IntPtr.Zero) tabbedThumbnailListWPF.Add(preview.WindowsControl, preview); else tabbedThumbnailList.Add(preview.WindowHandle, preview); preview.InvalidatePreview(); }
/// <summary> /// Adds a new tabbed thumbnail to the taskbar. /// </summary> /// <param name="preview">Thumbnail preview for a specific window handle or control. The preview /// object can be initialized with specific properties for the title, bitmap, and tooltip.</param> /// <exception cref="System.ArgumentException">If the tabbed thumbnail has already been added</exception> public void AddThumbnailPreview(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } // UI Element has a windowHandle of zero. if (preview.WindowHandle == IntPtr.Zero) { // if (_tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) // { // throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewAdded, "preview"); // } // _tabbedThumbnailCacheWPF.Add(preview.WindowsControl, preview); } else { // Regular control with a valid handle if (_tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewAdded, "preview"); } _tabbedThumbnailCache.Add(preview.WindowHandle, preview); } TaskbarWindowManager.AddTabbedThumbnail(preview); preview.InvalidatePreview(); // Note: Why this here? }
private static void CreateThumbnailBitmap(TabbedThumbnail thumbnail, Control targetControl) { using (Bitmap bmp = new Bitmap(targetControl.Width, targetControl.Height)) { targetControl.DrawToBitmap(bmp, targetControl.ClientRectangle); thumbnail.SetImage(bmp); } thumbnail.InvalidatePreview(); }