Extension methods

This commit is contained in:
CreepyCrafter24 2020-01-10 16:58:48 +01:00
parent 5a4f4c083f
commit d021fec063
3 changed files with 18 additions and 0 deletions

View File

@ -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<T, G>(this Dictionary<T, G> dict, int index) =>
dict.Remove(dict.Keys.OfType<T>().ToArray()[index]);
public static long GetSize(this DirectoryInfo directory) => IO.GetDirectorySize(directory.FullName);
}
}

14
W32/GenericExtensions.cs Normal file
View File

@ -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);
}
}

View File

@ -50,6 +50,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GenericExtensions.cs" />
<Compile Include="Hooks\MouseHook.cs" />
<Compile Include="Hooks\KeyboardHook.cs" />
<Compile Include="Hooks\KeyboardHookEventArgs.cs" />