public static int GetDpiForMonitor(IntPtr hMonitor, MonitorDpiType dpiType, out Interop.DpiScale dpi)
        {
            var result = GetDpiForMonitor(hMonitor, dpiType, out var x, out var y);

            dpi = new Interop.DpiScale(x, y);
            return(result);
        }
        /// <summary>
        /// Gets the DPI for the current display.
        /// </summary>
        /// <remarks>
        /// Consider using the <see cref="CompositionTarget.TransformToDevice"/> matrix, provided by <see cref="PresentationSource.CompositionTarget"/> instead.
        /// </remarks>
        /// <param name="window">Window.</param>
        /// <param name="defaultWindow">Determines the function's return value if the window does not intersect any display monitor.</param>
        /// <param name="dpiScale">The dpi scale for the current monitor.</param>
        /// <returns>True if the function succeeded.</returns>
        public static bool TryGetDpiForCurrentMonitor(this Window window, DefaultWindow defaultWindow, out Interop.DpiScale dpiScale)
        {
            IntPtr hMonitor = NativeMethods.MonitorFromWindow(window.GetHandle(), defaultWindow);

            if (hMonitor != IntPtr.Zero && NativeMethods.GetDpiForMonitor(hMonitor, MonitorDpiType.MDT_EFFECTIVE_DPI, out dpiScale) == 0)
            {
                return(true);
            }

            dpiScale = default;
            return(false);
        }