Table of Contents

Class ChartTools

Namespace
LightningChartLib.WinForms.Charting
Assembly
LightningChart.WinForms.Charting.NET4.dll

Chart tools provides versatile static methods.

public class ChartTools
Inheritance
ChartTools
Inherited Members

Constructors

ChartTools()

LightningChartLib.WinForms.Charting.ChartTools
public ChartTools()

Methods

AdjustBitmapAlpha(Bitmap, int)

Adjusts bitmap alpha to given level for every pixel. Doesn't modify the input bitmap.

public static Bitmap AdjustBitmapAlpha(Bitmap bitmapIn, int alpha)

Parameters

bitmapIn Bitmap

Input bitmap.

alpha int

Alpha.

Returns

Bitmap

Bitmap with selected alpha.

AntiAliasBitmap(Bitmap, BitmapAntialiasOptions)

Anti-alias bitmap. Makes anti-aliasing for image, or blur-effect.

public static Bitmap AntiAliasBitmap(Bitmap bitmapIn, BitmapAntialiasOptions options)

Parameters

bitmapIn Bitmap

Source bitmap to be anti-aliased.

options BitmapAntialiasOptions

Anti-aliasing options.

Returns

Bitmap

Creates the correct size output bitmap and returns it. If invalid parameters are given, returns null.

BitmapSegmentFromBitmap(Bitmap, int, int, int, int)

Get a segment (sub-region) of a bitmap.

public static Bitmap BitmapSegmentFromBitmap(Bitmap bitmapIn, int firstColumnIndex, int segmentWidth, int firstRowIndex, int segmentHeight)

Parameters

bitmapIn Bitmap

Source bitmap.

firstColumnIndex int

Index of first column to appear in output bitmap.

segmentWidth int

Segment width in pixels.

firstRowIndex int

Index of first row to appear in output bitmap.

segmentHeight int

Segment height in pixels.

Returns

Bitmap

Bitmap segment an a new bitmap.

Remarks

Works only with bitmaps having Format32bppArgb format. Convert it before calling this method, if needed.

CalcGradient(Color, Color, double)

Calculates the gradient color between two colors.

public static Color CalcGradient(Color colorFrom, Color colorTo, double positionPercents)

Parameters

colorFrom Color

From-color.

colorTo Color

To-color.

positionPercents double

Gradient color position in percents (0...100%).

Returns

Color

Gradient color.

CalcPolygonArea(PointDouble2D[])

Get polygon area.

public static double CalcPolygonArea(PointDouble2D[] points)

Parameters

points PointDouble2D[]

Polygon route points.

Returns

double

Area of polygon.

Remarks

Use a closed route, where last point has same values than the first point.

CalcPolygonCenterOfGravity(PointDouble2D[])

Calculate center of gravity (centroid) of a homogenous polygon.

public static PointDouble2D CalcPolygonCenterOfGravity(PointDouble2D[] points)

Parameters

points PointDouble2D[]

Polygon route points.

Returns

PointDouble2D

Center of gravity point.

Remarks

Use a closed route, where last point has same values than the first point.

CalculateMapCoordSphericalAngles(MapCoordinate, double, out double, out double)

Calculate map coordinate spherical angles, phi and theta.

public static void CalculateMapCoordSphericalAngles(MapCoordinate coordinate, double sphereRadius, out double phi, out double theta)

Parameters

coordinate MapCoordinate

Coordinate.

sphereRadius double

Sphere radius.

phi double

Phi angle in degrees.

theta double

Theta angle in degrees.

CalculateMapDistance(MapCoordinate, MapCoordinate)

Calculate distance between two coordinates in world map, by using two coordinates.

public static double CalculateMapDistance(MapCoordinate coordinate1, MapCoordinate coordinate2)

Parameters

coordinate1 MapCoordinate

First coordinate.

coordinate2 MapCoordinate

Second coordinate.

Returns

double

Distance in kilometers.

CalculateMapDistance(PointFloat, PointFloat)

Calculate distance between two coordinates in world map, by using latitude and longitude.

public static double CalculateMapDistance(PointFloat coord1, PointFloat coord2)

Parameters

coord1 PointFloat

First coordinate.

coord2 PointFloat

