CoreTools 1.3.0

dotnet add package CoreTools --version 1.3.0
NuGet\Install-Package CoreTools -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoreTools" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CoreTools --version 1.3.0
#r "nuget: CoreTools, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CoreTools as a Cake Addin
#addin nuget:?package=CoreTools&version=1.3.0

// Install CoreTools as a Cake Tool
#tool nuget:?package=CoreTools&version=1.3.0

❗ ADVICE: This project was merged into WpfCoreTools and, unless further notice, will not be updated anymore. For wpf applications use WpfCoreTools instead.

CoreTools

Lightweight package with some utilities for .NET Core.

Dependencies

net6 net7 drawing_common

Content

Content of the package:

GDIUtils

This static class contains the following functions:

Color GetPixelColor(Point pos, [bool takeScreenshotWhenPossible = false])

Returns the color of the pixel at a specified position.
Parameters:
pos: Position of the pixel from to get the color.
takeScreenshotWhenPossible: Take a screenshot when possible to get the pixel color (this may be slower and is supported only in Windows).

Color GetPixelColorAtCursorPos([bool takeScreenshotWhenPossible = false])

Returns the color of the pixel at the current cursor position on display.
Parameters:
takeScreenshotWhenPossible: Take a screenshot when possible to get the pixel color (this may be slower and is supported only in Windows).

Bitmap CaptureScreenshot(Point pos, Size size)

Captures a screenshot from a specified position, with a specified size.
Parameters:
pos: Top-left corner of the screenshot.
size: Size of the screenshot.

Bitmap CaptureScreenshotAtCursorPos(Size size, Size offset)

Captures a screenshot from the current cursor position on display, with a specified size, and offset.
Parameters:
size: Size of the screenshot.
offset: Offset of the screenshot.

Bitmap CaptureScreenshotAtCursorPos(Size size)

Captures a screenshot from the current cursor position on display, with a specified size.
Parameters:
size: Size of the screenshot.

GraphicUtils

This static class contains the following functions:

Point GetCursorPos()

Returns the current cursor position on display.

SystemUtils

This static class contains the following functions:

FileInfo GetExecutingFile()

Returns the current application executing file.

DirectoryInfo GetExecutingDirectory()

Returns the current application executing directory.

ColorExtensions

This static class provides a set of Color extensions:

Color Invert()

Inverts the Color by subtracting every value R, G, B from 255.

SizeExtensions

This static class provides a set of Size extensions:

Size Invert()

Inverts the Size by replacing every value with its negative.

Size UniformSize(int dim)

Initializes a new Size with uniform dimensions.
Parameters:
dim: Dimensions.

StringExtensions

This static class provides a set of string extensions:

bool IsDouble()

Checks if the string is a double.

bool IsInt()

Checks if the string is an int.

bool IsNumeric()

Checks if the string contains only numeric chars.

string NormalizeForDouble([bool ignoreFractionalZeros = true])

Normalizes the string for the type double.
Parameters:
ignoreFractionalZeros: Ignore if there are only zeros as the fractional part to speed up the algorithm.

string NormalizeForInt()

Normalizes the string for the type int.

string Append(char c)

Appends a char at the end of the string.
Parameters:
c: char to append.

string Append(string str)

Appends a string at the end of the string.
Parameters:
str: string to append.

string Reduce(int count)

Cuts the string by removing a specified number of chars from the end of the string.
Parameters:
count: Number of chars to remove from the end of the string.

string TakeStr(int count)

Returns a string by taking only the specified number of chars from the start of the string.
Parameters:
count: Number of chars to take from the start of the string.

string ToInt(int defaultValue)

Converts the string to an int. In case of errors returns a specified default value.
Parameters:
defaultValue: The default value used in case of errors.

string ToDouble(double defaultValue)

Converts the string to a double. In case of errors returns a specified default value.
Parameters:
defaultValue: The default value used in case of errors.

T? ParseTo<T>(T? defaultValue)

Converts the string to the specific type using a TypeDescriptor converter. In case of errors returns a specified default value.
Parameters:
defaultValue: The default value used in case of errors.

License

Copyright (C) 2021-2023 devpelux (Salvatore Peluso)
Licensed under MIT license.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 229 2/16/2023
1.2.0 782 5/20/2022
1.1.1.1 433 4/28/2022
1.1.0 531 12/29/2021
1.0.1 258 12/25/2021
1.0.0 488 12/23/2021

Added support for .NET 7.0.
Dropped support for .NET 5.0.
Updated dependencies.