/// <summary> /// Maps from logical pixels to physical desktop pixels. /// </summary> /// <param name="rect">Rectangle to be transformed.</param> /// <returns>Transformed rectangle.</returns> protected virtual Rect LogicalToPhysical(Rect rect) { var topLeft = new Win32Helpers.POINT { x = (int)rect.x, y = (int)rect.y }; Win32Helpers.LogicalToPhysicalPoint(_hwnd, ref topLeft); var bottomRight = new Win32Helpers.POINT { x = (int)(rect.x + rect.width), y = (int)(rect.y + rect.height) }; Win32Helpers.LogicalToPhysicalPoint(_hwnd, ref bottomRight); return(new Rect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y)); }
/// <summary> /// Maps from logical pixels to physical desktop pixels. /// </summary> /// <param name="rect">Rectangle to be transformed.</param> /// <returns>Transformed rectangle.</returns> protected virtual Rect LogicalToPhysical(Rect rect) { if (float.IsNaN(rect.x)) { return(rect); } var topLeft = new Win32Helpers.POINT { x = (int)rect.x, y = (int)rect.y }; Win32Helpers.LogicalToPhysicalPoint(_gameViewWindowHandle, ref topLeft); var bottomRight = new Win32Helpers.POINT { x = (int)(rect.x + rect.width), y = (int)(rect.y + rect.height) }; Win32Helpers.LogicalToPhysicalPoint(_gameViewWindowHandle, ref bottomRight); return(new Rect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y)); }