What is ElektroKit?
ElektroKit is a utility framework containing new APIs and extensions to the core .NET Framework to help complete your developer toolbox.
It is a set of general purpose classes provided as easy to consume packages.
These utility classes and components provide productivity in day to day software development mainly focused to WindowsForms. Many of these tools and components have been published individually in articles, forums or blog entries and there have been many requests to publish them as a supported and consolidated library, which turned into this unified toolkit that is integrated, documented and fully supported.
What’s in it?
ElektroKit is made up of the following assemblies:
Contains the core of Elektrokit, full of different utilities.
What can do ElektroKit for me?
It’s impossible to summarize all the functionalities in a single page, but here is a list of interesting things that you could do with ElektroKit:
Enumerate the loaded assemblies of the current application.
Enumerate the threads of the current application.
Register system-wide hotkeys with the Hotkey type.
Represent command-line parameters for CLI applications, with the CommandlineParameter type.
Serialize and deserialize objects as Binary, Xml, or JSon formats.
The ResXManager class that is a full-featured manager for the creation or edition of .Net managed resources (.resx files).
Create and manage INI files for your portable application with the IniManager class.
Create, save and load MRU lists with the MruUtil class and MruItem type.
Retrieve any setting from the AppConfig file with the GetAppConfigSetting function.
Dock your application window to any border of the screen with the WindowToScreenDocker class.
Dock your application window to other windows on the screen with the WindowToWindowDocker class.
Add magnetism to the borders of your window with the WindowMagnetizer class.
Lock the parts that composes your window with the WindowLocker class.
Add an Undo/Redo mechanism for your controls with the UndoRedo class and their inheritances.
Resize controls at run-time by dragging the control, with the ControlResizer class.
Manage the hints (cue-banners) of your controls, with the ControlHintManager class.
Drag controls at run-time with the ControlDragger class.
Make a borderless Form moveable with the FormDragger’ class.
Generate captchas for your application with the CaptchaGenerator class and the Captcha type.
Load true-type fonts from a resource or filepath, with the FontData class.
Animate forms, center to other forms, activate full-screen mode and other single tasks with the GuiUtil class.
A lot of command-line wrappers for 3rd part applications.
Extend IEnumerable types by adding extension-methods to find-by-index an element, split a collection into a number of sequences, randomize, bubble-sorting, etc…
Use a stack or queue with fixed capacity, with the FixedStack(Of T) and FixedQueue(Of T) types.
Permute all the possible sequences of characters.
Convert an amount of time, from unit of time to other.
Measure time as a chronometer or a countdown in a event-oriented way with the TimeMeasurer class.
Manage a simple logfile system with the LogfileWriter class.
Retrieve the current Visual Studio instance for further debug or automation operations.
Test the execution of a target member and the time that the member takes to finish execution.
A keyboard hook in a event-oriented way, with the KeyboardMonitor class.
A mouse hook in a event-oriented way, with the MouseMonitor class.
A mouse recorder (macro) with the MouseRecorder class.
A shortcut manager to create or edit shortcuts, with the Shortcuts class.
A file splitter and a file merger, with the FileSplitter class.
The Files class that contains helper methods to set the user-rights of a file, manipulate file attributes, find files by patterns, compare files byte-by-byte, create dummy files, etc…
The Directories class that contains helper methods set the user-rights of a directory, manipulate directory attributes, find directories by patterns, get the size of a directory, etc…
The Hardware class that helps to format a drive, list drives of specific drive-type, getting hardware identifiers (Cpu, Motherdoard) or print a document, etc…
The DriveWatcher class that notifies about hardware changes about the insertion or removal of drives (eg. useful for USB monitoring).
The FileCopy class that copies files reporting the copy-progress by firing evenets, and can cancel a copy operation.
Calculate percentages, determine if number is multiple by, divisible by, prime, positive, negative, etc…
- Split-by-length, rename in a specific string-case, randomize, measure, determine its size in memory or textfile, reverse, rotate/shift, and much more like custom Find-by-RegEx and Replace-by-RegEx utilities’
The Patterns class that exposes common regular expression patterns.
Beuautify Xml documents.
Get X-Paths of Xml documents.
Sort or distinct Xml documents by name of element.
Take screenshots from a screen, a Form, a region, or an object with the ImageUtil class.
Let the end-user select a region on the screen in a event-oriented way with the ScreenRegionSelector class.
Transform images into black-and-white or grayscale, set the brightness, gamma, opacity or contrast of a image, resize or scale a image, and much more…
The WindowsDataTypes class assists for the creation or manipulation between some unmanaged types (WORD, DWORD, DWORDLONG, etc).
The Win32 namespace which exposes all the dependant P/invokes of ElektroKit (and a lot of non-dependant more, such as ll-hooks) to arbitrary use them wherever in your applications.
Record and play Wave files with the WaveRecorder class.
Play, pause and seek audio files like an audio player with the AudioPlayer class.
Create or edit playlists with the PlaylistEditor class.
Convert karaoke lyrics with the LyricUtil class.
Validate an ip, url, or an email.
A pinger, and a port-scanner.
A huge list of known mimetypes and they file-extension relationship’
Determine if network or specific webpage is available.
Manage the Windows Firewall, enable or disable it, and add or remove firewall rules, with the FirewallUtil class.
Monitors the network traffic by firing events to notify about changes, with the NetworkTrafficMonitor class.
Monitors the network traffic of the current process by firing events to notify about changes, with the ProcessTrafficMonitor class.
Translate between languages with the GoogleTranslator class.
Geo-locate addresses, download files, upload to FTP, or send emails using Gmail, etc…
Monitors the execution and closure of processes, with the ProcessMonitor class.
Kill or close processes by their name, do WMI queries for processes, run and wait until a process is fully loaded, etc…
Manages the creation and manipulation of shared-memory blocks with another application, with the SharedMemory class.
Automate external processes, move or resize windows, modify text of an edit-control, flash a window, etc. with the UIAutomation class.
Launch a controlpanel applet, arrange desktop icons, show or hide the desktop or taskbar…
The Theming namespace that manages the personalization of system cursors, wallpapers, fonts, screen saver, and visual themes.
The Tweaking namespace that exposes a way to tweak various operating system properties.
The Registry class that exposes helper methods to create, find, remove, and manipulate registry keys in general.
The UserAccounts class that exposes helper methods to add, find, remove or edit user accounts.
Manage the address mappings of the HOSTS file with the Hosts class.
Manage the recycle-bins and their items inside with the RecycleBin class.
Manage the environment variables with the EnvironmentVariables class.
Manage the PATH and EXTPATH content with the EnvironmentPath class.
Add or remove items to windows startup with the WinStartup class.
All the members of ElektroKit source-code are documented and exposed in different ways.
Offline documentation is available as .chm file included in the package.
Note there are a lot of code examples for most of the ElektroKit members which can be a good starting place, like this random example:
The code examples are also available in the source-code as part of the Xml documentation.
An xample of the Xml documentation format:
An example of Intellisense preview at design-time:
Various members of the ElektroKit solution depends on the Elektro.Core assembly or other assemblies that are part of the solution. Note that any required assembly will be warned by Visual Studio, so don’t worry about.
Some members of the Elektro.Application and Elektro.System assemblies depends on WindowsAPICodePack API, which is included in the package, but also can be downloaded from here:
Note that there is no need to reference the WindowsAPICodePack assemblies in your application as long as you don’t need to use the members that requires it, and the same for the other Elektro* assemblies.
- The ReadUntilFirstNullByte method extensions for Byte, IEnumerable(Byte) and Stream types.
- The IsWindowTotallyVisible method and overloads in the UIAutomation class.
- More method overloads for lots of method extensions in general.
- More Win32 function definitions in the corresponding NativeMethods namespace.
- Class HUDForm has been redesigned to accomplish some important design purposes, and class HUDFormLayout has been integrated in.
- Elektro.Core.IO.Keyboard.SendString() method from not sending special characters.
- Apart from the typical additions of methods and functions, the correction of some things, or the updating and refactoring of others, not only of the code but also of the documentation, these are some of important changes and innovations of this new version:
- A new experimental SafePInvoke method has been added in class Elektro.Interop.Tools.UnmanagedUtil, its purpose is double, to provide greater control when calling Win32 functions and to do so by writing less code than usual.
- A new class Elektro.Core.Xml.Tools.JsonUtil has been added, with utilities for JSON code, including converting a JSON code to several input types of Xml, and a method to embellish and/or minify a JSON code (BeautifyJson / MinifyJson).
- In the Elektro.Application.ThirdParty.Office365.Types namespace, class OutlookMailClient is renamed OutlookMailClientExperimental, and now there is a new class OutlookMailClient. The difference is that the new builds of the Microsoft API are used, I left the old version or “experimental” because in my case I find very useful, especially the ease of logging into an Outlook.com account.
- We have added a new type, Elektro.Core.IO.Types.FileSignature, with which we can create and represent a file signature. And type Elektro.Core.IO.Types.FileTypeMatch with which we can get the data from a signature analysis.
- More overloads added to class Elektro.System.Tools.Registry for manipulation of Windows registry entries.
- method extensions have been added in the Elektro.Core.Generics.Extensions.Nullable namespace for conversion between nullable data types.
- A new Elektro.Core.IO.Tools.FileTypeUtil class has been added, which is used to determine the file type of a file, by examining the header with a list of signatures (which is extendable at runtime).
- Added a new class Elektro.Multimedia.Gaming.Types.SnesRom to represent and manipulate a super nintendo rom (to do rom hacking).
- More predefined source templates and snippets have been added to the Elektro.Interop.Tools.CompilerUtil.SourceCodeTemplates namespace.
- A new Elektro.System.Tools.SystemInfo.Steam class has been added to get information about an installation of the Steam video game client.
- Class Elektro.System.Tools.SystemInfo.Volume has been added to obtain information about the volumes (partitions) mounted on the system.
- More tweaks have been added in class Elektro.System.Tools.Tweaking.SystemParameters to manipulate different aspects of the operating system configuration.
- ElektroKit is now also distributed under the .NET Framework 4.6.
- The AutomatedCompilerTask.exe tool that accompanies the ElektroKit source code, which is used to fully compile all configurations and platforms of the project, has been updated to support .NET Framework 4.6.
- Added class GoogleSearch to use the Google search service (for free) using type GoogleSearchOptions, and get the search results represented with type GoogleSearchResult.
- The generic method Elektro.Core.Diagnostics.Tools.ProfillingUtil.SwapObjects (Of T) (T, T) to invert the value of two objects.
- The method Elektro.Application.UI.Tools.CLI.CLIUtil.SpinCursor () and Elektro.Application.UI.Tools.CLI.CLIUtil.SpinCursorTask () to create a peculiar animation of “loading …” for a console application .
- Asynchronous methods have been added to class Elektro.Application.UI.Tools.CLI.TypeWritter
- The NameValueCollection.ToGETRequestString () extension to facilitate the formatting of a string to make a GET request to a Web service.
- More overloads added for the Elektro.Application.Tools.AppUtil.SleepRandom () method
- Class Elektro.Interop.Tools.CompilerUtil.SubsystemVersions goes from being private to public, for use that can be given out of ElektroKit.
- Class Elektro.Interop.Tools.CompilerUtil.SourceCodeTemplates renamed Elektro.Interop.Tools.CompilerUtil.Snippets.
- Overloads of the Elektro.Interop.Tools.CompilerUtil.CompileProject () method have been added in order to use the MsBuild.exe compiler for .NET Framework 4.5, 4.6, and 4.6.1,
- And also to compile a project-specific configuration and platform (eg Release -> Any CPU)
- A variety of extensions for type conversion and export formats for the following types: DataTable, DataGridView, ListView.
- In the Elektro.Application.Tools.AppUtil.SleepRandom() method, the TimeSpan parameter was interpreted in seconds, not milliseconds.
- All ElektroKit classes that inherit from EventArgs and Exception have been grouped into separate namespaces / directories, now the source code and its visual representation is somewhat more organized.
- Added class HUDForm in the namespace Elektro.Application.ThirdParty.SharpDX.Types to have the main base with which to be able to develop a HUD window for a third party game (it is very basic).
- Added class LibVideoUtil to download Youtube videos using the libvideo library (unofficial successor to YoutubeExtractor) Elektro.Application.ThirdParty.LibVideo.Tools.LibVideoUtil.
- Added several extension modules to facilitate the use of the official Youtube API, in the namespace: Elektro.Application.ThirdParty.Google.Youtube.Extensions.
- Added additional methods of unloading data in WebUtil class (DownloadData (), DownloadDataAsync (), DownloadImage (), DownloadImageAsync ()).
- Added additional extensions for file and directory recycling in extensions modules: Elektro.Core.IO.Extensions.FileInfo and Elektro.Core.IO.Extensions.DirectoryInfo. (FileInfo.Recycle () and DirectoryInfo.Recycle ())
- Added extension methods for grouping and joining groupings for IEnumerable collections, in the namespace: Elektro.Core.Generics.Extensions.IEnumerable (files: Group.vb and Join.vb).
- PS: Many of the mentioned features of ElektroKit are only available in the assemblies compiled under .Net Framework 4.5.
- In this version, the most important changes are aesthetic and do not affect the end user. I have literally had to modify one by one the more than a thousand classes / files that make up ElektroKit to make these changes; Has been a fairly complete refactoring of membership hierarchy and inheritance, so although this is not an update with many new features, it can be said that it is a great upgrade to call itself v1.7.
- It is worth mentioning that as a result of the aesthetic changes, the libraries occupy less, and the Xml documents much less.
- I have also corrected some small bugs, I have added new methods and types, and I have refactored some parts of the source code, but there is nothing to note about it.
- Type OutlookMailClient, to manage an online Outlook.com (Hotmail) account using the Microsoft Office 365 and Active Directory (ADAL) API. It is not a very complete class, but it facilitates and simplifies everyday tasks such as authorizing, accessing a folder, retrieving messages from a folder, deleting messages and / or moving them to another folder, so that a nice crawler can be developed in a few Few and simple steps, or other major …
- (This class uses asynchronous methods so it is only visible in the version of ElektroKit that runs under the .Net Framework 4.5 runtimes)
- Class ImgurUtil and type ImgurUploader, to host images on the Internet using the Imgur API.
- Class DwmPreviewManager, to manage the images that windows will use to generate the thumbnail preview of our app, as well as the peek preview (Aero Peek). This functionality is somewhat curious, I like to integrate exotic things.
- New properties to cheat some Windows parameters in class SystemParameters, such as show / hide hidden system files and protected files, activate / deactivate selection of Explorer items by checkbox selection, run instances of Explorer.exe In parallel processes, enable / disable the file deletion confirmation dialog, and much more !.
- (The changes made through these properties have an INSTANT effect, unlike other implementations that can be found on the Internet that are based on a sudden use of the Windows registry which implies a session restart to apply the changes ;-D)
- Methods for image compression (rather size reduction), and the extraction and / or counting of icons from a file, in ImageUtil class.
- Methods to check the version of the current operating system (including Windows 10), in class OS.
- Methods to manage the current power scheme, in class Power (see also type PowerPlan).
- Methods of loading and unloading registry Hives (SAM, NTUSER.DAT, etc.) in class Registry (methods: LoadHive and UnloadHive).
- Properties to set the error mode of the current application or thread, in class AppUtil (Properties: ProcessErrorMode and ThreadErrorMode)
- New methods of asynchronous file download, in WebUtil class.
- The ShowShellAboutDialog method in class Applets, to display a custom shell-about dialog.
- Methods to assign a process as critical, and also to assign or remove process privileges, in class ProcessUtil.
- Class VisualBasicProjectFileManager to handle the properties of a VB.NET project file (project.vbproj) at runtime.
- Class DelphiUtil with a simple type equivalence conversion method to help with interoperability between Delphi and .NET Framework.
- The following types for Win32 interoperability: SafeWindowHandle, SafeIconHandle, SafeBitmapHandle, SafeCursorHandle, SafeRegionHandle, and ZeroInvalidHandle (base class).
- The HResult enumeration to facilitate the programming of unmanaged code, which contains the most well-known HRESULT codes, including HRESULT codes controlled by .NET Framework managed exceptions.
- A large number of new Win32 (public) functions in class NativeMethods, with their corresponding types, interfaces and enumerations in the Elektro.Interop.Win32 namespace.
- Elektro.Application.ThirdParty.TagLibSharp namespace types have now been extensively extended, now support the manipulation of APEv2 and Lyrics3 tags.
- I have modified the name of all the values in the WindowsMessages and EditControlMessages enumeration, from the pattern “WmAbc” to “WM_Abc”; It is not correct to add a low script in .NET, but this will ease the usability experience when programming in unmanaged code.
- I’ve gutted and removed all unnecessary members of the third-party WindowsAPICodePack project, such as user controls, so it’s now a small, lightweight version specifically for using ElektroKit. Take it into account, because I have eliminated many features that came in the full version of Microsoft.
- The ElektroKit.sln project is now compiled with Visual Studio 2015, so I’m not sure if this will affect users trying to compile in earlier versions of Visual Studio.
- The total size of ElektroKit’s libraries, both in DEBUG and RELEASE mode, has been greatly reduced, now the total of all 9 .dll files weighs about 1.20 MB. This is due to the way Visual Studio 2015 compiles them.
- Class Input, which is related to the Win32 API RAW_INPUT (implemented in keylogging and mouselogging functionality in the Elektro.Core.IO namespace) has been divided into two distinct classes, Input32 and Input64. This is experimental and I have not tested it, in case Input32 does not work on 32-Bit computers then always use Input64 class, it should work.
- The RedirectUrl method in the WebUtil class did not redirect correctly if the url pointed to certain known services, such as a RapidGator.net url.
- The reason for this failure is specific to each server and its headers, but as a generalized and alternative solution I have added an overload to specify a custom user agent, which will work according to which services (for RapidGator.net, it works).
- The number of references R.C.W. was not being correctly lowered to 0. Of some COM objects that are used internally by some classes of ElektroKit,
- This has been fixed by directly calling the Marshal.FinalReleaseComObject () method instead of decrementing 1 single reference with Marshal.ReleaseComObject ().
- All unnecessary .NET Framework assemblies and namespaces have been cleaned and renamed.
- Some extension modules were not visible through Intellisense when trying to write the complete namespace, that’s because the name of the module was called in the same way as some method inside, the solution was to rename the conflicting modules.
- This change does not affect at all if we were using method extensions on a regular basis (type.Extension ()) and not writing the complete namespace (Namespace.Extension (type)).
- Constant refactorings / optimizations here and there, not really important, but the names of some members of ElektroKit may have changed, or how they are used.
- The number of assemblies has been reduced to 9, unifying several of them.
- A new assembly, Elektro.Core.dll, has been added, for the previous reason.
- Added a new assembly, Elektro.Application.ThirdParty.dll, with almost a multitude of utilities for third-party libraries, command-line application wrappers, extensions for third-party frameworks such as Telerik, etc.
- Around 100 new method extensions have been added in total.
- Many more uses have been added in general, methods, functions, types, interfaces, etc.
- Small optimizations, refactorings, corrections, and so on.
- Small optimizations, refactorings, corrections, and so on.
- A new namespace, Elektro.Diagnostics, with utilities focused on logging, debugging, profilling, etc.
- The namespace Elektro.Application.Debugging and Elektro.Application.Profilling have been joined in the Elektro.Diagnostics namespace. (For design reasons)
- The Elektro.Audio namespace is renamed to Elektro.Multimedia. (For design reasons)
- The Elektro.Strings namespace is renamed to Elektro.Text. (For design reasons)
- The Elektro.Strings.RegEx namespace is renamed to Elektro.Text.RegEx. (For design reasons)
- All namespaces names of method extensions have been modified. (For design reasons)
- Class NetworkUtil of the namespace Elektro.Net has been divided into several classes focused on different topics. (For reasons of design and organization)
- The amount of method extensions has been dramatically expanded, now they are around 500 extensions.
- The source code of the WindowsAPICodePack dependency has been integrated, basically, into the ElektroKit source code (for portability reasons)
- Expanded architecture platforms in which ElektroKit libraries are distributed, are now classified in AnyCpu, x64, and x86. (For reasons of portability)
- Code optimizations have been added for .Net Framework +4.5, but they are so few at the moment that I have decided not to compile these libraries in this release.
- All modules of the source code have been divided into several modules, and some classes as well. (For organizational reasons)
- The number of code examples in the ElektroKit help file for methods, functions, and properties has been greatly expanded.
- Some bugfixes without too much importance.
- class KeyboardMonitor, to mnitor and report keyboard evenets (a keylogger).
- class MouseMonitor, to mnitor and report mouse evenets.
- class Keyboard, to synthetize keyboard input.
- class Mouse, to synthetize mouse input.
- base class UndoRedo and inherited classes, a system to undo and redo actions on controls.
- class Hosts, to manage Hosts mappings.
- class FirewallUtil, to manage to manage firewall, enable, disable, add or remove firewall rules, etc.
- type CSharpCompiler, to compile source code at runtime.
- type VisualBasicCompiler, to compile source code at runtime.
- generic type FixedStack(Of T).
- generic type FixedQueue(Of T).
- WindowMagnetizer class, to add “magnetism” to the window of your application (to adhere it to the edges of the screen)
- The IniSection, IniKey, IniSectionCollection, IniKeyCollection and IniManager classes, to manage the user configurations of your applications in portable INI files.
- The classes MruItem, MruFileItem and MruUtil, to create and load MRU lists in your applications.
- Type Hotkey, for global keyboard shortcuts (system-wide hotkeys) in your applications, very simply and efficiently.
- A plenty of P/invokes added in the Win32 namespace, for use in their applications as they please.
- Many methods extensions added for different types in general.