Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool IsLocationGood()
- {
- //abort
- if (0 == this.dpiOld) return false;
- var factor = dpiNew / dpiOld;
- var widthDiff = Convert.ToInt32(SystemParameters.WorkArea.Width * factor) - SystemParameters.WorkArea.Width;
- var heightDiff = Convert.ToInt32(SystemParameters.WorkArea.Height * factor) - SystemParameters.WorkArea.Height;
- var r = new Rect(this.RenderSize);
- var rect = new RECT() { left = (int)r.Left, top = (int)r.Top, right = (int)r.Right, bottom = (int)r.Bottom };
- //Get handle to monitor that has the largest intersection with the rectangle.
- var handleMonitor = W32.MonitorFromRect(ref rect, W32.MONITOR_DEFAULTTONULL);
- if (IntPtr.Zero == handleMonitor) return false;
- uint dpiX = 0;
- uint dpiY = 0;
- var result = W32.GetDpiForMonitor(handleMonitor, MonitorDpiType.Default, ref dpiX, ref dpiY);
- if (IntPtr.Zero != result) return false;
- return (dpiX == dpiNew);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement