-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #458 from TheJoeFin/Dapplo-Screens
Dapplo screens
- Loading branch information
Showing
6 changed files
with
131 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Dapplo.Windows.User32; | ||
using System.Windows; | ||
|
||
namespace Text_Grab.Extensions; | ||
public static class DapploExtensions | ||
{ | ||
public static Point ScaledCenterPoint(this DisplayInfo displayInfo) | ||
{ | ||
Rect displayRect = displayInfo.Bounds; | ||
NativeMethods.GetScaleFactorForMonitor(displayInfo.MonitorHandle, out uint scaleFactor); | ||
double scaleFraction = scaleFactor / 100.0; | ||
Point 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 uint scaleFactor); | ||
double 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.