You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1312 lines
39 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace DNSD_Controls
{
/// <summary>
/// 整个组件的代码辅助工具,提供了一个基础的类库方法
/// </summary>
// Token: 0x02000034 RID: 52
public class HslHelper
{
// Token: 0x060004EA RID: 1258 RVA: 0x0003319C File Offset: 0x0003139C
static HslHelper()
{
HslHelper.StringFormatCenter = new StringFormat();
HslHelper.StringFormatCenter.Alignment = StringAlignment.Center;
HslHelper.StringFormatCenter.LineAlignment = StringAlignment.Center;
HslHelper.StringFormatLeft = new StringFormat();
HslHelper.StringFormatLeft.LineAlignment = StringAlignment.Center;
HslHelper.StringFormatLeft.Alignment = StringAlignment.Near;
HslHelper.StringFormatRight = new StringFormat();
HslHelper.StringFormatRight.LineAlignment = StringAlignment.Center;
HslHelper.StringFormatRight.Alignment = StringAlignment.Far;
HslHelper.StringFormatTopCenter = new StringFormat();
HslHelper.StringFormatTopCenter.Alignment = StringAlignment.Center;
HslHelper.StringFormatTopCenter.LineAlignment = StringAlignment.Near;
}
/// <summary>
/// 返回中间范围值数据,如果大于最大值,则返回最大值,如果小于最小值,则返回最小值
/// </summary>
/// <param name="min">最小值</param>
/// <param name="value">实际值</param>
/// <param name="max">最大值</param>
/// <returns>中间值信息</returns>
// Token: 0x060004EB RID: 1259 RVA: 0x00033244 File Offset: 0x00031444
public static int Middle(int min, int value, int max)
{
bool flag = value > max;
int result;
if (flag)
{
result = max;
}
else
{
bool flag2 = value < min;
if (flag2)
{
result = min;
}
else
{
result = value;
}
}
return result;
}
/// <summary>
/// 从一个矩形的图形中获取菱形的坐标数组
/// </summary>
/// <param name="rect">矩形</param>
/// <returns>数组结果</returns>
// Token: 0x060004EC RID: 1260 RVA: 0x00033270 File Offset: 0x00031470
public static Point[] GetRhombusFromRectangle(Rectangle rect)
{
return new Point[]
{
new Point(rect.X, rect.Y + rect.Height / 2),
new Point(rect.X + rect.Width / 2, rect.Y + rect.Height - 1),
new Point(rect.X + rect.Width - 1, rect.Y + rect.Height / 2),
new Point(rect.X + rect.Width / 2, rect.Y),
new Point(rect.X, rect.Y + rect.Height / 2)
};
}
/// <summary>
/// 计算绘图时的相对偏移值
/// </summary>
/// <param name="max">0-100分的最大值就是指准备绘制的最大值</param>
/// <param name="min">0-100分的最小值就是指准备绘制的最小值</param>
/// <param name="height">实际绘图区域的高度</param>
/// <param name="value">需要绘制数据的当前值</param>
/// <returns>相对于0的位置还需要增加上面的偏值</returns>
// Token: 0x060004ED RID: 1261 RVA: 0x00033350 File Offset: 0x00031550
public static float ComputePaintLocationY(int max, int min, int height, int value)
{
bool flag = (float)(max - min) == 0f;
float result;
if (flag)
{
result = (float)height;
}
else
{
result = (float)height - (float)(value - min) * 1f / (float)(max - min) * (float)height;
}
return result;
}
/// <summary>
/// 计算绘图Y轴时的相对偏移值
/// </summary>
/// <param name="max">0-100分的最大值就是指准备绘制的最大值</param>
/// <param name="min">0-100分的最小值就是指准备绘制的最小值</param>
/// <param name="height">实际绘图区域的高度</param>
/// <param name="value">需要绘制数据的当前值</param>
/// <returns>相对于0的位置还需要增加上面的偏值</returns>
// Token: 0x060004EE RID: 1262 RVA: 0x00033390 File Offset: 0x00031590
public static float ComputePaintLocationY(float max, float min, float height, float value)
{
bool flag = max - min == 0f;
float result;
if (flag)
{
result = height;
}
else
{
float num = max - min;
bool flag2 = num == 0f;
if (flag2)
{
num = 1f;
}
result = height - (value - min) / num * height;
}
return result;
}
/// <summary>
/// 计算绘图X轴时的相对偏移值
/// </summary>
/// <param name="max">0-100分的最大值就是指准备绘制的最大值</param>
/// <param name="min">0-100分的最小值就是指准备绘制的最小值</param>
/// <param name="width">实际绘图区域的宽度</param>
/// <param name="value">需要绘制数据的当前值</param>
/// <returns>相对于0的位置还需要增加上面的偏值</returns>
// Token: 0x060004EF RID: 1263 RVA: 0x000333D8 File Offset: 0x000315D8
public static float ComputePaintLocationX(float max, float min, float width, float value)
{
bool flag = max - min == 0f;
float result;
if (flag)
{
result = width;
}
else
{
float num = max - min;
bool flag2 = num == 0f;
if (flag2)
{
num = 1f;
}
result = (value - min) / num * width;
}
return result;
}
/// <summary>
/// 根据绘制的值计算原始的值信息
/// </summary>
/// <param name="max">0-100分的最大值就是指准备绘制的最大值</param>
/// <param name="min">0-100分的最小值就是指准备绘制的最小值</param>
/// <param name="height">实际绘图区域的高度</param>
/// <param name="paint">实际绘制的位置信息</param>
/// <returns>实际的值信息</returns>
// Token: 0x060004F0 RID: 1264 RVA: 0x0003341C File Offset: 0x0003161C
public static float ComputeValueFromPaintLocationY(float max, float min, float height, float paint)
{
bool flag = max - min == 0f;
float result;
if (flag)
{
result = max;
}
else
{
float num = max - min;
bool flag2 = num == 0f;
if (flag2)
{
num = 1f;
}
result = (height - paint) * num / height + min;
}
return result;
}
/// <summary>
/// 计算绘图时的相对偏移值
/// </summary>
/// <param name="referenceAxis">坐标轴信息</param>
/// <param name="height">实际绘图区域的高度</param>
/// <param name="value">需要绘制数据的当前值</param>
/// <returns>相对于0的位置还需要增加上面的偏值</returns>
// Token: 0x060004F1 RID: 1265 RVA: 0x00033464 File Offset: 0x00031664
public static float ComputePaintLocationY(ReferenceAxis referenceAxis, float height, float value)
{
return HslHelper.ComputePaintLocationY(referenceAxis.Max, referenceAxis.Min, height, value);
}
/// <summary>
/// 绘制坐标系中的刻度线
/// </summary>
/// <param name="g">绘图对象</param>
/// <param name="penLine">画坐标轴的画笔</param>
/// <param name="penDash"></param>
/// <param name="font"></param>
/// <param name="brush"></param>
/// <param name="sf"></param>
/// <param name="degree"></param>
/// <param name="max"></param>
/// <param name="min"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="left"></param>
/// <param name="right"></param>
/// <param name="up"></param>
/// <param name="down"></param>
// Token: 0x060004F2 RID: 1266 RVA: 0x0003348C File Offset: 0x0003168C
public static void PaintCoordinateDivide(Graphics g, System.Drawing.Pen penLine, System.Drawing.Pen penDash, Font font, System.Drawing.Brush brush, StringFormat sf, int degree, int max, int min, int width, int height, int left = 60, int right = 8, int up = 8, int down = 8)
{
for (int i = 0; i <= degree; i++)
{
int value = (max - min) * i / degree + min;
int num = (int)HslHelper.ComputePaintLocationY(max, min, height - up - down, value) + up + 1;
g.DrawLine(penLine, left - 1, num, left - 4, num);
bool flag = i != 0;
if (flag)
{
g.DrawLine(penDash, left, num, width - right, num);
}
g.DrawString(value.ToString(), font, brush, new Rectangle(-5, num - font.Height / 2, left, font.Height), sf);
}
}
/// <summary>
/// 根据指定的方向绘制一个箭头
/// </summary>
/// <param name="g"></param>
/// <param name="brush"></param>
/// <param name="point"></param>
/// <param name="size"></param>
/// <param name="direction"></param>
// Token: 0x060004F3 RID: 1267 RVA: 0x00033540 File Offset: 0x00031740
public static void PaintTriangle(Graphics g, System.Drawing.Brush brush, Point point, int size, GraphDirection direction)
{
Point[] array = new Point[4];
bool flag = direction == GraphDirection.Leftward;
if (flag)
{
array[0] = new Point(point.X, point.Y - size);
array[1] = new Point(point.X, point.Y + size);
array[2] = new Point(point.X - 2 * size, point.Y);
}
else
{
bool flag2 = direction == GraphDirection.Rightward;
if (flag2)
{
array[0] = new Point(point.X, point.Y - size);
array[1] = new Point(point.X, point.Y + size);
array[2] = new Point(point.X + 2 * size, point.Y);
}
else
{
bool flag3 = direction == GraphDirection.Upward;
if (flag3)
{
array[0] = new Point(point.X - size, point.Y);
array[1] = new Point(point.X + size, point.Y);
array[2] = new Point(point.X, point.Y - 2 * size);
}
else
{
array[0] = new Point(point.X - size, point.Y);
array[1] = new Point(point.X + size, point.Y);
array[2] = new Point(point.X, point.Y + 2 * size);
}
}
}
array[3] = array[0];
g.FillPolygon(brush, array);
}
/// <summary>
/// 绘制向左或是向右的箭头,例如 &lt;&lt; 或是 &gt;&gt;
/// </summary>
/// <param name="g">画刷资源</param>
/// <param name="pen">画笔资源</param>
/// <param name="rectangle">绘制的矩形</param>
/// <param name="direction">方向信息</param>
// Token: 0x060004F4 RID: 1268 RVA: 0x000336F4 File Offset: 0x000318F4
public static void DrawLeftRight(Graphics g, System.Drawing.Pen pen, Rectangle rectangle, GraphDirection direction)
{
bool flag = direction == GraphDirection.Leftward;
if (flag)
{
g.DrawLines(pen, new Point[]
{
new Point(rectangle.X + rectangle.Width / 2, rectangle.Y),
new Point(rectangle.X, rectangle.Y + rectangle.Height / 2),
new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height)
});
g.DrawLines(pen, new Point[]
{
new Point(rectangle.X + rectangle.Width, rectangle.Y),
new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2),
new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height)
});
}
else
{
bool flag2 = direction == GraphDirection.Rightward;
if (flag2)
{
g.DrawLines(pen, new Point[]
{
new Point(rectangle.X, rectangle.Y),
new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2),
new Point(rectangle.X, rectangle.Y + rectangle.Height)
});
g.DrawLines(pen, new Point[]
{
new Point(rectangle.X + rectangle.Width / 2, rectangle.Y),
new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height / 2),
new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height)
});
}
}
}
/// <summary>
/// 根据指定的方向绘制一个箭头
/// </summary>
/// <param name="g"></param>
/// <param name="brush"></param>
/// <param name="point"></param>
/// <param name="size"></param>
/// <param name="direction"></param>
// Token: 0x060004F5 RID: 1269 RVA: 0x00033930 File Offset: 0x00031B30
public static void PaintTriangle(Graphics g, System.Drawing.Brush brush, PointF point, int size, GraphDirection direction)
{
PointF[] array = new PointF[4];
bool flag = direction == GraphDirection.Leftward;
if (flag)
{
array[0] = new PointF(point.X, point.Y - (float)size);
array[1] = new PointF(point.X, point.Y + (float)size);
array[2] = new PointF(point.X - (float)(2 * size), point.Y);
}
else
{
bool flag2 = direction == GraphDirection.Rightward;
if (flag2)
{
array[0] = new PointF(point.X, point.Y - (float)size);
array[1] = new PointF(point.X, point.Y + (float)size);
array[2] = new PointF(point.X + (float)(2 * size), point.Y);
}
else
{
bool flag3 = direction == GraphDirection.Upward;
if (flag3)
{
array[0] = new PointF(point.X - (float)size, point.Y);
array[1] = new PointF(point.X + (float)size, point.Y);
array[2] = new PointF(point.X, point.Y - (float)(2 * size));
}
else
{
array[0] = new PointF(point.X - (float)size, point.Y);
array[1] = new PointF(point.X + (float)size, point.Y);
array[2] = new PointF(point.X, point.Y + (float)(2 * size));
}
}
}
array[3] = array[0];
g.FillPolygon(brush, array);
}
/// <summary>
/// 一个通用的数组新增个数方法,会自动判断越界情况,越界的情况下,会自动的截断或是填充 -&gt;
/// A common array of new methods, will automatically determine the cross-border situation, in the case of cross-border, will be automatically truncated or filled
/// </summary>
/// <typeparam name="T">数据类型</typeparam>
/// <param name="array">原数据</param>
/// <param name="data">等待新增的数据</param>
/// <param name="max">原数据的最大值</param>
// Token: 0x060004F6 RID: 1270 RVA: 0x00033AF0 File Offset: 0x00031CF0
public static void AddArrayData<T>(ref T[] array, T[] data, int max)
{
bool flag = data == null;
if (!flag)
{
bool flag2 = data.Length == 0;
if (!flag2)
{
bool flag3 = array.Length == max;
if (flag3)
{
Array.Copy(array, data.Length, array, 0, array.Length - data.Length);
Array.Copy(data, 0, array, array.Length - data.Length, data.Length);
}
else
{
bool flag4 = array.Length + data.Length > max;
if (flag4)
{
T[] array2 = new T[max];
for (int i = 0; i < max - data.Length; i++)
{
array2[i] = array[i + (array.Length - max + data.Length)];
}
for (int j = 0; j < data.Length; j++)
{
array2[array2.Length - data.Length + j] = data[j];
}
array = array2;
}
else
{
T[] array3 = new T[array.Length + data.Length];
for (int k = 0; k < array.Length; k++)
{
array3[k] = array[k];
}
for (int l = 0; l < data.Length; l++)
{
array3[array3.Length - data.Length + l] = data[l];
}
array = array3;
}
}
}
}
}
/// <summary>
/// 尺寸转换,计算旋转后的尺寸。
/// </summary>
/// <param name="size"></param>
/// <param name="angle"></param>
/// <returns></returns>
// Token: 0x060004F7 RID: 1271 RVA: 0x00033C5C File Offset: 0x00031E5C
public static SizeF ConvertSize(SizeF size, float angle)
{
System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
matrix.Rotate(angle);
PointF[] array = new PointF[4];
array[0].X = -size.Width / 2f;
array[0].Y = -size.Height / 2f;
array[1].X = -size.Width / 2f;
array[1].Y = size.Height / 2f;
array[2].X = size.Width / 2f;
array[2].Y = size.Height / 2f;
array[3].X = size.Width / 2f;
array[3].Y = -size.Height / 2f;
matrix.TransformPoints(array);
float num = float.MaxValue;
float num2 = float.MinValue;
float num3 = float.MaxValue;
float num4 = float.MinValue;
foreach (PointF pointF in array)
{
bool flag = pointF.X < num;
if (flag)
{
num = pointF.X;
}
bool flag2 = pointF.X > num2;
if (flag2)
{
num2 = pointF.X;
}
bool flag3 = pointF.Y < num3;
if (flag3)
{
num3 = pointF.Y;
}
bool flag4 = pointF.Y > num4;
if (flag4)
{
num4 = pointF.Y;
}
}
SizeF result = new SizeF(num2 - num, num4 - num3);
return result;
}
/// <summary>
/// 绘制旋转文本
/// </summary>
/// <param name="g"></param>
/// <param name="s"></param>
/// <param name="font"></param>
/// <param name="brush"></param>
/// <param name="point"></param>
/// <param name="format"></param>
/// <param name="angle"></param>
// Token: 0x060004F8 RID: 1272 RVA: 0x00033E14 File Offset: 0x00032014
public static void DrawString(Graphics g, string s, Font font, System.Drawing.Brush brush, PointF point, StringFormat format, float angle)
{
System.Drawing.Drawing2D.Matrix transform = g.Transform;
System.Drawing.Drawing2D.Matrix transform2 = g.Transform;
transform2.RotateAt(angle, point);
g.Transform = transform2;
g.DrawString(s, font, brush, point, format);
g.Transform = transform;
}
// Token: 0x060004F9 RID: 1273 RVA: 0x00033E5C File Offset: 0x0003205C
private static int GetPow(int digit)
{
int num = 1;
for (int i = 0; i < digit; i++)
{
num *= 10;
}
return num;
}
/// <summary>
/// 将int数组转换为double数组
/// </summary>
/// <param name="values">int数组值</param>
/// <returns>结果值</returns>
// Token: 0x060004FA RID: 1274 RVA: 0x00033E88 File Offset: 0x00032088
public static double[] TranlateArrayToDouble(int[] values)
{
bool flag = values == null;
double[] result;
if (flag)
{
result = null;
}
else
{
double[] array = new double[values.Length];
for (int i = 0; i < values.Length; i++)
{
array[i] = (double)values[i];
}
result = array;
}
return result;
}
/// <summary>
/// 将float数组转换为double数组值
/// </summary>
/// <param name="values">float数组值</param>
/// <returns>结果值</returns>
// Token: 0x060004FB RID: 1275 RVA: 0x00033ED0 File Offset: 0x000320D0
public static double[] TranlateArrayToDouble(float[] values)
{
double[] array = new double[values.Length];
for (int i = 0; i < values.Length; i++)
{
array[i] = (double)values[i];
}
return array;
}
/// <summary>
/// 获得数据的上限值,这个上限值是自动计算的。
/// </summary>
/// <param name="values">数据值</param>
/// <returns>数据值</returns>
// Token: 0x060004FC RID: 1276 RVA: 0x00033F08 File Offset: 0x00032108
public static int CalculateMaxSectionFrom(double[] values)
{
double num = values.Max();
bool flag = num <= 5.0;
int result;
if (flag)
{
result = 5;
}
else
{
bool flag2 = num <= 9.0;
if (flag2)
{
result = 10;
}
else
{
int num2 = Convert.ToInt32(Math.Ceiling(num));
int digit = num2.ToString().Length - 2;
int num3 = int.Parse(num2.ToString().Substring(0, 2));
bool flag3 = num3 < 11;
if (flag3)
{
result = 12 * HslHelper.GetPow(digit);
}
else
{
bool flag4 = num3 < 13;
if (flag4)
{
result = 14 * HslHelper.GetPow(digit);
}
else
{
bool flag5 = num3 < 15;
if (flag5)
{
result = 16 * HslHelper.GetPow(digit);
}
else
{
bool flag6 = num3 < 17;
if (flag6)
{
result = 18 * HslHelper.GetPow(digit);
}
else
{
bool flag7 = num3 < 19;
if (flag7)
{
result = 20 * HslHelper.GetPow(digit);
}
else
{
bool flag8 = num3 < 21;
if (flag8)
{
result = 22 * HslHelper.GetPow(digit);
}
else
{
bool flag9 = num3 < 23;
if (flag9)
{
result = 24 * HslHelper.GetPow(digit);
}
else
{
bool flag10 = num3 < 25;
if (flag10)
{
result = 26 * HslHelper.GetPow(digit);
}
else
{
bool flag11 = num3 < 27;
if (flag11)
{
result = 28 * HslHelper.GetPow(digit);
}
else
{
bool flag12 = num3 < 29;
if (flag12)
{
result = 30 * HslHelper.GetPow(digit);
}
else
{
bool flag13 = num3 < 33;
if (flag13)
{
result = 34 * HslHelper.GetPow(digit);
}
else
{
bool flag14 = num3 < 40;
if (flag14)
{
result = 40 * HslHelper.GetPow(digit);
}
else
{
bool flag15 = num3 < 50;
if (flag15)
{
result = 50 * HslHelper.GetPow(digit);
}
else
{
bool flag16 = num3 < 60;
if (flag16)
{
result = 60 * HslHelper.GetPow(digit);
}
else
{
bool flag17 = num3 < 80;
if (flag17)
{
result = 80 * HslHelper.GetPow(digit);
}
else
{
bool flag18 = num3 < 95;
if (flag18)
{
result = 100 * HslHelper.GetPow(digit);
}
else
{
result = 100 * HslHelper.GetPow(digit);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}
/// <inheritdoc cref="M:HslControls.HslHelper.CalculateMaxSectionFrom(System.Double[])" />
// Token: 0x060004FD RID: 1277 RVA: 0x00034138 File Offset: 0x00032338
public static int CalculateMaxSectionFrom(Dictionary<string, double[]> values)
{
return HslHelper.CalculateMaxSectionFrom((from m in values
select m.Value.Max()).ToArray<double>());
}
/// <summary>
/// 获取当前颜色更淡的颜色信息
/// </summary>
/// <param name="color">颜色信息</param>
/// <returns>颜色</returns>
// Token: 0x060004FE RID: 1278 RVA: 0x0003417C File Offset: 0x0003237C
public static System.Drawing.Color GetColorLight(System.Drawing.Color color)
{
return HslHelper.GetColorLight(color, 40);
}
/// <summary>
/// 获取当前颜色更深的颜色信息
/// </summary>
/// <param name="color">颜色信息</param>
/// <returns>颜色</returns>
// Token: 0x060004FF RID: 1279 RVA: 0x00034198 File Offset: 0x00032398
public static System.Drawing.Color GetColorDeep(System.Drawing.Color color)
{
return HslHelper.GetColorLight(color, -40);
}
/// <summary>
/// 获取当前颜色更淡的颜色信息需要指定系数0-1000时是原来的原色100时是纯白色
/// </summary>
/// <param name="color">颜色信息</param>
/// <param name="scale">获取颜色的系数信息</param>
/// <returns>颜色</returns>
// Token: 0x06000500 RID: 1280 RVA: 0x000341B4 File Offset: 0x000323B4
public static System.Drawing.Color GetColorLight(System.Drawing.Color color, int scale)
{
bool flag = scale > 0;
System.Drawing.Color result;
if (flag)
{
result = System.Drawing.Color.FromArgb((int)color.R + (int)(byte.MaxValue - color.R) * scale / 100, (int)color.G + (int)(byte.MaxValue - color.G) * scale / 100, (int)color.B + (int)(byte.MaxValue - color.B) * scale / 100);
}
else
{
result = System.Drawing.Color.FromArgb((int)color.R + (int)color.R * scale / 100, (int)color.G + (int)color.G * scale / 100, (int)color.B + (int)color.B * scale / 100);
}
return result;
}
/// <summary>
/// 获取颜色的偏移信息
/// </summary>
/// <param name="color">颜色值</param>
/// <param name="offset">颜色偏移信息</param>
/// <returns>颜色值</returns>
// Token: 0x06000501 RID: 1281 RVA: 0x00034268 File Offset: 0x00032468
public static System.Drawing.Color GetColorOffset(System.Drawing.Color color, int offset)
{
int num = (int)color.R + offset;
bool flag = num < 0;
if (flag)
{
num = 0;
}
bool flag2 = num > 255;
if (flag2)
{
num = 255;
}
int num2 = (int)color.G + offset;
bool flag3 = num2 < 0;
if (flag3)
{
num2 = 0;
}
bool flag4 = num2 > 255;
if (flag4)
{
num2 = 255;
}
int num3 = (int)color.B + offset;
bool flag5 = num3 < 0;
if (flag5)
{
num3 = 0;
}
bool flag6 = num3 > 255;
if (flag6)
{
num3 = 255;
}
return System.Drawing.Color.FromArgb(num, num2, num3);
}
/// <summary>
/// 获取当前颜色更淡的颜色信息
/// </summary>
/// <param name="color">颜色信息</param>
/// <returns>颜色</returns>
// Token: 0x06000502 RID: 1282 RVA: 0x00034300 File Offset: 0x00032500
public static System.Drawing.Color GetColorLightFive(System.Drawing.Color color)
{
return HslHelper.GetColorLight(color, 50);
}
/// <summary>
/// 从字符串表示的点位信息里解析出真正的点位信息
/// </summary>
/// <param name="points">字符串的点位</param>
/// <param name="soureWidth">原来的长度信息</param>
/// <param name="sourceHeight">原来的高度信息</param>
/// <param name="width">实际的宽度信息</param>
/// <param name="height">实际的高度信息</param>
/// <param name="dx">x偏移量信息</param>
/// <param name="dy">y偏移量信息</param>
/// <returns></returns>
// Token: 0x06000505 RID: 1285 RVA: 0x000343F4 File Offset: 0x000325F4
public static PointF[] GetPointsFrom(string points, float soureWidth, float sourceHeight, float width, float height, float dx = 0f, float dy = 0f)
{
string[] array = points.Split(new char[]
{
' '
}, StringSplitOptions.RemoveEmptyEntries);
PointF[] array2 = new PointF[array.Length];
for (int i = 0; i < array.Length; i++)
{
int num = array[i].IndexOf(',');
float num2 = Convert.ToSingle(array[i].Substring(0, num));
float num3 = Convert.ToSingle(array[i].Substring(num + 1));
array2[i] = new PointF(width * (num2 + dx) / soureWidth, height * (num3 + dy) / sourceHeight);
}
return array2;
}
/// <summary>
/// 根据矩形及其各个定点的配置信息,获取圆角的路径信息,可以指定每个定点的圆角情况
/// </summary>
/// <param name="rectangle"></param>
/// <param name="radius"></param>
/// <param name="topLeft"></param>
/// <param name="topRight"></param>
/// <param name="buttomRight"></param>
/// <param name="buttomLeft"></param>
/// <returns></returns>
// Token: 0x06000506 RID: 1286 RVA: 0x00034488 File Offset: 0x00032688
public static GraphicsPath GetRoundRectange(Rectangle rectangle, int radius, bool topLeft, bool topRight, bool buttomRight, bool buttomLeft)
{
GraphicsPath graphicsPath = new GraphicsPath();
Point pt = new Point(rectangle.X + (topLeft ? radius : 0), rectangle.Y);
Point pt2 = new Point(rectangle.X + rectangle.Width - 1 - (topRight ? radius : 0), rectangle.Y);
graphicsPath.AddLine(pt, pt2);
bool flag = topRight && radius > 0;
if (flag)
{
graphicsPath.AddArc(rectangle.X + rectangle.Width - radius * 2 - 1, rectangle.Y, radius * 2, radius * 2, 270f, 90f);
}
Point pt3 = new Point(rectangle.X + rectangle.Width - 1, rectangle.Y + (topRight ? radius : 0));
Point pt4 = new Point(rectangle.X + rectangle.Width - 1, rectangle.Y + rectangle.Height - 1 - (buttomRight ? radius : 0));
graphicsPath.AddLine(pt3, pt4);
bool flag2 = buttomRight && radius > 0;
if (flag2)
{
graphicsPath.AddArc(rectangle.X + rectangle.Width - radius * 2 - 1, rectangle.Y + rectangle.Height - radius * 2 - 1, radius * 2, radius * 2, 0f, 90f);
}
Point pt5 = new Point(rectangle.X + rectangle.Width - 1 - (buttomRight ? radius : 0), rectangle.Y + rectangle.Height - 1);
Point pt6 = new Point(rectangle.X + (buttomLeft ? radius : 0), rectangle.Y + rectangle.Height - 1);
graphicsPath.AddLine(pt5, pt6);
bool flag3 = buttomLeft && radius > 0;
if (flag3)
{
graphicsPath.AddArc(rectangle.X, rectangle.Y + rectangle.Height - radius * 2 - 1, radius * 2, radius * 2, 90f, 90f);
}
Point pt7 = new Point(rectangle.X, rectangle.Y + rectangle.Height - 1 - (buttomLeft ? radius : 0));
Point pt8 = new Point(rectangle.X, rectangle.Y + (topLeft ? radius : 0));
graphicsPath.AddLine(pt7, pt8);
bool flag4 = topLeft && radius > 0;
if (flag4)
{
graphicsPath.AddArc(rectangle.X, rectangle.Y, radius * 2, radius * 2, 180f, 90f);
}
return graphicsPath;
}
// Token: 0x06000507 RID: 1287 RVA: 0x00034718 File Offset: 0x00032918
private static string FloatMatchEvaluator(Match m)
{
bool flag = m.Value.Length == 5;
string result;
if (flag)
{
result = m.Value.Substring(0, 3);
}
else
{
result = m.Value.Substring(0, 2);
}
return result;
}
// Token: 0x06000508 RID: 1288 RVA: 0x0003475C File Offset: 0x0003295C
private static string RemoveEndWithZero(string value)
{
return Regex.Replace(value, "\\.[0]+$", "");
}
// Token: 0x06000509 RID: 1289 RVA: 0x00034780 File Offset: 0x00032980
public static float GetReferenceAxisMaxValue(float max)
{
bool flag = max >= 0f;
float result;
if (flag)
{
int floatPow = HslHelper.GetFloatPow(max);
float num = (float)((double)max * Math.Pow(10.0, (double)(-(double)floatPow)));
bool flag2 = num == 0f;
if (flag2)
{
result = 1f;
}
else
{
bool flag3 = num < 1.1f;
if (flag3)
{
result = Convert.ToSingle(1.2000000476837158 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag4 = num < 1.3f;
if (flag4)
{
result = Convert.ToSingle(1.399999976158142 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag5 = num < 1.5f;
if (flag5)
{
result = Convert.ToSingle(1.600000023841858 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag6 = num < 1.7f;
if (flag6)
{
result = Convert.ToSingle(1.7999999523162842 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag7 = num < 1.9f;
if (flag7)
{
result = Convert.ToSingle(2.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag8 = num < 2.2f;
if (flag8)
{
result = Convert.ToSingle(2.4000000953674316 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag9 = num < 2.4f;
if (flag9)
{
result = Convert.ToSingle(2.5999999046325684 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag10 = num < 2.6f;
if (flag10)
{
result = Convert.ToSingle(2.799999952316284 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag11 = num < 2.8f;
if (flag11)
{
result = Convert.ToSingle(3.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag12 = num < 3.3f;
if (flag12)
{
result = Convert.ToSingle(3.5 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag13 = num < 3.8f;
if (flag13)
{
result = Convert.ToSingle(4.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag14 = num < 4.5f;
if (flag14)
{
result = Convert.ToSingle(5.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag15 = num < 6.5f;
if (flag15)
{
result = Convert.ToSingle(6.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag16 = num < 7.5f;
if (flag16)
{
result = Convert.ToSingle(8.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
bool flag17 = num < 9.5f;
if (flag17)
{
result = Convert.ToSingle(10.0 * Math.Pow(10.0, (double)floatPow));
}
else
{
result = Convert.ToSingle(12.0 * Math.Pow(10.0, (double)floatPow));
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
int floatPow2 = HslHelper.GetFloatPow(-max);
float num2 = (float)((double)max * Math.Pow(10.0, (double)(-(double)floatPow2)));
bool flag18 = num2 < -8.5f;
if (flag18)
{
result = Convert.ToSingle(-8.0 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag19 = num2 < -6.5f;
if (flag19)
{
result = Convert.ToSingle(-6.0 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag20 = num2 < -4.5f;
if (flag20)
{
result = Convert.ToSingle(-4.0 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag21 = num2 < -3.5f;
if (flag21)
{
result = Convert.ToSingle(-3.0 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag22 = num2 < -2.2f;
if (flag22)
{
result = Convert.ToSingle(-2.0 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag23 = num2 < -1.9f;
if (flag23)
{
result = Convert.ToSingle(-1.7999999523162842 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag24 = num2 < -1.7f;
if (flag24)
{
result = Convert.ToSingle(-1.600000023841858 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag25 = num2 < -1.5f;
if (flag25)
{
result = Convert.ToSingle(-1.399999976158142 * Math.Pow(10.0, (double)floatPow2));
}
else
{
bool flag26 = num2 < -1.3f;
if (flag26)
{
result = Convert.ToSingle(-1.2000000476837158 * Math.Pow(10.0, (double)floatPow2));
}
else
{
result = Convert.ToSingle(-1.0 * Math.Pow(10.0, (double)floatPow2));
}
}
}
}
}
}
}
}
}
}
return result;
}
// Token: 0x0600050A RID: 1290 RVA: 0x00034D30 File Offset: 0x00032F30
private static int GetFloatPow(float value)
{
bool flag = value >= 1f && value < 10f;
int result;
if (flag)
{
result = 0;
}
else
{
bool flag2 = value >= 10f;
if (flag2)
{
result = HslHelper.GetFloatPow(value / 10f) + 1;
}
else
{
bool flag3 = value > 0f && value < 1f;
if (flag3)
{
result = HslHelper.GetFloatPow(value * 10f) - 1;
}
else
{
result = 0;
}
}
}
return result;
}
/// <summary>
/// 获取浮点数值的格式化文本信息,如果发生了异常,则返回错误消息
/// </summary>
/// <param name="format">格式化信息</param>
/// <param name="value">值信息</param>
/// <param name="remainZero">是否保留0的信息</param>
/// <returns>等待显示的文本</returns>
// Token: 0x0600050B RID: 1291 RVA: 0x00034DA8 File Offset: 0x00032FA8
public static string GetFormatString(string format, float value, bool remainZero = false)
{
string result;
try
{
string text = string.Format(format, value);
if (remainZero)
{
result = HslHelper.RemoveEndWithZero(text);
}
else
{
result = HslHelper.RemoveEndWithZero(Regex.Replace(text, "[Ee][+-][0]+", new MatchEvaluator(HslHelper.FloatMatchEvaluator)));
}
}
catch
{
result = "Wrong";
}
return result;
}
// Token: 0x0600050C RID: 1292 RVA: 0x00034E0C File Offset: 0x0003300C
public static void ShowExceptionMessage(Exception ex)
{
MessageBox.Show(HslHelper.GetExceptionMessage(ex));
}
// Token: 0x0600050D RID: 1293 RVA: 0x00034E1B File Offset: 0x0003301B
public static void ShowExceptionMessage(string extraMsg, Exception ex)
{
MessageBox.Show(HslHelper.GetExceptionMessage(extraMsg, ex));
}
// Token: 0x0600050E RID: 1294 RVA: 0x00034E2C File Offset: 0x0003302C
public static string GetExceptionMessage(Exception ex)
{
string[] array = new string[8];
array[0] = "Message";
array[1] = ex.Message;
array[2] = Environment.NewLine;
array[3] = "StackTrace";
array[4] = ex.StackTrace;
array[5] = Environment.NewLine;
array[6] = "TargetSite";
int num = 7;
MethodBase targetSite = ex.TargetSite;
array[num] = ((targetSite != null) ? targetSite.ToString() : null);
return string.Concat(array);
}
// Token: 0x0600050F RID: 1295 RVA: 0x00034E98 File Offset: 0x00033098
public static string GetExceptionMessage(string extraMsg, Exception ex)
{
bool flag = string.IsNullOrEmpty(extraMsg);
string result;
if (flag)
{
result = HslHelper.GetExceptionMessage(ex);
}
else
{
result = extraMsg + Environment.NewLine + HslHelper.GetExceptionMessage(ex);
}
return result;
}
/// <summary>
/// 矩形中间的字符串对齐机制
/// </summary>
// Token: 0x17000185 RID: 389
// (get) Token: 0x06000510 RID: 1296 RVA: 0x00034ECE File Offset: 0x000330CE
// (set) Token: 0x06000511 RID: 1297 RVA: 0x00034ED5 File Offset: 0x000330D5
public static StringFormat StringFormatCenter { get; set; }
/// <summary>
/// 矩形的左侧中间的对齐机制
/// </summary>
// Token: 0x17000186 RID: 390
// (get) Token: 0x06000512 RID: 1298 RVA: 0x00034EDD File Offset: 0x000330DD
// (set) Token: 0x06000513 RID: 1299 RVA: 0x00034EE4 File Offset: 0x000330E4
public static StringFormat StringFormatLeft { get; set; }
/// <summary>
/// 矩形的右侧的中间对齐机制
/// </summary>
// Token: 0x17000187 RID: 391
// (get) Token: 0x06000514 RID: 1300 RVA: 0x00034EEC File Offset: 0x000330EC
// (set) Token: 0x06000515 RID: 1301 RVA: 0x00034EF3 File Offset: 0x000330F3
public static StringFormat StringFormatRight { get; set; }
/// <summary>
/// 矩形的的默认的左上角对齐的机制
/// </summary>
// Token: 0x17000188 RID: 392
// (get) Token: 0x06000516 RID: 1302 RVA: 0x00034EFB File Offset: 0x000330FB
// (set) Token: 0x06000517 RID: 1303 RVA: 0x00034F02 File Offset: 0x00033102
public static StringFormat StringFormatDefault { get; set; } = new StringFormat();
/// <summary>
/// 矩形的下方中间的对齐的机制
/// </summary>
// Token: 0x17000189 RID: 393
// (get) Token: 0x06000518 RID: 1304 RVA: 0x00034F0A File Offset: 0x0003310A
// (set) Token: 0x06000519 RID: 1305 RVA: 0x00034F11 File Offset: 0x00033111
public static StringFormat StringFormatTopCenter { get; set; }
}
}