/// <summary> /// Sets the current selected region to a specific region rectangle. /// </summary> /// <param name="region">The region boundaries.</param> public void SetRegion(ThumbnailRegion region) { try { _ignoreValueChanges = true; UpdateRegionControls(region); numX.Enabled = numY.Enabled = numW.Enabled = numH.Enabled = true; } finally { _ignoreValueChanges = false; } OnRegionSet(region); }
/// <summary> /// Constructs a ThumbnailRegion from the dialog's current state. /// </summary> protected ThumbnailRegion ConstructCurrentRegion() { Rectangle bounds = new Rectangle { X = (int)numX.Value, Y = (int)numY.Value, Width = (int)numW.Value, Height = (int)numH.Value }; ThumbnailRegion newRegion = new ThumbnailRegion(bounds, checkRelative.Checked); return(newRegion); }
/// <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 { CurrentThumbnailWindowHandle = handle; ThumbnailPanel.SetThumbnailHandle(handle, region); //Set aspect ratio (this will resize the form), do not refresh if in fullscreen SetAspectRatio(ThumbnailPanel.ThumbnailPixelSize, true); } catch (Exception ex) { ThumbnailError(ex, false, "无法创建缩略图"); ThumbnailPanel.UnsetThumbnail(); } }
/// <summary> /// Updates the labels for the region value selectors and the relative mode checkbox. /// </summary> private void UpdateRegionControls(ThumbnailRegion region) { checkRelative.Checked = region.Relative; if (region.Relative) { Padding p = region.BoundsAsPadding; numX.Value = p.Left; numY.Value = p.Top; numW.Value = p.Right; numH.Value = p.Bottom; } else { Rectangle r = region.Bounds; numX.Value = r.X; numY.Value = r.Y; numW.Value = r.Width; numH.Value = r.Height; } UpdateRegionLabels(); }
void ThumbnailPanel_RegionDrawn(object sender, ThumbnailRegion region) => SetRegion(region);
protected virtual void OnRegionSet(ThumbnailRegion region) => ParentMainForm.SelectedThumbnailRegion = region;//Forward region to thumbnail