1
1
using System ;
2
2
using System . Collections . Generic ;
3
- using System . Diagnostics ;
4
- using System . Drawing ;
5
3
using System . Linq ;
6
- using System . Security . Permissions ;
7
- using System . Text . RegularExpressions ;
8
4
using System . Threading . Tasks ;
9
5
using System . Windows ;
10
6
using System . Windows . Controls ;
@@ -30,26 +26,26 @@ public static void AddTextToOpenWindow(string textToAdd)
30
26
31
27
public static void SetWindowPosition ( Window passedWindow )
32
28
{
33
- string storedPostionString = "" ;
29
+ string storedPositionString = "" ;
34
30
35
31
if ( passedWindow is EditTextWindow )
36
- storedPostionString = Properties . Settings . Default . EditTextWindowSizeAndPosition ;
32
+ storedPositionString = Settings . Default . EditTextWindowSizeAndPosition ;
37
33
38
34
if ( passedWindow is GrabFrame )
39
- storedPostionString = Properties . Settings . Default . GrabFrameWindowSizeAndPosition ;
35
+ storedPositionString = Settings . Default . GrabFrameWindowSizeAndPosition ;
40
36
41
- List < string > storedPostion = new ( storedPostionString . Split ( ',' ) ) ;
37
+ List < string > storedPosition = new ( storedPositionString . Split ( ',' ) ) ;
42
38
43
39
bool isStoredRectWithinScreen = false ;
44
40
45
- if ( storedPostion != null
46
- && storedPostion . Count == 4 )
41
+ if ( storedPosition != null
42
+ && storedPosition . Count == 4 )
47
43
{
48
44
bool couldParseAll = false ;
49
- couldParseAll = double . TryParse ( storedPostion [ 0 ] , out double parsedX ) ;
50
- couldParseAll = double . TryParse ( storedPostion [ 1 ] , out double parsedY ) ;
51
- couldParseAll = double . TryParse ( storedPostion [ 2 ] , out double parsedWid ) ;
52
- couldParseAll = double . TryParse ( storedPostion [ 3 ] , out double parsedHei ) ;
45
+ couldParseAll = double . TryParse ( storedPosition [ 0 ] , out double parsedX ) ;
46
+ couldParseAll = double . TryParse ( storedPosition [ 1 ] , out double parsedY ) ;
47
+ couldParseAll = double . TryParse ( storedPosition [ 2 ] , out double parsedWid ) ;
48
+ couldParseAll = double . TryParse ( storedPosition [ 3 ] , out double parsedHei ) ;
53
49
Rect storedSize = new ( ( int ) parsedX , ( int ) parsedY , ( int ) parsedWid , ( int ) parsedHei ) ;
54
50
IEnumerable < Screen > allScreens = Screen . AllScreens ;
55
51
WindowCollection allWindows = Application . Current . Windows ;
@@ -83,8 +79,8 @@ public static void LaunchFullScreenGrab(TextBox? destinationTextBox = null)
83
79
int numberOfScreens = allScreens . Count ( ) ;
84
80
85
81
foreach ( Window window in allWindows )
86
- if ( window is FullscreenGrab )
87
- allFullscreenGrab . Add ( ( FullscreenGrab ) window ) ;
82
+ if ( window is FullscreenGrab grab )
83
+ allFullscreenGrab . Add ( grab ) ;
88
84
89
85
int numberOfFullscreenGrabWindowsToCreate = numberOfScreens - allFullscreenGrab . Count ;
90
86
@@ -95,34 +91,30 @@ public static void LaunchFullScreenGrab(TextBox? destinationTextBox = null)
95
91
96
92
int count = 0 ;
97
93
94
+ double sideLength = 40 ;
95
+
98
96
foreach ( Screen screen in allScreens )
99
97
{
100
- FullscreenGrab fullscreenGrab = allFullscreenGrab [ count ] ;
101
- fullscreenGrab . WindowStartupLocation = WindowStartupLocation . Manual ;
102
- fullscreenGrab . Width = 400 ;
103
- fullscreenGrab . Height = 200 ;
104
- fullscreenGrab . DestinationTextBox = destinationTextBox ;
105
- fullscreenGrab . WindowState = WindowState . Normal ;
106
-
107
- System . Windows . Point screenCenterPoint = screen . GetCenterPoint ( ) ;
108
- System . Windows . Point windowCenterPoint = fullscreenGrab . GetWindowCenter ( ) ;
98
+ FullscreenGrab fullScreenGrab = allFullscreenGrab [ count ] ;
99
+ fullScreenGrab . WindowStartupLocation = WindowStartupLocation . Manual ;
100
+ fullScreenGrab . Width = sideLength ;
101
+ fullScreenGrab . Height = sideLength ;
102
+ fullScreenGrab . DestinationTextBox = destinationTextBox ;
103
+ fullScreenGrab . WindowState = WindowState . Normal ;
109
104
110
- double virtualScreenTop = SystemParameters . VirtualScreenTop ;
111
- double virtualScreenLeft = SystemParameters . VirtualScreenLeft ;
112
- double virtualScreenWidth = SystemParameters . VirtualScreenWidth ;
113
- double virtualScreenHeight = SystemParameters . VirtualScreenHeight ;
105
+ Point screenCenterPoint = screen . GetCenterPoint ( ) ;
114
106
115
- fullscreenGrab . Left = screenCenterPoint . X - windowCenterPoint . X ;
116
- fullscreenGrab . Top = screenCenterPoint . Y - windowCenterPoint . Y ;
107
+ fullScreenGrab . Left = screenCenterPoint . X - ( sideLength / 2 ) ;
108
+ fullScreenGrab . Top = screenCenterPoint . Y - ( sideLength / 2 ) ;
117
109
118
- fullscreenGrab . Show ( ) ;
119
- fullscreenGrab . Activate ( ) ;
110
+ fullScreenGrab . Show ( ) ;
111
+ fullScreenGrab . Activate ( ) ;
120
112
121
113
count ++ ;
122
114
}
123
115
}
124
116
125
- public static System . Windows . Point GetCenterPoint ( this Screen screen )
117
+ public static Point GetCenterPoint ( this Screen screen )
126
118
{
127
119
double x = screen . WpfBounds . Left + ( screen . WpfBounds . Width / 2 ) ;
128
120
double y = screen . WpfBounds . Top + ( screen . WpfBounds . Height / 2 ) ;
@@ -164,7 +156,7 @@ internal static async void CloseAllFullscreenGrabs()
164
156
165
157
if ( fsg . DestinationTextBox is not null )
166
158
{
167
- // TODO 3.0 Find out how to re normaize an ETW when FSG had it minimzed
159
+ // TODO 3.0 Find out how to re normalize an ETW when FSG had it minimized
168
160
isFromEditWindow = true ;
169
161
// if (fsg.EditWindow.WindowState == WindowState.Minimized)
170
162
// fsg.EditWindow.WindowState = WindowState.Normal;
@@ -201,7 +193,7 @@ internal static async Task TryInsertString(string stringToInsert)
201
193
{
202
194
await Task . Delay ( TimeSpan . FromSeconds ( Settings . Default . InsertDelay ) ) ;
203
195
204
- List < INPUT > inputs = new List < INPUT > ( ) ;
196
+ List < INPUT > inputs = new ( ) ;
205
197
// make sure keys are up.
206
198
TryInjectModifierKeyUp ( ref inputs , VirtualKeyShort . LCONTROL ) ;
207
199
TryInjectModifierKeyUp ( ref inputs , VirtualKeyShort . RCONTROL ) ;
@@ -264,7 +256,7 @@ private static void TryInjectModifierKeyUp(ref List<INPUT> inputs, VirtualKeySho
264
256
}
265
257
266
258
// No Window Found, open a new one
267
- T newWindow = new T ( ) ;
259
+ T newWindow = new ( ) ;
268
260
newWindow . Show ( ) ;
269
261
return newWindow ;
270
262
}
0 commit comments