private Standard.HRESULT _UpdateThumbnailClipping(bool attached) { Standard.RefRECT prcClip = null; if (attached && (this.ThumbnailClipMargin != _EmptyThickness)) { Thickness thumbnailClipMargin = this.ThumbnailClipMargin; Standard.RECT clientRect = Standard.NativeMethods.GetClientRect(this._hwndSource.Handle); Rect rect2 = Standard.DpiHelper.DeviceRectToLogical(new Rect((double)clientRect.Left, (double)clientRect.Top, (double)clientRect.Width, (double)clientRect.Height)); if (((thumbnailClipMargin.Left + thumbnailClipMargin.Right) >= rect2.Width) || ((thumbnailClipMargin.Top + thumbnailClipMargin.Bottom) >= rect2.Height)) { prcClip = new Standard.RefRECT(0, 0, 0, 0); } else { Rect logicalRectangle = new Rect(thumbnailClipMargin.Left, thumbnailClipMargin.Top, (rect2.Width - thumbnailClipMargin.Left) - thumbnailClipMargin.Right, (rect2.Height - thumbnailClipMargin.Top) - thumbnailClipMargin.Bottom); Rect rect4 = Standard.DpiHelper.LogicalRectToDevice(logicalRectangle); prcClip = new Standard.RefRECT((int)rect4.Left, (int)rect4.Top, (int)rect4.Right, (int)rect4.Bottom); } } return(this._taskbarList.SetThumbnailClip(this._hwndSource.Handle, prcClip)); }
private HRESULT _UpdateThumbnailClipping(bool attached) { Assert.IsNotNull(_window); RefRECT interopRc = null; if (attached && ThumbnailClipMargin != _EmptyThickness) { Thickness margin = ThumbnailClipMargin; // Use the native GetClientRect. Window.ActualWidth and .ActualHeight include the non-client areas. RECT physicalClientRc = NativeMethods.GetClientRect(_hwndSource.Handle); Rect logicalClientRc = DpiHelper.DeviceRectToLogical(new Rect(physicalClientRc.Left, physicalClientRc.Top, physicalClientRc.Width, physicalClientRc.Height)); // Crop the clipping to ensure that the margin doesn't overlap itself. if (margin.Left + margin.Right >= logicalClientRc.Width || margin.Top + margin.Bottom >= logicalClientRc.Height) { interopRc = new RefRECT(0, 0, 0, 0); } else { Rect logicalClip = new Rect(margin.Left, margin.Top, logicalClientRc.Width - margin.Left - margin.Right, logicalClientRc.Height - margin.Top - margin.Bottom); Rect physicalClip = DpiHelper.LogicalRectToDevice(logicalClip); interopRc = new RefRECT((int)physicalClip.Left, (int)physicalClip.Top, (int)physicalClip.Right, (int)physicalClip.Bottom); } } // This will fail in the interop layer if called too early. HRESULT hr = _taskbarList.SetThumbnailClip(_hwndSource.Handle, interopRc); Assert.IsTrue(hr.Succeeded); return hr; }