Second coordinate.

Returns

double

Distance in kilometers.

CalculateMapDistance(double, double, double, double)

Calculate distance between two coordinates in world map, by using latitude and longitude.

public static double CalculateMapDistance(double longitude1, double latitude1, double longitude2, double latitude2)

Parameters

longitude1 double

First point longitude.

latitude1 double

First point latitude.

longitude2 double

Second point longitude.

latitude2 double

Second point latitude.

Returns

double

Distance in kilometers.

CalculateMapDistance(PointF, PointF)

Calculate distance between two coordinates in world map, by using latitude and longitude.

public static double CalculateMapDistance(PointF coord1, PointF coord2)

Parameters

coord1 PointF

First coordinate.

coord2 PointF

Second coordinate.

Returns

double

Distance in kilometers.

CalculateSphereFullGreatCircleCoords(MapCoordinate, MapCoordinate, double)

Calculate great circle coords for sphere.

public static MapCoordinate[] CalculateSphereFullGreatCircleCoords(MapCoordinate beginPoint, MapCoordinate endPoint, double angleStep)

Parameters

beginPoint MapCoordinate

Begin point.

endPoint MapCoordinate

End point.

angleStep double

Angle step.

Returns

MapCoordinate[]
returns M:LightningChartLib.WinForms.Charting.ChartTools.CalculateSphereFullGreatCircleCoords(LightningChartLib.WinForms.Charting.MapCoordinate,LightningChartLib.WinForms.Charting.MapCoordinate,System.Double)

CalculateSphericalRoute(MapCoordinate, MapCoordinate, double, double)

Calculate a spherical route (going shortest way, in sphere surface). This is also known as Great Circle route.

public static MapCoordinate[] CalculateSphericalRoute(MapCoordinate beginPoint, MapCoordinate endPoint, double sphereRadius, double angleStep)

Parameters

beginPoint MapCoordinate

Route begin coordinate.

endPoint MapCoordinate

Route end coordinate.

sphereRadius double

Sphere radius.

angleStep double

Angle step.

Returns

MapCoordinate[]

Route waypoints.

CaptureControlToBitmap(Control)

Captures a Control area to a bitmap, very fast. Great for making

  • Chart
  • Any other Control
  • Form capture into set of images.
public static Bitmap CaptureControlToBitmap(Control control)

Parameters

control Control

Control to capture.

Returns

Bitmap

Bitmap.

ColorHSVA(double, double, double, double)

hue = angle of color circle where 0 deg = red, 120 deg = green, 240 deg = blue. saturation: defines the brilliance and intensity of a color. default = 1,range = 0-1 value refers to the lightness or darkness of a color. default = 1, range = 0-1 alfa describes the transparency. default = 1. range = 0-1

public static Color ColorHSVA(double hue, double saturation = 1, double value = 1, double alfa = 1)

Parameters

hue double
param hue M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double)
saturation double
param saturation M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double)
value double
param value M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double)
alfa double
param alfa M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double)

Returns

Color
returns M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double)

ColorToInt(Color)

Drawing color to integer.

public static int ColorToInt(Color color)

Parameters

color Color

Color.

Returns

int

Drawing color as ARGB value.

Convert2DArrayTo1D<T>(T[,])

Convert 2-dimensional array to 1-dimensional, row by row

public static T[] Convert2DArrayTo1D<T>(T[,] array) where T : struct

Parameters

array T[,]

2D array

Returns

T[]

1D array

Type Parameters

T

Type of item

ConvertDataToColorsByFixedIntervalPalette(double[], double[], Color[])

Convert data values to colors, by given palette. Palette is defined by steps, consisting of value and corresponding color. E.g. 0 : Black, 50: Yellow, 100: Red. The output colors are interpolated based on their position between steps. E.g. in this example palette, data value 60 will be almost yellow, but a little bit blending with red.

public static int[] ConvertDataToColorsByFixedIntervalPalette(double[] dataValues, double[] paletteStepValues, Color[] paletteStepColors)

Parameters

dataValues double[]

Data values.

paletteStepValues double[]

Values of palette. Count must be equal to step color count.

paletteStepColors Color[]

Colors of palette. Count must be equal to step value count.

