From d021fec0636c4070a9e4b862adb6a405d73a3205 Mon Sep 17 00:00:00 2001 From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com> Date: Fri, 10 Jan 2020 16:58:48 +0100 Subject: [PATCH] Extension methods --- Misc/GenericExtensions.cs | 3 +++ W32/GenericExtensions.cs | 14 ++++++++++++++ W32/W32.csproj | 1 + 3 files changed, 18 insertions(+) create mode 100644 W32/GenericExtensions.cs diff --git a/Misc/GenericExtensions.cs b/Misc/GenericExtensions.cs index f676cdf..fb02099 100644 --- a/Misc/GenericExtensions.cs +++ b/Misc/GenericExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; namespace CC_Functions.Misc @@ -63,5 +64,7 @@ namespace CC_Functions.Misc public static void RemoveAt(this Dictionary dict, int index) => dict.Remove(dict.Keys.OfType().ToArray()[index]); + + public static long GetSize(this DirectoryInfo directory) => IO.GetDirectorySize(directory.FullName); } } \ No newline at end of file diff --git a/W32/GenericExtensions.cs b/W32/GenericExtensions.cs new file mode 100644 index 0000000..69c1b8b --- /dev/null +++ b/W32/GenericExtensions.cs @@ -0,0 +1,14 @@ +using System; +using System.Diagnostics; +using System.Windows.Forms; + +namespace CC_Functions.W32 +{ + public static class GenericExtensions + { + public static Wnd32 GetWindow(this IntPtr handle) => Wnd32.fromHandle(handle); + public static Wnd32 GetMainWindow(this Process handle) => Wnd32.getProcessMain(handle); + public static Wnd32 GetWnd32(this Form frm) => Wnd32.fromForm(frm); + public static bool IsDown(this Keys key) => KeyboardReader.IsKeyDown(key); + } +} \ No newline at end of file diff --git a/W32/W32.csproj b/W32/W32.csproj index 9e0e05f..8cf0f8d 100644 --- a/W32/W32.csproj +++ b/W32/W32.csproj @@ -50,6 +50,7 @@ +