1
- using System ;
1
+ using Dapplo . Windows . User32 ;
2
+ using System ;
2
3
using System . Collections . Generic ;
3
4
using System . Linq ;
4
5
using System . Threading . Tasks ;
5
6
using System . Windows ;
6
7
using System . Windows . Controls ;
7
8
using System . Windows . Input ;
8
- using Text_Grab . Properties ;
9
+ using Text_Grab . Extensions ;
9
10
using Text_Grab . Views ;
10
- // using Screen = System.Windows.Forms.Screen;
11
- using WpfScreenHelper ;
12
11
using static OSInterop ;
13
12
14
13
namespace Text_Grab . Utilities ;
@@ -47,15 +46,18 @@ public static void SetWindowPosition(Window passedWindow)
47
46
couldParseAll = double . TryParse ( storedPosition [ 2 ] , out double parsedWid ) ;
48
47
couldParseAll = double . TryParse ( storedPosition [ 3 ] , out double parsedHei ) ;
49
48
Rect storedSize = new ( ( int ) parsedX , ( int ) parsedY , ( int ) parsedWid , ( int ) parsedHei ) ;
50
- IEnumerable < Screen > allScreens = Screen . AllScreens ;
49
+ DisplayInfo [ ] allScreens = DisplayInfo . AllDisplayInfos ;
51
50
WindowCollection allWindows = Application . Current . Windows ;
52
51
53
52
if ( parsedHei < 10 || parsedWid < 10 )
54
53
return ;
55
54
56
- foreach ( Screen screen in allScreens )
57
- if ( screen . WpfBounds . IntersectsWith ( storedSize ) )
55
+ foreach ( DisplayInfo screen in allScreens )
56
+ {
57
+ Rect screenRect = screen . Bounds ;
58
+ if ( screenRect . IntersectsWith ( storedSize ) )
58
59
isStoredRectWithinScreen = true ;
60
+ }
59
61
60
62
if ( isStoredRectWithinScreen && couldParseAll )
61
63
{
@@ -71,7 +73,7 @@ public static void SetWindowPosition(Window passedWindow)
71
73
72
74
public static void LaunchFullScreenGrab ( TextBox ? destinationTextBox = null )
73
75
{
74
- IEnumerable < Screen > allScreens = Screen . AllScreens ;
76
+ DisplayInfo [ ] allScreens = DisplayInfo . AllDisplayInfos ;
75
77
WindowCollection allWindows = Application . Current . Windows ;
76
78
77
79
List < FullscreenGrab > allFullscreenGrab = new ( ) ;
@@ -93,7 +95,7 @@ public static void LaunchFullScreenGrab(TextBox? destinationTextBox = null)
93
95
94
96
double sideLength = 40 ;
95
97
96
- foreach ( Screen screen in allScreens )
98
+ foreach ( DisplayInfo screen in allScreens )
97
99
{
98
100
FullscreenGrab fullScreenGrab = allFullscreenGrab [ count ] ;
99
101
fullScreenGrab . WindowStartupLocation = WindowStartupLocation . Manual ;
@@ -102,7 +104,7 @@ public static void LaunchFullScreenGrab(TextBox? destinationTextBox = null)
102
104
fullScreenGrab . DestinationTextBox = destinationTextBox ;
103
105
fullScreenGrab . WindowState = WindowState . Normal ;
104
106
105
- Point screenCenterPoint = screen . GetCenterPoint ( ) ;
107
+ Point screenCenterPoint = screen . ScaledCenterPoint ( ) ;
106
108
107
109
fullScreenGrab . Left = screenCenterPoint . X - ( sideLength / 2 ) ;
108
110
fullScreenGrab . Top = screenCenterPoint . Y - ( sideLength / 2 ) ;
@@ -114,10 +116,11 @@ public static void LaunchFullScreenGrab(TextBox? destinationTextBox = null)
114
116
}
115
117
}
116
118
117
- public static Point GetCenterPoint ( this Screen screen )
119
+ public static Point GetCenterPoint ( this DisplayInfo screen )
118
120
{
119
- double x = screen . WpfBounds . Left + ( screen . WpfBounds . Width / 2 ) ;
120
- double y = screen . WpfBounds . Top + ( screen . WpfBounds . Height / 2 ) ;
121
+ Rect screenRect = screen . Bounds ;
122
+ double x = screenRect . Left + ( screenRect . Width / 2 ) ;
123
+ double y = screenRect . Top + ( screenRect . Height / 2 ) ;
121
124
return new ( x , y ) ;
122
125
}
123
126
@@ -151,8 +154,8 @@ internal static async void CloseAllFullscreenGrabs()
151
154
{
152
155
if ( window is FullscreenGrab fsg )
153
156
{
154
- if ( ! string . IsNullOrWhiteSpace ( fsg . textFromOCR ) )
155
- stringFromOCR = fsg . textFromOCR ;
157
+ if ( ! string . IsNullOrWhiteSpace ( fsg . TextFromOCR ) )
158
+ stringFromOCR = fsg . TextFromOCR ;
156
159
157
160
if ( fsg . DestinationTextBox is not null )
158
161
{
0 commit comments