Returns

int[]

Colors as ARGB integer values.

Remarks

Use fixed interval palette steps only. E.g. 0, 25, 50, 75, 100. NOT like 0, 10, 40, 50, 80, 100.

ConvertDoubleArrayToBitmap(double[][], Color[], double, double)

Convert double array into colors, by using gradient fixed-interval palette.

public static Bitmap ConvertDoubleArrayToBitmap(double[][] array, Color[] colors, double minValue, double maxValue)

Parameters

array double[][]

Jagged array matrix, M x N.

colors Color[]

Colors.

minValue double

Minimum value, which represents the first color.

maxValue double

Maximum value, which represents the last color.

Returns

Bitmap

Bitmap.

ConvertDoubleArrayToIndexed8Bitmap(double[][], Color[], double, double)

Convert double array into Indexed8 bitmap, by using uniform fixed-interval palette. NOTE! Can't use more than 256 colors. If input contains more colors, last ones will be truncated.

public static Bitmap ConvertDoubleArrayToIndexed8Bitmap(double[][] array, Color[] colors, double minValue, double maxValue)

Parameters

array double[][]

Jagged array matrix, M x N.

colors Color[]

Colors.

minValue double

Minimum value, which represents the first color.

maxValue double

Maximum value, which represents the last color.

Returns

Bitmap

Bitmap.

ConvertDoubleArrayToIndexed8Bitmap(double[][], int, int, double, double, byte[], byte[], byte[], byte[])

Convert Array of Double to Indexed8 Bitmap. NOTE! Can't use more than 256 colors. If input contains more colors, last ones will be truncated.

public static Bitmap ConvertDoubleArrayToIndexed8Bitmap(double[][] array, int width, int height, double maxValue, double minValue, byte[] colorsA, byte[] colorsR, byte[] colorsG, byte[] colorsB)

Parameters

array double[][]

Double array.

width int

Width.

height int

Height.

maxValue double

Maximum value.

minValue double

Minimum value.

colorsA byte[]

Alpha array.

colorsR byte[]

Red array.

colorsG byte[]

Green array.

colorsB byte[]

Blue array.

Returns

Bitmap

Bitmap frame.

ConvertFromString(string)

Convert Hex to Winforms color

public static Color ConvertFromString(string hex)

Parameters

hex string

Hex string

Returns

Color

Converted color. If unable to convert a color channel (a, r, g, b), returns 0 to that channel.

ConvertImageToFormat32bppArgb(Image)

Converts image format to 32 bits ARGB.

public static Image ConvertImageToFormat32bppArgb(Image sourceImage)

Parameters

sourceImage Image

Source image, which is not in 32bppArgb format.

Returns

Image

Image in 32bbArgb format.

ConvertMapCoordDMSToDegrees(int, uint, double)

Convert DMS (Degrees, minutes, seconds) value to decimal degrees value.

public static double ConvertMapCoordDMSToDegrees(int degrees, uint arcMinutes, double arcSeconds)

Parameters

degrees int

Degrees.

arcMinutes uint

Arc minutes.

arcSeconds double

Arc seconds.

Returns

double

Degrees value.

ConvertMapCoordDMSToDegrees(uint, uint, double, CoordPostfix)

Convert DMS (Degrees, minutes, seconds) value to decimal degrees value, with given post-fix (N,E,S,W).

public static double ConvertMapCoordDMSToDegrees(uint degrees, uint arcMinutes, double arcSeconds, CoordPostfix postfix)

Parameters

degrees uint

Degrees.

arcMinutes uint

Arc minutes.

arcSeconds double

Arc seconds.

postfix CoordPostfix

Postfix.

Returns

double

Degrees value.

ConvertMapCoordTo3DPointOnSphere(MapCoordinate, double)

Convert map coordinate to a point in 3D space. The 3D space has origin in (0,0,0).

public static PointDouble3D ConvertMapCoordTo3DPointOnSphere(MapCoordinate mapCoordinate, double sphereRadius)

Parameters

mapCoordinate MapCoordinate

Map coordinate.

sphereRadius double

Sphere radius.

Returns

PointDouble3D

3D point.

ConvertTicksToSeconds(long)

Converts time ticks to seconds, accurately.

