33using System . Drawing ;
44using System . Runtime . InteropServices ;
55using System . Text ;
6- using System . Windows . Forms ;
76using static ImgurSniper . Libraries . Helper . CaptureHelpers ;
87using static ImgurSniper . Libraries . Native . NativeStructs ;
98
@@ -52,8 +51,6 @@ public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out
5251 [ DllImport ( "user32.dll" ) ]
5352 public static extern IntPtr GetWindowLong ( IntPtr hWnd , int nIndex ) ;
5453 [ DllImport ( "user32.dll" ) ]
55- public static extern IntPtr GetForegroundWindow ( ) ;
56- [ DllImport ( "user32.dll" ) ]
5754 public static extern IntPtr FindWindowEx ( IntPtr parentHwnd , IntPtr childAfterHwnd , IntPtr className , string windowText ) ;
5855 [ DllImport ( "user32.dll" ) ]
5956 public static extern bool ShowWindow ( IntPtr hWnd , int nCmdShow ) ;
@@ -151,8 +148,6 @@ private static int IntPtrToInt32(IntPtr intPtr) {
151148 return unchecked ( ( int ) intPtr . ToInt64 ( ) ) ;
152149 }
153150
154- public static Rectangle GetScreenBounds ( ) => SystemInformation . VirtualScreen ;
155-
156151 public static Point ScreenToClient ( Point p ) {
157152 int screenX = GetSystemMetrics ( SystemMetric . SmXvirtualscreen ) ;
158153 int screenY = GetSystemMetrics ( SystemMetric . SmYvirtualscreen ) ;
@@ -177,8 +172,7 @@ public static Rectangle GetWindowRect(IntPtr handle) {
177172 }
178173
179174 public static bool GetExtendedFrameBounds ( IntPtr handle , out Rectangle rectangle ) {
180- int result = DwmGetWindowAttribute ( handle , ( int ) DwmWindowAttribute . ExtendedFrameBounds , out RECT rect ,
181- Marshal . SizeOf ( typeof ( RECT ) ) ) ;
175+ int result = DwmGetWindowAttribute ( handle , ( int ) DwmWindowAttribute . ExtendedFrameBounds , out RECT rect , Marshal . SizeOf ( typeof ( RECT ) ) ) ;
182176 rectangle = rect ;
183177 return result == 0 ;
184178 }
@@ -222,84 +216,7 @@ public static bool GetBorderSize(IntPtr handle, out Size size) {
222216 return result ;
223217 }
224218
225- public static Rectangle GetClientRect ( IntPtr handle ) {
226- GetClientRect ( handle , out RECT rect ) ;
227- Point position = rect . Location ;
228- ClientToScreen ( handle , ref position ) ;
229- return new Rectangle ( position , rect . Size ) ;
230- }
231-
232- public static bool SetTaskbarVisibilityIfIntersect ( bool visible , Rectangle rect ) {
233- bool result = false ;
234-
235- IntPtr taskbarHandle = FindWindow ( "Shell_TrayWnd" , null ) ;
236-
237- if ( taskbarHandle != IntPtr . Zero ) {
238- Rectangle taskbarRect = GetWindowRect ( taskbarHandle ) ;
239-
240- if ( rect . IntersectsWith ( taskbarRect ) ) {
241- ShowWindow ( taskbarHandle , visible ? ( int ) WindowShowStyle . Show : ( int ) WindowShowStyle . Hide ) ;
242- result = true ;
243- }
244-
245- if ( IsWindowsVista ( ) || IsWindows7 ( ) ) {
246- IntPtr startHandle = FindWindowEx ( IntPtr . Zero , IntPtr . Zero , ( IntPtr ) 0xC017 , null ) ;
247-
248- if ( startHandle != IntPtr . Zero ) {
249- Rectangle startRect = GetWindowRect ( startHandle ) ;
250-
251- if ( rect . IntersectsWith ( startRect ) ) {
252- ShowWindow ( startHandle , visible ? ( int ) WindowShowStyle . Show : ( int ) WindowShowStyle . Hide ) ;
253- result = true ;
254- }
255- }
256- }
257- }
258-
259- return result ;
260- }
261-
262- public static bool SetTaskbarVisibility ( bool visible ) {
263- IntPtr taskbarHandle = FindWindow ( "Shell_TrayWnd" , null ) ;
264-
265- if ( taskbarHandle != IntPtr . Zero ) {
266- ShowWindow ( taskbarHandle , visible ? ( int ) WindowShowStyle . Show : ( int ) WindowShowStyle . Hide ) ;
267-
268- if ( IsWindowsVista ( ) || IsWindows7 ( ) ) {
269- IntPtr startHandle = FindWindowEx ( IntPtr . Zero , IntPtr . Zero , ( IntPtr ) 0xC017 , null ) ;
270-
271- if ( startHandle != IntPtr . Zero ) {
272- ShowWindow ( startHandle , visible ? ( int ) WindowShowStyle . Show : ( int ) WindowShowStyle . Hide ) ;
273- }
274- }
275-
276- return true ;
277- }
278-
279- return false ;
280- }
281-
282- public static Rectangle GetActiveScreenBounds ( ) {
283- return Screen . FromPoint ( GetCursorPosition ( ) ) . Bounds ;
284- }
285-
286219 #region Custom Definitions
287- public enum WindowShowStyle : uint {
288- Hide = 0 ,
289- ShowNormal = 1 ,
290- ShowMinimized = 2 ,
291- ShowMaximized = 3 ,
292- Maximize = 3 ,
293- ShowNormalNoActivate = 4 ,
294- Show = 5 ,
295- Minimize = 6 ,
296- ShowMinNoActivate = 7 ,
297- ShowNoActivate = 8 ,
298- Restore = 9 ,
299- ShowDefault = 10 ,
300- ForceMinimized = 11
301- }
302-
303220 [ StructLayout ( LayoutKind . Sequential ) ]
304221 public struct WindowInfo {
305222 public uint cbSize ;
0 commit comments