/// <summary> /// Creates a new thumbnail of a certain window. /// </summary> /// <param name="handle">Handle of the window to clone.</param> /// <param name="region">Optional region.</param> public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region) { Log.WriteDetails("Setting new thumbnail", "HWND {0}, region {1}", handle, region ); if (_thumbnail != null && !_thumbnail.IsInvalid) { _thumbnail.Close(); _thumbnail = null; } //Attempt to get top level Form from Control Form owner = this.TopLevelControl as Form; if (owner == null) { throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form."); } _labelGlass.Visible = false; //Register new thumbnail, update regioning directly and refresh thumbnail _thumbnail = DwmManager.Register(owner, handle.Handle); _currentRegion = region; _regionEnabled = (region != null); UpdateThubmnail(); }
private void HandleQuickRegionDrawn(object sender, ThumbnailRegion region) { //Reset region drawing state ThumbnailPanel.DrawMouseRegions = false; ThumbnailPanel.RegionDrawn -= _quickRegionDrawingHandler; SelectedThumbnailRegion = region; }
/// <summary> /// Sets a new thumbnail. /// </summary> /// <param name="handle">Handle to the window to clone.</param> /// <param name="region">Region of the window to clone or null.</param> public void SetThumbnail(WindowHandle handle, ThumbnailRegion region) { try { Log.Write("Cloning window HWND {0} of class {1}", handle.Handle, handle.Class); CurrentThumbnailWindowHandle = handle; _thumbnailPanel.SetThumbnailHandle(handle, region); //Set aspect ratio (this will resize the form), do not refresh if in fullscreen SetAspectRatio(_thumbnailPanel.ThumbnailPixelSize, !FullscreenManager.IsFullscreen); } catch (Exception ex) { Log.WriteException("Unable to set new thumbnail", ex); ThumbnailError(ex, false, Strings.ErrorUnableToCreateThumbnail); _thumbnailPanel.UnsetThumbnail(); } }
private StoredRegion ParseStoredRegion(XElement xmlRegion) { var xName = xmlRegion.Attribute("name"); if (xName == null || string.IsNullOrWhiteSpace(xName.Value)) { System.Diagnostics.Debug.Fail("Parsed stored region has no name attribute."); return(null); } ThumbnailRegion region = ParseRegion(xmlRegion); if (region == null) { System.Diagnostics.Debug.Fail("Parsed stored region has no valid region."); return(null); } return(new StoredRegion(region, xName.Value)); }
/// <summary> /// Creates a new thumbnail of a certain window. /// </summary> /// <param name="handle">Handle of the window to clone.</param> /// <param name="region">Optional region.</param> public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region) { Log.WriteDetails("Setting new thumbnail", "HWND {0}, region {1}", handle, region ); if (_thumbnail != null && !_thumbnail.IsInvalid) { _thumbnail.Close(); _thumbnail = null; } //Attempt to get top level Form from Control Form owner = this.TopLevelControl as Form; if (owner == null) throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form."); _labelGlass.Visible = false; //Register new thumbnail, update regioning directly and refresh thumbnail _thumbnail = DwmManager.Register(owner, handle.Handle); _currentRegion = region; _regionEnabled = (region != null); UpdateThubmnail(); }
public StoredRegion(ThumbnailRegion r, string name) { Region = r; Name = name; }
/// <summary> /// Sets a new thumbnail. /// </summary> /// <param name="handle">Handle to the window to clone.</param> /// <param name="region">Region of the window to clone or null.</param> public void SetThumbnail(WindowHandle handle, ThumbnailRegion region) { try { System.Diagnostics.Trace.WriteLine(string.Format("Cloning window HWND {0} of class {1}.", handle.Handle, handle.Class)); CurrentThumbnailWindowHandle = handle; _thumbnailPanel.SetThumbnailHandle(handle, region); //Set aspect ratio (this will resize the form), do not refresh if in fullscreen SetAspectRatio(_thumbnailPanel.ThumbnailPixelSize, !FullscreenManager.IsFullscreen); } catch (Exception ex) { System.Diagnostics.Trace.Fail("Unable to set thumbnail.", ex.ToString()); ThumbnailError(ex, false, Strings.ErrorUnableToCreateThumbnail); _thumbnailPanel.UnsetThumbnail(); } }
/// <summary> /// Creates a new thumbnail of a certain window. /// </summary> /// <param name="handle">Handle of the window to clone.</param> /// <param name="region">Optional region.</param> public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region) { System.Diagnostics.Trace.WriteLine(string.Format("Setting thumbnail to handle {0}, with region {1}.", handle, region), "ThumbnailPanel"); if (_thumbnail != null && !_thumbnail.IsInvalid) { _thumbnail.Close(); _thumbnail = null; } //Get form and register thumbnail on it Form owner = this.TopLevelControl as Form; if(owner == null) throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form."); _labelGlass.Visible = false; //Register new thumbnail, disable regioning directly and refresh _thumbnail = DwmManager.Register(owner, handle.Handle); _currentRegion = region; _regionEnabled = (region != null); UpdateThubmnail(); }