public static double ConvertTicksToSeconds(long ticks)

Parameters

ticks long

Ticks value.

Returns

double

Seconds value.

Remarks

This method is very precise, when compared to using TimeSpan.TotalSeconds.

CreateGrayscaleAlphaMap(Bitmap)

Create a grayscale bitmap of source bitmap's pixels' alpha level. White output pixel means A = 255, Black means A = 0, and grayscales values between them.

public static Bitmap CreateGrayscaleAlphaMap(Bitmap bitmapIn)

Parameters

bitmapIn Bitmap

Source bitmap whose alpha level is to be investigated pixel-by-pixel.

Returns

Bitmap

Bitmap having alpha RGB values as grayscale, and alpha 255 in each output pixel.

CreateMap(double[][][], Color[], double, double)

Convert 3-dimensional array to texture map.

public static Bitmap CreateMap(double[][][] data, Color[] colors, double minValue, double maxValue)

Parameters

data double[][][]

3-Dimensional array.

colors Color[]

Color array.

minValue double

Minimal value of the dataset.

maxValue double

Maximal value of the dataset.

Returns

Bitmap

Texture Map.

CreateMap(Bitmap[])

Load all images from the folder and return them as texture map.

public static Bitmap CreateMap(Bitmap[] imgs)

Parameters

imgs Bitmap[]

List of bitmaps.

Returns

Bitmap

Texture Map.

CreateMap(string)

Load all images from the folder and return them as texture map.

public static Bitmap CreateMap(string filePath)

Parameters

filePath string

Path to the folder.

Returns

Bitmap

Texture Map.

ExtractValues(IntensityPoint[,])

Create a jagged array of Intensity series data (IntensityPoint array). Extracts IntensityPoint.Value fields.

public static double[][] ExtractValues(IntensityPoint[,] data)

Parameters

data IntensityPoint[,]

Data.

Returns

double[][]

Values array.

GatherApplicationInformation(GatherDataOptions, LightningChart, string, string)

Gathers various information for debugging purposes as a string and optionally saves the output to a text file. Gathered data (if ChartTools.GatherDataOptions is set to All): system information, LightningChart object information, list of running processes, DxDiag output, installed Windows hotfixes.

[SecurityCritical]
public static string GatherApplicationInformation(ChartTools.GatherDataOptions options, LightningChart chart = null, string path = null, string fileName = null)

Parameters

options ChartTools.GatherDataOptions

Data gathering options flags. See ChartTools.GatherDataOptions.

chart LightningChart

LightningChart object (optional, leave null if not running with a LightningChart instance).

path string

