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()
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
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
bitmapInBitmapSource bitmap to be anti-aliased.
optionsBitmapAntialiasOptionsAnti-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
bitmapInBitmapSource bitmap.
firstColumnIndexintIndex of first column to appear in output bitmap.
segmentWidthintSegment width in pixels.
firstRowIndexintIndex of first row to appear in output bitmap.
segmentHeightintSegment 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
colorFromColorFrom-color.
colorToColorTo-color.
positionPercentsdoubleGradient color position in percents (0...100%).
Returns
- Color
Gradient color.
CalcPolygonArea(PointDouble2D[])
Get polygon area.
public static double CalcPolygonArea(PointDouble2D[] points)
Parameters
pointsPointDouble2D[]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
pointsPointDouble2D[]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
coordinateMapCoordinateCoordinate.
sphereRadiusdoubleSphere radius.
phidoublePhi angle in degrees.
thetadoubleTheta 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
coordinate1MapCoordinateFirst coordinate.
coordinate2MapCoordinateSecond 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
coord1PointFloatFirst coordinate.
coord2PointFloatSecond 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
longitude1doubleFirst point longitude.
latitude1doubleFirst point latitude.
longitude2doubleSecond point longitude.
latitude2doubleSecond 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
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
beginPointMapCoordinateBegin point.
endPointMapCoordinateEnd point.
angleStepdoubleAngle 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
beginPointMapCoordinateRoute begin coordinate.
endPointMapCoordinateRoute end coordinate.
sphereRadiusdoubleSphere radius.
angleStepdoubleAngle 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
controlControlControl 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
huedoubleparam hue M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double) saturationdoubleparam saturation M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double) valuedoubleparam value M:LightningChartLib.WinForms.Charting.ChartTools.ColorHSVA(System.Double,System.Double,System.Double,System.Double) alfadoubleparam 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
colorColorColor.
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
arrayT[,]2D array
Returns
- T[]
1D array
Type Parameters
TType 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
dataValuesdouble[]Data values.
paletteStepValuesdouble[]Values of palette. Count must be equal to step color count.
paletteStepColorsColor[]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
arraydouble[][]Jagged array matrix, M x N.
colorsColor[]Colors.
minValuedoubleMinimum value, which represents the first color.
maxValuedoubleMaximum 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
arraydouble[][]Jagged array matrix, M x N.
colorsColor[]Colors.
minValuedoubleMinimum value, which represents the first color.
maxValuedoubleMaximum 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
arraydouble[][]Double array.
widthintWidth.
heightintHeight.
maxValuedoubleMaximum value.
minValuedoubleMinimum value.
colorsAbyte[]Alpha array.
colorsRbyte[]Red array.
colorsGbyte[]Green array.
colorsBbyte[]Blue array.
Returns
- Bitmap
Bitmap frame.
ConvertFromString(string)
Convert Hex to Winforms color
public static Color ConvertFromString(string hex)
Parameters
hexstringHex 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
sourceImageImageSource 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
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
degreesuintDegrees.
arcMinutesuintArc minutes.
arcSecondsdoubleArc seconds.
postfixCoordPostfixPostfix.
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
mapCoordinateMapCoordinateMap coordinate.
sphereRadiusdoubleSphere radius.
Returns
- PointDouble3D
3D point.
ConvertTicksToSeconds(long)
Converts time ticks to seconds, accurately.
public static double ConvertTicksToSeconds(long ticks)
Parameters
tickslongTicks 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
bitmapInBitmapSource 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
datadouble[][][]3-Dimensional array.
colorsColor[]Color array.
minValuedoubleMinimal value of the dataset.
maxValuedoubleMaximal 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
imgsBitmap[]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
filePathstringPath 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
dataIntensityPoint[,]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
optionsChartTools.GatherDataOptionsData gathering options flags. See ChartTools.GatherDataOptions.
chartLightningChartLightningChart object (optional, leave null if not running with a LightningChart instance).
pathstringPath 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).
fileNamestringOutput 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
controlControlControl whose controls are to investigated
getSubControlsboolGive true if control's subcontrols are seeked too (recursive)
Returns
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
bitmapInBitmapBitmap.
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
resourceNamestringResource name, without assembly identifier. E.g. "Resources.ArctionLogo.png", not like "Arction.DemoApp.Resources.ArctionLogo.png"
resourceAssemblyAssemblyAssembly 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
fullyQualifiedNamestringFully qualified resource name.
resourceAssemblyAssemblyAssembly 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
valuesdouble[][]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
sourceArraydouble[][]Source data array.
factorXintX density multiplier.
factorYintY 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
folderNamestringPath 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
pointPointDouble3D3D coordinate.
angleAboutXAxisdoubleRotation angle in degrees, about X-axis.
angleAboutYAxisdoubleRotation angle in degrees, about Y-axis.
angleAboutZAxisdoubleRotation 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
Returns
- double
Nearest interval multiple.
SamePoint(PointFloat, PointFloat)
Test if two point equals.
public static bool SamePoint(PointFloat p1, PointFloat p2)
Parameters
p1PointFloatPoint 1.
p2PointFloatPoint 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
point1PointFloatFirst point.
point2PointFloatSecond point.
distanceFromP1floatDistance from Point1 towards Point2.
resultPointFloatSolved 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
point1PointFloatXYZFirst point
point2PointFloatXYZSecond point
fPointPositionFromP1floatPosition 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
entrystringString to write.
WriteLog(string, string)
Write a string to log file.
public static void WriteLog(string entry, string fileName)
Parameters
ZoomToDataAndLabelsArea(LightningChart)
Zoom to data and label area.
public static void ZoomToDataAndLabelsArea(LightningChart chart)
Parameters
chartLightningChartChart to apply zooming.