If you need to show a list of languages, or more general CultureInfos, you might want to sort them by the name they show up…
Calculating a leap year The correct calculation of a leap year was first introduced by pope Gregor in 1582. The Gregorian Calendar is still commonly…
You can simply use styles to enable text wrapping in a WPF DataGrid Column. This sets the element style of the standard column control and…
This checks the availability of a server by sending a ping to the given IP address and waiting a certain amount of time for a…
Not all possible characters are suitable for file names. For example path separators cannot be used for file names. This changes any string into a…
The following functions can be used to convert an image object to a byte array (and vise versa). This is often used to store images…
The following code snippet checks if the current user as administrator rights: /// <summary> /// Checks if user has administrator rights /// </summary> public static bool UserIsAdmin() { WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); return principal.IsInRole(WindowsBuiltInRole.Administrator); } If the application requires…
The following C# code changes an image object into an icon. public static Icon ConvertImageToIcon(Image img) { if (img == null) return null; Bitmap square…
The following function changes the size of an image object and optionally changes the ratio of the image or crops the image. Perfectly for creating…