/// <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? }
internal TabbedThumbnailProxyWindow(TabbedThumbnail preview) { TabbedThumbnail = preview; if (preview.WindowHandle != IntPtr.Zero) { proxyingFor = preview.WindowHandle; Size = new System.Drawing.Size(1, 1); // Try to get the window text so we can use it on the tabbed thumbnail as well StringBuilder text = new StringBuilder(256); TabbedThumbnailNativeMethods.GetWindowText(proxyingFor, text, text.Capacity); Text = text.ToString(); // If we get a valid title from the GetWindowText method, // and also if the user hasn't set any title on the preview object, // then update the preview's title with what we get from GetWindowTitle if(!string.IsNullOrEmpty(Text) && string.IsNullOrEmpty(preview.Title)) preview.Title = Text; } else if (preview.WindowsControl != null) { proxyingFor = IntPtr.Zero; WindowsControl = preview.WindowsControl; Size = new System.Drawing.Size(1, 1); // Since we can't get the text/caption for a UIElement, not setting this.Text here. } }
internal TabbedThumbnailProxyWindow(TabbedThumbnail preview) { TabbedThumbnail = preview; if (preview.WindowHandle != IntPtr.Zero) { proxyingFor = preview.WindowHandle; Size = new System.Drawing.Size(1, 1); // Try to get the window text so we can use it on the tabbed thumbnail as well StringBuilder text = new StringBuilder(256); TabbedThumbnailNativeMethods.GetWindowText(proxyingFor, text, text.Capacity); Text = text.ToString(); // If we get a valid title from the GetWindowText method, // and also if the user hasn't set any title on the preview object, // then update the preview's title with what we get from GetWindowTitle if (!string.IsNullOrEmpty(Text) && string.IsNullOrEmpty(preview.Title)) { preview.Title = Text; } } else if (preview.WindowsControl != null) { proxyingFor = IntPtr.Zero; WindowsControl = preview.WindowsControl; Size = new System.Drawing.Size(1, 1); // Since we can't get the text/caption for a UIElement, not setting this.Text here. } }
public void Dispose(bool disposing) { if (disposing) { // Dispose managed resources if (tabbedThumbnailPreview != null) { tabbedThumbnailPreview.Dispose(); } tabbedThumbnailPreview = null; if (ThumbnailToolbarProxyWindow != null) { ThumbnailToolbarProxyWindow.Dispose(); } ThumbnailToolbarProxyWindow = null; if (TabbedThumbnailProxyWindow != null) { TabbedThumbnailProxyWindow.Dispose(); } TabbedThumbnailProxyWindow = null; // Don't dispose the thumbnail buttons // as they might be used in another window. // Setting them to null will indicate we don't need use anymore. thumbnailButtons = null; } }
/// <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> /// Sets the given tabbed thumbnail preview object as being active on the taskbar tabbed thumbnails list. /// Call this method to keep the application and the taskbar in sync as to which window/control /// is currently active (or selected, in the case of tabbed application). /// </summary> /// <param name="preview">TabbedThumbnail for the specific control/indow that is currently active in the application</param> /// <exception cref="System.ArgumentException">If the control/window is not yet added to the tabbed thumbnails list</exception> public void SetActiveTab(TabbedThumbnail preview) { if (preview.WindowHandle != IntPtr.Zero) { if (tabbedThumbnailList.ContainsKey(preview.WindowHandle)) { TaskbarWindowManager.Instance.SetActiveTab(tabbedThumbnailList[preview.WindowHandle].TaskbarWindow); } else { throw new ArgumentException("The given preview has not been added to the taskbar."); } } else if (preview.WindowsControl != null) { if (tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) { TaskbarWindowManager.Instance.SetActiveTab(tabbedThumbnailListWPF[preview.WindowsControl].TaskbarWindow); } else { throw new ArgumentException("The given preview has not been added to the taskbar."); } } }
/// <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(); }
internal static void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = null; // get the TaskbarWindow for UIElement/WindowHandle respectfully. if (preview.WindowHandle == IntPtr.Zero) { taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); } else { taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); } //create taskbar, or set its TabbedThumbnail if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); _taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) { taskbarWindow.TabbedThumbnail = preview; } // Listen for Title changes preview.TitleChanged += new EventHandler(thumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(thumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr windowHandle = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarList.Instance.RegisterTab(windowHandle, preview.ParentWindowHandle); TaskbarList.Instance.SetTabOrder(windowHandle, IntPtr.Zero); TaskbarList.Instance.SetTabActive(windowHandle, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when running with admin TabbedThumbnailNativeMethods.ChangeWindowMessageFilter( TabbedThumbnailNativeMethods.WmDwmSendIconicThumbnail, TabbedThumbnailNativeMethods.MsgfltAdd); TabbedThumbnailNativeMethods.ChangeWindowMessageFilter( TabbedThumbnailNativeMethods.WmDwmSendIconicLivePreviewBitmap, TabbedThumbnailNativeMethods.MsgfltAdd); // BUG: There should be somewhere to disable CustomWindowPreview. I didn't find it. TabbedThumbnailNativeMethods.EnableCustomWindowPreview(windowHandle, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. thumbnailPreview_TitleChanged(preview, EventArgs.Empty); thumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }
public void InitalizeDWM() { TabbedThumbnail thumbnail = new TabbedThumbnail(this.Handle, Editor); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(thumbnail); thumbnail.SetImage(new Bitmap(Editor.Image)); thumbnail.DisplayFrameAroundBitmap = false; thumbnail.Title = "Paint Bucket"; thumbnail.SetWindowIcon(this.Icon); }
internal void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = null; if (preview.WindowHandle != IntPtr.Zero) { taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); } else { taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); } if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) { taskbarWindow.TabbedThumbnail = preview; } // preview.TaskbarWindow = taskbarWindow; // Listen for Title changes preview.TitleChanged += new EventHandler(thumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(thumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr hwnd = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarManager.Instance.TaskbarList.RegisterTab(hwnd, preview.ParentWindowHandle); TaskbarManager.Instance.TaskbarList.SetTabOrder(hwnd, IntPtr.Zero); TaskbarManager.Instance.TaskbarList.SetTabActive(hwnd, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when // running with admin TabbedThumbnailNativeMethods.ChangeWindowMessageFilter(TabbedThumbnailNativeMethods.WM_DWMSENDICONICTHUMBNAIL, TabbedThumbnailNativeMethods.MSGFLT_ADD); TabbedThumbnailNativeMethods.ChangeWindowMessageFilter(TabbedThumbnailNativeMethods.WM_DWMSENDICONICLIVEPREVIEWBITMAP, TabbedThumbnailNativeMethods.MSGFLT_ADD); TabbedThumbnailNativeMethods.EnableCustomWindowPreview(hwnd, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. thumbnailPreview_TitleChanged(preview, EventArgs.Empty); thumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }
internal void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = null; if (preview.WindowHandle != IntPtr.Zero) taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); else taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) taskbarWindow.TabbedThumbnail = preview; // preview.TaskbarWindow = taskbarWindow; // Listen for Title changes preview.TitleChanged += new EventHandler(thumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(thumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr hwnd = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarManager.Instance.TaskbarList.RegisterTab(hwnd, preview.ParentWindowHandle); TaskbarManager.Instance.TaskbarList.SetTabOrder(hwnd, IntPtr.Zero); TaskbarManager.Instance.TaskbarList.SetTabActive(hwnd, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when // running with admin TabbedThumbnailNativeMethods.ChangeWindowMessageFilter(TabbedThumbnailNativeMethods.WM_DWMSENDICONICTHUMBNAIL, TabbedThumbnailNativeMethods.MSGFLT_ADD); TabbedThumbnailNativeMethods.ChangeWindowMessageFilter(TabbedThumbnailNativeMethods.WM_DWMSENDICONICLIVEPREVIEWBITMAP, TabbedThumbnailNativeMethods.MSGFLT_ADD); TabbedThumbnailNativeMethods.EnableCustomWindowPreview(hwnd, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. thumbnailPreview_TitleChanged(preview, EventArgs.Empty); thumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }
internal TabbedThumbnailProxyWindow(TabbedThumbnail preview) { TabbedThumbnail = preview; Size = new System.Drawing.Size(1, 1); if (!string.IsNullOrEmpty(preview.Title)) { Text = preview.Title; } if (preview.WindowsControl != null) { WindowsControl = preview.WindowsControl; } }
protected override void Dispose(bool disposing) { if (disposing) { // Dispose managed resources if (TabbedThumbnail != null) { TabbedThumbnail.Dispose(); } TabbedThumbnail = null; WindowsControl = null; } base.Dispose(disposing); }
// /// <summary> // /// Gets the TabbedThumbnail object associated with the given WPF Window // /// </summary> // /// <param name="windowsControl">WPF Control (UIElement) for which the preview object is requested</param> // /// <returns>TabbedThumbnail associated with the given WPF Window</returns> // public TabbedThumbnail GetThumbnailPreview(UIElement windowsControl) // { // if (windowsControl == null) // { // throw new ArgumentNullException("windowsControl"); // } // // TabbedThumbnail thumbnail; // return _tabbedThumbnailCacheWPF.TryGetValue(windowsControl, out thumbnail) ? thumbnail : null; // } /// <summary> /// Remove the tabbed thumbnail from the taskbar. /// </summary> /// <param name="preview">TabbedThumbnail associated with the control/window that /// is to be removed from the taskbar</param> public void RemoveThumbnailPreview(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } if (_tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { RemoveThumbnailPreview(preview.WindowHandle); } // else if (_tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) // { // RemoveThumbnailPreview(preview.WindowsControl); // } }
/// <summary> /// Remove the tabbed thumbnail from the taskbar. /// </summary> /// <param name="preview">TabbedThumbnail associated with the control/window that /// is to be removed from the taskbar</param> public void RemoveThumbnailPreview(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } if (tabbedThumbnailList.ContainsKey(preview.WindowHandle)) { RemoveThumbnailPreview(preview.WindowHandle); } else if (tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) { RemoveThumbnailPreview(preview.WindowsControl); } }
internal TaskbarWindow(TabbedThumbnail preview) { if (preview == null) throw new ArgumentException("preview"); // Create our proxy window TabbedThumbnailProxyWindow = new TabbedThumbnailProxyWindow(preview); // set our current state EnableThumbnailToolbars = false; EnableTabbedThumbnails = true; // UserWindowHandle = preview.WindowHandle; WindowsControl = preview.WindowsControl; TabbedThumbnail = preview; }
public TaskbarWindow(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } // Create our proxy window // Bug: This is only called in this constructor. Which will cause the property // to fail if TaskbarWindow is initialized from a different constructor. TabbedThumbnailProxyWindow = new TabbedThumbnailProxyWindow(preview); // set our current state EnableThumbnailToolbars = false; EnableTabbedThumbnails = true; // copy values UserWindowHandle = preview.WindowHandle; WindowsControl = preview.WindowsControl; TabbedThumbnail = preview; }
// /// <summary> // /// Sets the given WPF window as being active on the taskbar tabbed thumbnails list. // /// Call this method to keep the application and the taskbar in sync as to which window/control // /// is currently active (or selected, in the case of tabbed application). // /// </summary> // /// <param name="windowsControl">WPF control that is currently active in the application</param> // /// <exception cref="System.ArgumentException">If the control/window is not yet added to the tabbed thumbnails list</exception> // public void SetActiveTab(UIElement windowsControl) // { // if (windowsControl == null) // { // throw new ArgumentNullException("windowsControl"); // } // // if (!_tabbedThumbnailCacheWPF.ContainsKey(windowsControl)) // { // throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewNotAdded, "windowsControl"); // } // TaskbarWindowManager.SetActiveTab(_tabbedThumbnailCacheWPF[windowsControl].TaskbarWindow); // // } /// <summary> /// Determines whether the given preview has been added to the taskbar's tabbed thumbnail list. /// </summary> /// <param name="preview">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(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } if (preview.WindowHandle != IntPtr.Zero && _tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { return(true); } // else if (preview.WindowsControl != null && _tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) // { // return true; // } return(false); }
/// <summary> /// Moves an existing thumbnail to a new position in the application's group. /// </summary> /// <param name="previewToChange">Preview for the window whose order is being changed. /// This value is required, must already be added via AddThumbnailPreview method, and cannot be null.</param> /// <param name="insertBeforePreview">The preview of the tab window whose thumbnail that previewToChange is inserted to the left of. /// This preview must already be added via AddThumbnailPreview. If this value is null, the previewToChange tab is added to the end of the list. /// </param> public static void SetTabOrder(TabbedThumbnail previewToChange, TabbedThumbnail insertBeforePreview) { if (previewToChange == null) { throw new ArgumentNullException("previewToChange"); } IntPtr handleToReorder = previewToChange.TaskbarWindow.WindowToTellTaskbarAbout; if (insertBeforePreview == null) { TaskbarList.Instance.SetTabOrder(handleToReorder, IntPtr.Zero); } else { IntPtr handleBefore = insertBeforePreview.TaskbarWindow.WindowToTellTaskbarAbout; TaskbarList.Instance.SetTabOrder(handleToReorder, handleBefore); } }
internal TaskbarWindow(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentException("preview"); } // Create our proxy window TabbedThumbnailProxyWindow = new TabbedThumbnailProxyWindow(preview); // set our current state EnableThumbnailToolbars = false; EnableTabbedThumbnails = true; // UserWindowHandle = preview.WindowHandle; WindowsControl = preview.WindowsControl; TabbedThumbnail = preview; }
/// <summary> /// Determines whether the given preview has been added to the taskbar's tabbed thumbnail list. /// </summary> /// <param name="preview">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(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } if (preview.WindowHandle != IntPtr.Zero && tabbedThumbnailList.ContainsKey(preview.WindowHandle)) { return(true); } else if (preview.WindowsControl != null && tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) { return(true); } else { return(false); } }
// internal TaskbarWindow(System.Windows.UIElement windowsControl, params ThumbnailToolBarButton[] buttons) // { // if (windowsControl == null) // { // throw new ArgumentNullException("windowsControl"); // } // // if (buttons == null || buttons.Length == 0) // { // throw new ArgumentException(LocalizedMessages.TaskbarWindowEmptyButtonArray, "buttons"); // } // // // Create our proxy window // ThumbnailToolbarProxyWindow = new ThumbnailToolbarProxyWindow(windowsControl, buttons); // ThumbnailToolbarProxyWindow.TaskbarWindow = this; // // // Set our current state // EnableThumbnailToolbars = true; // EnableTabbedThumbnails = false; // // this.ThumbnailButtons = buttons; // UserWindowHandle = IntPtr.Zero; // WindowsControl = windowsControl; // } internal TaskbarWindow(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } // Create our proxy window // Bug: This is only called in this constructor. Which will cause the property // to fail if TaskbarWindow is initialized from a different constructor. TabbedThumbnailProxyWindow = new TabbedThumbnailProxyWindow(preview); // set our current state EnableThumbnailToolbars = false; EnableTabbedThumbnails = true; // copy values UserWindowHandle = preview.WindowHandle; //WindowsControl = preview.WindowsControl; TabbedThumbnail = preview; }
private static void thumbnailPreview_TooltipChanged(object sender, EventArgs e) { TabbedThumbnail preview = sender as TabbedThumbnail; TaskbarWindow taskbarWindow = null; if (preview.WindowHandle == IntPtr.Zero) { taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); } else { taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); } // Update the proxy window for the tabbed thumbnail if (taskbarWindow != null) { TaskbarList.Instance.SetThumbnailTooltip(taskbarWindow.WindowToTellTaskbarAbout, preview.Tooltip); } }
private static void thumbnailPreview_TitleChanged(object sender, EventArgs e) { TabbedThumbnail preview = sender as TabbedThumbnail; TaskbarWindow taskbarWindow = null; if (preview.WindowHandle == IntPtr.Zero) { taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); } else { taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); } // Update the proxy window for the tabbed thumbnail if (taskbarWindow != null) { taskbarWindow.SetTitle(preview.Title); } }
public void Tabify(Control targetControl) { if (TaskbarManager.Instance.TabbedThumbnail.IsThumbnailPreviewAdded(targetControl)) { return; } var thumbnail = new TabbedThumbnail(_form.Handle, targetControl) { Title = targetControl.Text, Tooltip = targetControl.Text }; thumbnail.TabbedThumbnailActivated += (sender, e) => OnThumbnailActivated(targetControl); thumbnail.TabbedThumbnailClosed += (sender, e) => OnThumbnailClosed(targetControl); thumbnail.TabbedThumbnailBitmapRequested += (sender, e) => CreateThumbnailBitmap(thumbnail, targetControl); thumbnail.SetWindowIcon(_form.Icon); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(thumbnail); SetActiveTab(targetControl); CreateThumbnailBitmap(thumbnail, targetControl); }
// /// <summary> // /// Remove the tabbed thumbnail from the taskbar. // /// </summary> // /// <param name="windowsControl">TabbedThumbnail associated with the WPF Control (UIElement) that // /// is to be removed from the taskbar</param> // public void RemoveThumbnailPreview(UIElement windowsControl) // { // if (windowsControl == null) { throw new ArgumentNullException("windowsControl"); } // // if (!_tabbedThumbnailCacheWPF.ContainsKey(windowsControl)) // { // throw new ArgumentException(LocalizedMessages.ThumbnailManagerControlNotAdded, "windowsControl"); // } // // TaskbarWindowManager.UnregisterTab(_tabbedThumbnailCacheWPF[windowsControl].TaskbarWindow); // // _tabbedThumbnailCacheWPF.Remove(windowsControl); // // TaskbarWindow taskbarWindow = TaskbarWindowManager.GetTaskbarWindow(windowsControl, TaskbarProxyWindowType.TabbedThumbnail); // // if (taskbarWindow != null) // { // if (TaskbarWindowManager._taskbarWindowList.Contains(taskbarWindow)) // { // TaskbarWindowManager._taskbarWindowList.Remove(taskbarWindow); // } // taskbarWindow.Dispose(); // taskbarWindow = null; // } // } /// <summary> /// Sets the given tabbed thumbnail preview object as being active on the taskbar tabbed thumbnails list. /// Call this method to keep the application and the taskbar in sync as to which window/control /// is currently active (or selected, in the case of tabbed application). /// </summary> /// <param name="preview">TabbedThumbnail for the specific control/indow that is currently active in the application</param> /// <exception cref="System.ArgumentException">If the control/window is not yet added to the tabbed thumbnails list</exception> public void SetActiveTab(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException("preview"); } if (preview.WindowHandle != IntPtr.Zero) { if (!_tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewNotAdded, "preview"); } TaskbarWindowManager.SetActiveTab(_tabbedThumbnailCache[preview.WindowHandle].TaskbarWindow); } // else if (preview.WindowsControl != null) // { // if (!_tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) // { // throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewNotAdded, "preview"); // } // TaskbarWindowManager.SetActiveTab(_tabbedThumbnailCacheWPF[preview.WindowsControl].TaskbarWindow); // } }
/// <summary> /// Sets the given tabbed thumbnail preview object as being active on the taskbar tabbed thumbnails list. /// Call this method to keep the application and the taskbar in sync as to which window/control /// is currently active (or selected, in the case of tabbed application). /// </summary> /// <param name="preview">TabbedThumbnail for the specific control/indow that is currently active in the application</param> /// <exception cref="System.ArgumentException">If the control/window is not yet added to the tabbed thumbnails list</exception> public void SetActiveTab(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException(nameof(preview)); } if (preview.WindowHandle != IntPtr.Zero) { if (!_tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewNotAdded, nameof(preview)); } TaskbarWindowManager.SetActiveTab(_tabbedThumbnailCache[preview.WindowHandle].TaskbarWindow); } else if (preview.WindowsControl != null) { if (!_tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) { throw new ArgumentException(LocalizedMessages.ThumbnailManagerPreviewNotAdded, nameof(preview)); } TaskbarWindowManager.SetActiveTab(_tabbedThumbnailCacheWPF[preview.WindowsControl].TaskbarWindow); } }
/// <summary> /// Remove the tabbed thumbnail from the taskbar. /// </summary> /// <param name="preview">TabbedThumbnail associated with the control/window that /// is to be removed from the taskbar</param> public void RemoveThumbnailPreview(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException(nameof(preview)); } if (_tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { RemoveThumbnailPreview(preview.WindowHandle); } else if (_tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) { RemoveThumbnailPreview(preview.WindowsControl); } }
protected void Connect(RDCConnection connection) { _history.AddToHistory(connection); RDCWindow sessionWindow = new RDCWindow(_password); _addingWindow = true; Tabs.Add(new TitleBarTab(this) { Content = sessionWindow }); _addingWindow = false; sessionWindow.FormClosing += sessionWindow_FormClosing; sessionWindow.Connected += sessionWindow_Connected; sessionWindow.Connect(connection); TabbedThumbnail preview = new TabbedThumbnail(Handle, sessionWindow); preview.Title = sessionWindow.Text; preview.Tooltip = sessionWindow.Text; preview.SetWindowIcon(sessionWindow.Icon); preview.TabbedThumbnailActivated += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailActivated); preview.TabbedThumbnailClosed += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailClosed); preview.TabbedThumbnailBitmapRequested += new EventHandler<TabbedThumbnailBitmapRequestedEventArgs>(preview_TabbedThumbnailBitmapRequested); preview.PeekOffset = new Vector(sessionWindow.Location.X, sessionWindow.Location.Y); for (Control currentControl = sessionWindow.Parent; currentControl.Parent != null; currentControl = currentControl.Parent) preview.PeekOffset += new Vector(currentControl.Location.X, currentControl.Location.Y); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview); TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(preview); if (_recentConnections.FirstOrDefault((HistoryWindow.HistoricalConnection c) => c.Guid == connection.Guid) == null) { _recentCategory.AddJumpListItems(new JumpListLink(Application.ExecutablePath, sessionWindow.Text) { Arguments = "/openHistory:" + connection.Guid.ToString(), IconReference = new IconReference(Application.ExecutablePath, 0) }); _jumpList.Refresh(); _recentConnections.Enqueue(_history.Connections.First((HistoryWindow.HistoricalConnection c) => c.Guid == connection.Guid)); if (_recentConnections.Count > _jumpList.MaxSlotsInList) _recentConnections.Dequeue(); } }
//The following method is part of the lab. Create a thumbnail and register for the event so that //you can render its bitmap on demand. Use an offset from the main window to the black image. private void createThumbnail(IntPtr displayHandle) { if (displayHandle != IntPtr.Zero && windowsTaskbar.TabbedThumbnail.GetThumbnailPreview(displayHandle) == null) { TabbedThumbnail preview = new TabbedThumbnail((IntPtr)mcRef.GetWindowHandle(), displayHandle); windowsTaskbar.TabbedThumbnail.AddThumbnailPreview(preview); windowsTaskbar.TabbedThumbnail.SetActiveTab(preview); } }
internal void SetupThumbAndButtons() { _thumbForm = new ThumbForm(this); _thumb = new TabbedThumbnail(this.Handle, _thumbForm); _thumb.Title = _gmailClient.Username; _thumb.SetWindowIcon((Icon)this.Icon.Clone()); _thumbForm.Show(); _thumbForm.Render(); _prevButton = new ThumbnailToolBarButton(Properties.Resources.Previous, "Previous") { Enabled = false }; _openButton = new ThumbnailToolBarButton(Properties.Resources.Open, "Open") { Enabled = false }; _nextButton = new ThumbnailToolBarButton(Properties.Resources.Next, "Next") { Enabled = false }; _prevButton.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(PrevButtonClicked); _openButton.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(OpenButtonClicked); _nextButton.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(NextButtonClicked); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(_thumb); TaskbarManager.Instance.ThumbnailToolBars.AddButtons(_thumbForm.Handle, _prevButton, _openButton, _nextButton); }
private void CreateInstances() { for (int i = 0; i < _Config.Accounts.Count; i++) { Account account = _Config.Accounts[i]; if (_Instances.ContainsKey(account.FullAddress)) { continue; } Notifier notifier = new Notifier(i); notifier.FormClosed += _Notifier_FormClosed; notifier.CheckMailFinished += _Notifier_CheckFinished; _Instances.Add(account.FullAddress, notifier); notifier.Show(this); TabbedThumbnail preview = new TabbedThumbnail(base.Handle, notifier.Handle); preview.TabbedThumbnailClosed += _Preview_TabbedThumbnailClosed; preview.SetWindowIcon(Utilities.ResourceHelper.GetIcon("gmail-classic.ico")); preview.Tooltip = String.Empty; preview.Title = account.FullAddress; _TaskbarManager.TabbedThumbnail.AddThumbnailPreview(preview); } if (_Config.Accounts.Count > 0) { Account account = _Config.Accounts[0]; _TaskbarManager.TabbedThumbnail.SetActiveTab(_Instances[account.FullAddress].Handle); } }
/// <summary> /// Creates a Event Args for a TabbedThumbnailClosing event. /// </summary> /// <param name="windowHandle">Window handle for the control/window related to the event</param> /// <param name="preview">TabbedThumbnail related to this event</param> public TabbedThumbnailClosingEventArgs(IntPtr windowHandle, TabbedThumbnail preview) : base(windowHandle, preview) { }
public void Dispose(bool disposing) { if (disposing) { // Dispose managed resources if (_tabbedThumbnailPreview != null) { _tabbedThumbnailPreview.Dispose(); } _tabbedThumbnailPreview = null; if (ThumbnailToolbarProxyWindow != null) { ThumbnailToolbarProxyWindow.Dispose(); } ThumbnailToolbarProxyWindow = null; if (TabbedThumbnailProxyWindow != null) { TabbedThumbnailProxyWindow.Dispose(); } TabbedThumbnailProxyWindow = null; // Don't dispose the thumbnail buttons as they might be used in another window. // Setting them to null will indicate we don't need use anymore. _thumbnailButtons = null; } }
/// <summary> /// Sets the given tabbed thumbnail preview object as being active on the taskbar tabbed thumbnails list. /// Call this method to keep the application and the taskbar in sync as to which window/control /// is currently active (or selected, in the case of tabbed application). /// </summary> /// <param name="preview">TabbedThumbnail for the specific control/indow that is currently active in the application</param> /// <exception cref="System.ArgumentException">If the control/window is not yet added to the tabbed thumbnails list</exception> public void SetActiveTab(TabbedThumbnail preview) { if (preview.WindowHandle != IntPtr.Zero) { if (tabbedThumbnailList.ContainsKey(preview.WindowHandle)) TaskbarWindowManager.Instance.SetActiveTab(tabbedThumbnailList[preview.WindowHandle].TaskbarWindow); else throw new ArgumentException("The given preview has not been added to the taskbar."); } else if (preview.WindowsControl != null) { if (tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) TaskbarWindowManager.Instance.SetActiveTab(tabbedThumbnailListWPF[preview.WindowsControl].TaskbarWindow); else throw new ArgumentException("The given preview has not been added to the taskbar."); } }
/// <summary> /// Determines whether the given preview has been added to the taskbar's tabbed thumbnail list. /// </summary> /// <param name="preview">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(TabbedThumbnail preview) { if (preview == null) throw new ArgumentNullException("preview"); if (preview.WindowHandle != IntPtr.Zero && tabbedThumbnailList.ContainsKey(preview.WindowHandle)) return true; else if (preview.WindowsControl != null && tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) return true; else return false; }
/// <summary> /// Create a new tab, add a webbrowser and navigate the given address/URL /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void button1_Click(object sender, System.EventArgs args) { TabPage newTab = new TabPage(comboBox1.Text); tabControl1.TabPages.Add(newTab); WebBrowser wb = new WebBrowser(); wb.DocumentTitleChanged += new EventHandler(wb_DocumentTitleChanged); wb.Navigated += new WebBrowserNavigatedEventHandler(wb_Navigated); wb.ProgressChanged += new WebBrowserProgressChangedEventHandler(wb_ProgressChanged); wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted); wb.Dock = DockStyle.Fill; wb.Navigate(comboBox1.Text); newTab.Controls.Add(wb); // Add thumbnail toolbar buttons TaskbarManager.Instance.ThumbnailToolBars.AddButtons(newTab.Handle, thumbButtonBack, thumbButtonForward, thumbButtonRefresh); // Add a new preview TabbedThumbnail preview = new TabbedThumbnail(this.Handle, newTab.Handle); // Event handlers for this preview preview.TabbedThumbnailActivated += preview_TabbedThumbnailActivated; preview.TabbedThumbnailClosed += preview_TabbedThumbnailClosed; preview.TabbedThumbnailMaximized += preview_TabbedThumbnailMaximized; preview.TabbedThumbnailMinimized += preview_TabbedThumbnailMinimized; TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview); // Select the tab in the application UI as well as taskbar tabbed thumbnail list tabControl1.SelectedTab = newTab; TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(tabControl1.SelectedTab); // set false for this new webbrowser scrollEventAdded = false; // button2.Enabled = true; }
internal static void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = preview.WindowHandle == IntPtr.Zero ? GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail) : GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); // get the TaskbarWindow for UIElement/WindowHandle respectfully. //create taskbar, or set its TabbedThumbnail if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); _taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) taskbarWindow.TabbedThumbnail = preview; // Listen for Title changes preview.TitleChanged += new EventHandler(ThumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(ThumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr windowHandle = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarList.Instance.RegisterTab(windowHandle, preview.ParentWindowHandle); TaskbarList.Instance.SetTabOrder(windowHandle, IntPtr.Zero); TaskbarList.Instance.SetTabActive(windowHandle, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when running with admin var changeFilterResult = new ChangeFilterStruct { cbSize = (uint)Marshal.SizeOf #if CS7 < #else (typeof( #endif ChangeFilterStruct #if CS7 >( #else ) #endif ) }; _ = HandlerNativeMethods.ChangeWindowMessageFilterEx( windowHandle, WindowMessage.DWMSendIconicThumbnail, MessageFilterAction.Allow, ref changeFilterResult); changeFilterResult = new ChangeFilterStruct { cbSize = (uint)Marshal.SizeOf #if CS7 < #else (typeof( #endif ChangeFilterStruct #if CS7 >( #else ) #endif ) }; _ = HandlerNativeMethods.ChangeWindowMessageFilterEx( windowHandle, WindowMessage.DWMSendIconicLivePreviewBitmap, MessageFilterAction.Allow, ref changeFilterResult); // BUG: There should be somewhere to disable CustomWindowPreview. I didn't find it. DesktopWindowManager.EnableCustomWindowPreview(windowHandle, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. ThumbnailPreview_TitleChanged(preview, EventArgs.Empty); ThumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }
/// <summary> /// Determines whether the given preview has been added to the taskbar's tabbed thumbnail list. /// </summary> /// <param name="preview">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(TabbedThumbnail preview) { if (preview == null) { throw new ArgumentNullException(nameof(preview)); } if (preview.WindowHandle != IntPtr.Zero && _tabbedThumbnailCache.ContainsKey(preview.WindowHandle)) { return true; } else if (preview.WindowsControl != null && _tabbedThumbnailCacheWPF.ContainsKey(preview.WindowsControl)) { return true; } return false; }
/// <summary> /// Creates a Event Args for a TabbedThumbnailBitmapRequested event. /// </summary> /// <param name="windowsControl">WPF Control (UIElement) related to the event</param> /// <param name="preview">TabbedThumbnail related to this event</param> public TabbedThumbnailBitmapRequestedEventArgs(UIElement windowsControl, TabbedThumbnail preview) : base(windowsControl, preview) { }
/// <summary> /// Creates a Event Args for a specific tabbed thumbnail event. /// </summary> /// <param name="windowsControl">WPF Control (UIElement) related to the event</param> /// <param name="preview">TabbedThumbnail related to this event</param> public TabbedThumbnailEventArgs(UIElement windowsControl, TabbedThumbnail preview) { TabbedThumbnail = preview; WindowHandle = IntPtr.Zero; WindowsControl = windowsControl; }
/// <summary> /// Remove the tabbed thumbnail from the taskbar. /// </summary> /// <param name="preview">TabbedThumbnail associated with the control/window that /// is to be removed from the taskbar</param> public void RemoveThumbnailPreview(TabbedThumbnail preview) { if (preview == null) throw new ArgumentNullException("preview"); if (tabbedThumbnailList.ContainsKey(preview.WindowHandle)) RemoveThumbnailPreview(preview.WindowHandle); else if (tabbedThumbnailListWPF.ContainsKey(preview.WindowsControl)) RemoveThumbnailPreview(preview.WindowsControl); }
/// <summary> /// Creates a Event Args for a TabbedThumbnailClosing event. /// </summary> /// <param name="windowsControl">WPF Control (UIElement) related to the event</param> /// <param name="preview">TabbedThumbnail related to this event</param> public TabbedThumbnailClosingEventArgs(UIElement windowsControl, TabbedThumbnail preview) : base(windowsControl, preview) { }
/// <summary> /// Creates a Event Args for a TabbedThumbnailBitmapRequested event. /// </summary> /// <param name="windowHandle">Window handle for the control/window related to the event</param> /// <param name="preview">TabbedThumbnail related to this event</param> public TabbedThumbnailBitmapRequestedEventArgs(IntPtr windowHandle, TabbedThumbnail preview) : base(windowHandle, preview) { }
private void FrmMain_Load(object sender, System.EventArgs e) { webBrowser1.Navigate("http://listen.grooveshark.com"); // register the event that is fired after a key press. hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(hook_KeyPressed); webBrowser1.ObjectForScripting = this; //needed to capture JavaScript events //disable the IE "click sound" int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS; CoInternetSetFeatureEnabled(feature, SET_FEATURE_ON_PROCESS, true); if (Properties.Settings.Default.startMinimized) { showHideWindow(); } //Thumbnail buttons for win7 users if (TaskbarManager.IsPlatformSupported) { //Add a thumbnail image during peak _customThumbnail = new TabbedThumbnail(this.Handle, this.Handle); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(_customThumbnail); buttonPrev.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(Previous_Click); buttonPause.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(Play_Click); buttonNext.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(Next_Click); //Add the buttons (kinda of ugly tough) ThumbnailToolbarButton[] buttonList = new ThumbnailToolbarButton[3] { buttonPrev, buttonPause, buttonNext }; TaskbarManager.Instance.ThumbnailToolbars.AddButtons(this.Handle, buttonList); } }
/// <summary> /// Open a user-specified text file in a new tab (using a RichTextBox) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { // Open text file CommonOpenFileDialog cfd = new CommonOpenFileDialog(); CommonFileDialogStandardFilters.TextFiles.ShowExtensions = true; CommonFileDialogFilter rtfFilter = new CommonFileDialogFilter("RTF Files", ".rtf"); rtfFilter.ShowExtensions = true; cfd.Filters.Add(CommonFileDialogStandardFilters.TextFiles); cfd.Filters.Add(rtfFilter); if (cfd.ShowDialog() == CommonFileDialogResult.Ok) { TabPage newTab = new TabPage(Path.GetFileName(cfd.FileName)); tabControl1.TabPages.Add(newTab); RichTextBox rtbText = new RichTextBox(); rtbText.KeyDown += new KeyEventHandler(rtbText_KeyDown); rtbText.MouseMove += new MouseEventHandler(rtbText_MouseMove); rtbText.KeyUp += new KeyEventHandler(rtbText_KeyUp); rtbText.Dock = DockStyle.Fill; // Based on the extension, load the file appropriately in the RichTextBox if (Path.GetExtension(cfd.FileName).ToLower() == ".txt") rtbText.LoadFile(cfd.FileName, RichTextBoxStreamType.PlainText); else if (Path.GetExtension(cfd.FileName).ToLower() == ".rtf") rtbText.LoadFile(cfd.FileName, RichTextBoxStreamType.RichText); // Update the tab newTab.Controls.Add(rtbText); // Add a new preview TabbedThumbnail preview = new TabbedThumbnail(this.Handle, newTab.Handle); // Event handlers for this preview preview.TabbedThumbnailActivated += preview_TabbedThumbnailActivated; preview.TabbedThumbnailClosed += preview_TabbedThumbnailClosed; preview.TabbedThumbnailMaximized += preview_TabbedThumbnailMaximized; preview.TabbedThumbnailMinimized += preview_TabbedThumbnailMinimized; preview.ClippingRectangle = GetClippingRectangle(rtbText); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview); // Add thumbnail toolbar buttons TaskbarManager.Instance.ThumbnailToolBars.AddButtons(newTab.Handle, thumbButtonCut, thumbButtonCopy, thumbButtonPaste, thumbButtonSelectAll); // Select the tab in the application UI as well as taskbar tabbed thumbnail list tabControl1.SelectedTab = newTab; TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(tabControl1.SelectedTab); button2.Enabled = true; button4.Enabled = true; } }
public void AddToTaskbarThumbnail(Window winder, UIElement fifthelement, string timthetoolmantip, Vector? kimpeekoffset) { if (TaskbarManager.IsPlatformSupported) { var tt = new TabbedThumbnail(winder, fifthelement, new Vector(0, 0)) { Title = "MahTweets", Tooltip = timthetoolmantip, DisplayFrameAroundBitmap = false, PeekOffset = kimpeekoffset }; tt.TabbedThumbnailActivated += TabbedThumbnailActivated; TaskbarManager.TabbedThumbnail.AddThumbnailPreview(tt); if (TabbedThumbnailTimer == null) { TabbedThumbnailTimer = new Timer(); TabbedThumbnailTimer.Elapsed += ThumbnailTimerElapsed; TabbedThumbnailTimer.Interval = 1000; TabbedThumbnailTimer.Start(); } } }
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(); }
/// <summary> /// Creates a Event Args for a specific tabbed thumbnail event. /// </summary> /// <param name="windowHandle">Window handle for the control/window related to the event</param> /// <param name="preview">TabbedThumbnail related to this event</param> public TabbedThumbnailEventArgs(IntPtr windowHandle, TabbedThumbnail preview) { TabbedThumbnail = preview; WindowHandle = windowHandle; WindowsControl = null; }