Path to folder where file is saved (optional, if not specified the data won't be saved to a file and just returned as a string).

fileName string

Output text file filename (optional, if not specified the default name is created with timestamp).

Returns

string

The gathered data as a string.

GetAllControls(Control, bool)

Get all controls and its subcontrols

public static List<Control> GetAllControls(Control control, bool getSubControls)

Parameters

control Control

Control whose controls are to investigated

getSubControls bool

Give true if control's subcontrols are seeked too (recursive)

Returns

List<Control>

List of contorls

GetPixelColors(Bitmap)

Get pixel color of a bitmap. This is much faster method than calling GetPixel() separately for each pixel of a bitmap.

public static Color[,] GetPixelColors(Bitmap bitmapIn)

Parameters

bitmapIn Bitmap

Bitmap.

Returns

Color[,]

Pixel colors as an array.

ImageFromResource(string, Assembly)

Create image from assembly embedded resource. Includes assembly name in the beginning of resource name.

public static Image ImageFromResource(string resourceName, Assembly resourceAssembly)

Parameters

resourceName string

Resource name, without assembly identifier. E.g. "Resources.ArctionLogo.png", not like "Arction.DemoApp.Resources.ArctionLogo.png"

resourceAssembly Assembly

Assembly where the resource is located

Returns

Image

Image if success, else null

Remarks

Don't use this method if namespace is different from assembly name.

ImageFromResourceFullName(string, Assembly)

Create image from assembly embbedded resource

public static Image ImageFromResourceFullName(string fullyQualifiedName, Assembly resourceAssembly)

Parameters

fullyQualifiedName string

Fully qualified resource name.

resourceAssembly Assembly

Assembly where the resource is located.

Returns

Image

Image if success, otherwise null.

IntensityValuesToIntensityGridPoints(double[][])

Convert intensity values jagged array to intensity grid points. Fills IntensityPoint.Value fields only.

public static IntensityPoint[,] IntensityValuesToIntensityGridPoints(double[][] values)

Parameters

values double[][]

Values.

Returns

IntensityPoint[,]

Rectangular array of intensity points.

Remarks

The alignment must be M x N, all rows must be of equal length.

InterpolateBilinear(double[][], int, int)

Makes bilinear interpolation for given data array.

public static double[][] InterpolateBilinear(double[][] sourceArray, int factorX, int factorY)

Parameters

sourceArray double[][]

Source data array.

factorX int

X density multiplier.

factorY int

Y density multiplier.

Returns

double[][]

Interpolated data array.

Remarks

The alignment must be M x N, all rows must be of equal length.

Is64BitProcess()

Find out if this process needs 64-bit DLLs.

public static bool Is64BitProcess()

Returns

bool

True if 64-bit DLLs are needed. False if it's happy with 32-bit DLLs.

LoadImages(string)

Load all images from folder.

public static Bitmap[] LoadImages(string folderName)

Parameters

folderName string

Path to the folder.

Returns

Bitmap[]

Array of images from folder.

Rotate3DCoordinate(PointDouble3D, double, double, double)

Rotate 3D coordinate with yaw - pitch - roll method.

public static PointDouble3D Rotate3DCoordinate(PointDouble3D point, double angleAboutXAxis, double angleAboutYAxis, double angleAboutZAxis)

Parameters

point PointDouble3D

3D coordinate.

angleAboutXAxis double

Rotation angle in degrees, about X-axis.

angleAboutYAxis double

Rotation angle in degrees, about Y-axis.

angleAboutZAxis double

Rotation angle in degrees, about Z-axis.

Returns

PointDouble3D

Rotated coordinate.

RoundToNearestInterval(double, double)

Rounds the value to nearest multiple of Interval.

public static double RoundToNearestInterval(double value, double interval)

Parameters

value double

Value to round.

interval double

Interval.

Returns

double

Nearest interval multiple.

SamePoint(PointFloat, PointFloat)

Test if two point equals.

public static bool SamePoint(PointFloat p1, PointFloat p2)

Parameters

p1 PointFloat

Point 1.

p2 PointFloat

Point 2.

Returns

bool

True is points are at about same locations.

ShowLoadedAssemblies()

Show list of loaded assemblies by this application.

public static void ShowLoadedAssemblies()

SolvePointBetweenPoints(PointFloat, PointFloat, float, out PointFloat)

Solve point within a line going from Point1 to Point2.

public static bool SolvePointBetweenPoints(PointFloat point1, PointFloat point2, float distanceFromP1, out PointFloat result)

Parameters

point1 PointFloat

First point.

point2 PointFloat

Second point.

distanceFromP1 float

Distance from Point1 towards Point2.

result PointFloat

Solved point.

Returns

bool

Returns true if successfully solved (length is not 0).

SolvePointBetweenPoints(PointFloatXYZ, PointFloatXYZ, float)

Solve point within a line going from Point1 to Point2.

public static PointFloatXYZ SolvePointBetweenPoints(PointFloatXYZ point1, PointFloatXYZ point2, float fPointPositionFromP1)

Parameters

point1 PointFloatXYZ

First point

point2 PointFloatXYZ

Second point

fPointPositionFromP1 float

Position in range 0...1.

Returns

PointFloatXYZ

Point in position.

WriteLog(string)

Write a string to log file. The log file is c:\temp\LightningChartLog.txt.

public static void WriteLog(string entry)

Parameters

entry string

String to write.

WriteLog(string, string)

Write a string to log file.

public static void WriteLog(string entry, string fileName)

Parameters

entry string

String to write.

fileName string

File name.

ZoomToDataAndLabelsArea(LightningChart)

Zoom to data and label area.

public static void ZoomToDataAndLabelsArea(LightningChart chart)

Parameters

chart LightningChart

Chart to apply zooming.