Download src/ScreenGrab/Extensions/DapploExtensions.cs from dlxjj/imradv3: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/datasets/dlxjj/imradv3/resolve/main/src/ScreenGrab/Extensions/DapploExtensions.cs
- Command line
-
hf download hf://datasets/dlxjj/imradv3/src/ScreenGrab/Extensions/DapploExtensions.cs
-
curl -L -o DapploExtensions.cs https://huggingface.co/datasets/dlxjj/imradv3/resolve/main/src/ScreenGrab/Extensions/DapploExtensions.cs
1.15 kB
| using System.Windows; | |
| using Dapplo.Windows.User32; | |
| namespace ScreenGrab.Extensions; | |
| public static class DapploExtensions | |
| { | |
| public static Point ScaledCenterPoint(this DisplayInfo displayInfo) | |
| { | |
| Rect displayRect = displayInfo.Bounds; | |
| NativeMethods.GetScaleFactorForMonitor(displayInfo.MonitorHandle, out var scaleFactor); | |
| var scaleFraction = scaleFactor / 100.0; | |
| var rawCenter = displayRect.CenterPoint(); | |
| Point displayScaledCenterPoint = new(rawCenter.X / scaleFraction, rawCenter.Y / scaleFraction); | |
| return displayScaledCenterPoint; | |
| } | |
| public static Rect ScaledBounds(this DisplayInfo displayInfo) | |
| { | |
| Rect displayRect = displayInfo.Bounds; | |
| NativeMethods.GetScaleFactorForMonitor(displayInfo.MonitorHandle, out var scaleFactor); | |
| var scaleFraction = scaleFactor / 100.0; | |
| // Scale size and position | |
| Rect scaledBounds = new( | |
| displayRect.X / scaleFraction, | |
| displayRect.Y / scaleFraction, | |
| displayRect.Width / scaleFraction, | |
| displayRect.Height / scaleFraction); | |
| return scaledBounds; | |
| } | |
| } |