using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Text; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Controls.ChemicalWeighing { /// /// 数码管显示的控件信息,可以显示一串数码管的信息 /// // Token: 0x02000042 RID: 66 [Description("数码管显示控件,支持数字,小数点和特殊的英文字幕显示,支持显示单位")] public partial class HslLedDisplay : UserControl { /// /// 实例化一个默认的对象 /// // Token: 0x0600058C RID: 1420 RVA: 0x00036438 File Offset: 0x00034638 public HslLedDisplay() { InitializeComponent(); base.SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); base.SetStyle(ControlStyles.ResizeRedraw, true); base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); base.ForeColor = Color.Tomato; base.SuspendLayout(); base.AutoScaleMode = AutoScaleMode.None; this.BackColor = Color.FromArgb(46, 46, 46); base.Name = "HslLedDisplay"; base.Size = new Size(325, 58); base.ResumeLayout(false); } /// // Token: 0x0600058D RID: 1421 RVA: 0x00036510 File Offset: 0x00034710 protected override void OnPaint(PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; this.PaintHslControls(e.Graphics, base.Width, base.Height); base.OnPaint(e); } /// // Token: 0x0600058E RID: 1422 RVA: 0x00036568 File Offset: 0x00034768 public void PaintHslControls(Graphics g, int width, int height) { bool flag = false; if (!flag) { bool flag2 = width < 3 || height < 3; if (!flag2) { int num = this.leftRightOffect; int num2 = this.leftRightOffect; bool flag3 = !string.IsNullOrEmpty(this.unitText); if (flag3) { num2 = 2 + (int)g.MeasureString(this.unitText, this.Font).Width; } float num3 = (float)(width - num - num2) / 1f / (float)this.displayNumber; int num4 = this.SumCharCount(this.displayText); for (int i = 0; i < this.displayNumber; i++) { this.DrawNumber(g, (int)((float)i * num3) + num, 0, (int)num3, height, ' ', false); } bool flag4 = string.IsNullOrEmpty(this.displayText); if (!flag4) { bool flag5 = this.displayNumber >= num4; if (flag5) { int num5 = this.displayNumber - 1; for (int j = this.displayText.Length - 1; j >= 0; j--) { bool flag6 = this.supportChars.Contains(this.displayText[j]); if (flag6) { this.DrawNumber(g, (int)((float)num5 * num3) + num, 0, (int)num3, height, this.displayText[j], this.IsCharAfterSpot(this.displayText, j)); num5--; bool flag7 = num5 < 0; if (flag7) { break; } } } } else { int num6 = 0; for (int k = 0; k < this.displayText.Length; k++) { bool flag8 = this.supportChars.Contains(this.displayText[k]); if (flag8) { this.DrawNumber(g, (int)((float)num6 * num3) + num, 0, (int)num3, height, this.displayText[k], this.IsCharAfterSpot(this.displayText, k)); num6++; bool flag9 = num6 >= this.displayNumber; if (flag9) { break; } } } } bool flag10 = !string.IsNullOrEmpty(this.unitText); if (flag10) { g.DrawString(this.unitText, this.Font, this.foreBrush, (float)(width - num2 - 2), 3f); } } } } } // Token: 0x0600058F RID: 1423 RVA: 0x000367CC File Offset: 0x000349CC private int SumCharCount(string value) { int num = 0; for (int i = 0; i < value.Length; i++) { bool flag = this.supportChars.Contains(value[i]); if (flag) { num++; } } return num; } // Token: 0x06000590 RID: 1424 RVA: 0x00036818 File Offset: 0x00034A18 private bool IsCharAfterSpot(string value, int index) { bool flag = string.IsNullOrEmpty(value); bool result; if (flag) { result = false; } else { bool flag2 = index >= value.Length - 1; if (flag2) { result = false; } else { bool flag3 = value[index + 1] == '.'; result = flag3; } } return result; } // Token: 0x06000591 RID: 1425 RVA: 0x00036864 File Offset: 0x00034A64 private void DrawHorizontalItem(Graphics g, Brush brush, int x, int y, int width) { Point[] points = new Point[] { new Point(x, y), new Point(x - this.ledNumberSize / 2, y + this.ledNumberSize / 2), new Point(x, y + this.ledNumberSize), new Point(x + width, y + this.ledNumberSize), new Point(x + width + this.ledNumberSize / 2, y + this.ledNumberSize / 2), new Point(x + width, y), new Point(x, y) }; g.FillPolygon(brush, points); } // Token: 0x06000592 RID: 1426 RVA: 0x00036928 File Offset: 0x00034B28 private void DrawVerticalItem(Graphics g, Brush brush, int x, int y, int height) { Point[] points = new Point[] { new Point(x, y), new Point(x, y + height), new Point(x + this.ledNumberSize / 2, y + height + this.ledNumberSize / 2), new Point(x + this.ledNumberSize, y + height), new Point(x + this.ledNumberSize, y), new Point(x + this.ledNumberSize / 2, y - this.ledNumberSize / 2), new Point(x, y) }; g.FillPolygon(brush, points); } // Token: 0x06000593 RID: 1427 RVA: 0x000369EC File Offset: 0x00034BEC private void DrawNumber(Graphics g, int x, int y, int width, int height, char charValue, bool hasSpot) { bool[] array = new bool[9]; bool flag = charValue == this.supportChars[0]; if (flag) { bool[] array2 = new bool[] { true, true, true, false, true, true, true, false, false }; array2[7] = hasSpot; array = array2; } else { bool flag2 = charValue == this.supportChars[1]; if (flag2) { bool[] array3 = new bool[9]; array3[2] = true; array3[5] = true; array3[7] = hasSpot; array = array3; } else { bool flag3 = charValue == this.supportChars[2]; if (flag3) { bool[] array4 = new bool[] { true, false, true, true, true, false, true, false, false }; array4[7] = hasSpot; array = array4; } else { bool flag4 = charValue == this.supportChars[3]; if (flag4) { bool[] array5 = new bool[] { true, false, true, true, false, true, true, false, false }; array5[7] = hasSpot; array = array5; } else { bool flag5 = charValue == this.supportChars[4]; if (flag5) { bool[] array6 = new bool[] { false, true, true, true, false, true, false, false, false }; array6[7] = hasSpot; array = array6; } else { bool flag6 = charValue == this.supportChars[5]; if (flag6) { bool[] array7 = new bool[] { true, true, false, true, false, true, true, false, false }; array7[7] = hasSpot; array = array7; } else { bool flag7 = charValue == this.supportChars[6]; if (flag7) { bool[] array8 = new bool[] { true, true, false, true, true, true, true, false, false }; array8[7] = hasSpot; array = array8; } else { bool flag8 = charValue == this.supportChars[7]; if (flag8) { bool[] array9 = new bool[] { true, false, true, false, false, true, false, false, false }; array9[7] = hasSpot; array = array9; } else { bool flag9 = charValue == this.supportChars[8]; if (flag9) { bool[] array10 = new bool[] { true, true, true, true, true, true, true, false, false }; array10[7] = hasSpot; array = array10; } else { bool flag10 = charValue == this.supportChars[9]; if (flag10) { bool[] array11 = new bool[] { true, true, true, true, false, true, true, false, false }; array11[7] = hasSpot; array = array11; } else { bool flag11 = charValue == this.supportChars[10]; if (flag11) { bool[] array12 = new bool[] { true, true, true, true, true, true, false, false, false }; array12[7] = hasSpot; array = array12; } else { bool flag12 = charValue == this.supportChars[11]; if (flag12) { bool[] array13 = new bool[] { false, true, false, true, true, true, true, false, false }; array13[7] = hasSpot; array = array13; } else { bool flag13 = charValue == this.supportChars[12]; if (flag13) { bool[] array14 = new bool[] { true, true, false, false, true, false, true, false, false }; array14[7] = hasSpot; array = array14; } else { bool flag14 = charValue == this.supportChars[13]; if (flag14) { bool[] array15 = new bool[] { false, false, false, true, true, false, true, false, false }; array15[7] = hasSpot; array = array15; } else { bool flag15 = charValue == this.supportChars[14]; if (flag15) { bool[] array16 = new bool[] { false, false, true, true, true, true, true, false, false }; array16[7] = hasSpot; array = array16; } else { bool flag16 = charValue == this.supportChars[15]; if (flag16) { bool[] array17 = new bool[] { true, true, false, true, true, false, true, false, false }; array17[7] = hasSpot; array = array17; } else { bool flag17 = charValue == this.supportChars[16]; if (flag17) { bool[] array18 = new bool[] { true, true, false, true, true, false, false, false, false }; array18[7] = hasSpot; array = array18; } else { bool flag18 = charValue == this.supportChars[17]; if (flag18) { bool[] array19 = new bool[] { false, true, true, true, true, true, false, false, false }; array19[7] = hasSpot; array = array19; } else { bool flag19 = charValue == this.supportChars[18]; if (flag19) { bool[] array20 = new bool[] { false, true, false, true, true, true, false, false, false }; array20[7] = hasSpot; array = array20; } else { bool flag20 = charValue == this.supportChars[19]; if (flag20) { bool[] array21 = new bool[] { false, false, true, false, false, true, true, false, false }; array21[7] = hasSpot; array = array21; } else { bool flag21 = charValue == this.supportChars[20]; if (flag21) { bool[] array22 = new bool[] { false, true, false, false, true, false, true, false, false }; array22[7] = hasSpot; array = array22; } else { bool flag22 = charValue == this.supportChars[21]; if (flag22) { bool[] array23 = new bool[] { false, false, false, true, true, true, true, false, false }; array23[7] = hasSpot; array = array23; } else { bool flag23 = charValue == this.supportChars[22]; if (flag23) { bool[] array24 = new bool[] { true, true, true, true, true, false, false, false, false }; array24[7] = hasSpot; array = array24; } else { bool flag24 = charValue == this.supportChars[23]; if (flag24) { bool[] array25 = new bool[9]; array25[3] = true; array25[4] = true; array25[7] = hasSpot; array = array25; } else { bool flag25 = charValue == this.supportChars[24]; if (flag25) { bool[] array26 = new bool[] { false, true, true, false, true, true, true, false, false }; array26[7] = hasSpot; array = array26; } else { bool flag26 = charValue == this.supportChars[25]; if (flag26) { array = new bool[] { default(bool), default(bool), default(bool), default(bool), default(bool), default(bool), default(bool), default(bool), true }; } else { bool flag27 = charValue == this.supportChars[26]; if (flag27) { array = new bool[9]; } else { bool flag28 = charValue == this.supportChars[27]; if (flag28) { bool[] array27 = new bool[9]; array27[3] = true; array = array27; } } } } } } } } } } } } } } } } } } } } } } } } } } } } this.DrawNumber(g, x, y, width, height, array); } // Token: 0x06000594 RID: 1428 RVA: 0x00036FB0 File Offset: 0x000351B0 private void DrawNumber(Graphics g, int x, int y, int width, int height, bool[] array) { bool flag = array == null; if (!flag) { bool flag2 = array.Length < 9; if (!flag2) { int num = 5; int num2 = 5; int num3 = 3; int num4 = 4; int num5 = 2; bool flag3 = this.ledNumberSize < 6; if (flag3) { num3 = 2; num4 = 3; num5 = 1; } bool flag4 = this.ledNumberSize > 12; if (flag4) { num3 = 5; num4 = 6; num5 = 3; } int width2 = width - num3 - num4 - 2 * this.ledNumberSize - 2 * num5; int num6 = (height - num - num2 - 3 * this.ledNumberSize - 4 * num5) / 2; bool flag5 = array[0]; if (flag5) { this.DrawHorizontalItem(g, this.foreBrush, x + num3 + this.ledNumberSize + num5, y + num, width2); } else { this.DrawHorizontalItem(g, this.backBrush, x + num3 + this.ledNumberSize + num5, y + num, width2); } bool flag6 = array[1]; if (flag6) { this.DrawVerticalItem(g, this.foreBrush, x + num3, y + num + this.ledNumberSize + num5, num6); } else { this.DrawVerticalItem(g, this.backBrush, x + num3, y + num + this.ledNumberSize + num5, num6); } bool flag7 = array[2]; if (flag7) { this.DrawVerticalItem(g, this.foreBrush, x + width - num4 - this.ledNumberSize, y + num + this.ledNumberSize + num5, num6); } else { this.DrawVerticalItem(g, this.backBrush, x + width - num4 - this.ledNumberSize, y + num + this.ledNumberSize + num5, num6); } bool flag8 = array[3]; if (flag8) { this.DrawHorizontalItem(g, this.foreBrush, x + num3 + this.ledNumberSize + num5, y + num + this.ledNumberSize + num6 + 2 * num5, width2); } else { this.DrawHorizontalItem(g, this.backBrush, x + num3 + this.ledNumberSize + num5, y + num + this.ledNumberSize + num6 + 2 * num5, width2); } bool flag9 = array[4]; if (flag9) { this.DrawVerticalItem(g, this.foreBrush, x + num3, y + num + 2 * this.ledNumberSize + 3 * num5 + num6, num6); } else { this.DrawVerticalItem(g, this.backBrush, x + num3, y + num + 2 * this.ledNumberSize + 3 * num5 + num6, num6); } bool flag10 = array[5]; if (flag10) { this.DrawVerticalItem(g, this.foreBrush, x + width - num4 - this.ledNumberSize, y + num + 2 * this.ledNumberSize + 3 * num5 + num6, num6); } else { this.DrawVerticalItem(g, this.backBrush, x + width - num4 - this.ledNumberSize, y + num + 2 * this.ledNumberSize + 3 * num5 + num6, num6); } bool flag11 = array[6]; if (flag11) { this.DrawHorizontalItem(g, this.foreBrush, x + num3 + this.ledNumberSize + num5, y + height - num2 - this.ledNumberSize, width2); } else { this.DrawHorizontalItem(g, this.backBrush, x + num3 + this.ledNumberSize + num5, y + height - num2 - this.ledNumberSize, width2); } bool flag12 = x + width - num5 * 2 < base.Width - 20; if (flag12) { bool flag13 = array[7]; if (flag13) { g.FillEllipse(this.foreBrush, x + width - this.ledPointSize, y + height - num2 - this.ledPointSize * 2 + 1, this.ledPointSize * 2, this.ledPointSize * 2); } else { g.FillEllipse(this.backBrush, x + width - this.ledPointSize, y + height - num2 - this.ledPointSize * 2 + 1, this.ledPointSize * 2, this.ledPointSize * 2); } } bool flag14 = array[8]; if (flag14) { Rectangle rect = new Rectangle(x + width / 2 - num5 * 2, y + num + this.ledNumberSize + num5 + num6 - num5 * 4, num5 * 4, num5 * 4); g.FillEllipse(this.foreBrush, rect); rect.Y += num5 + num5 + this.ledNumberSize + num5 + num5 * 4; g.FillEllipse(this.foreBrush, rect); } } } } /// /// 获取或设置控件的背景色 /// // Token: 0x170001B6 RID: 438 // (get) Token: 0x06000595 RID: 1429 RVA: 0x000373E9 File Offset: 0x000355E9 // (set) Token: 0x06000596 RID: 1430 RVA: 0x000373F1 File Offset: 0x000355F1 [Browsable(true)] [Description("获取或设置控件的背景色")] [Category("HslControls")] [DefaultValue(typeof(Color), "[46, 46, 46]")] [EditorBrowsable(EditorBrowsableState.Always)] public override Color BackColor { get { return base.BackColor; } set { base.BackColor = value; } } /// /// 获取或设置数码管显示的位数 /// // Token: 0x170001B7 RID: 439 // (get) Token: 0x06000597 RID: 1431 RVA: 0x000373FC File Offset: 0x000355FC // (set) Token: 0x06000598 RID: 1432 RVA: 0x00037414 File Offset: 0x00035614 [Category("HslControls")] [DefaultValue(6)] [Description("获取或设置数码管显示的位数")] public int DisplayNumber { get { return this.displayNumber; } set { bool flag = value >= 0 && value < 100; if (flag) { this.displayNumber = value; base.Invalidate(); } } } /// /// 获取或设置数码管显示的大小 /// // Token: 0x170001B8 RID: 440 // (get) Token: 0x06000599 RID: 1433 RVA: 0x00037444 File Offset: 0x00035644 // (set) Token: 0x0600059A RID: 1434 RVA: 0x0003745C File Offset: 0x0003565C [Category("HslControls")] [DefaultValue(12)] [Description("获取或设置数码管显示的大小")] public int LedNumberSize { get { return this.ledNumberSize; } set { this.ledNumberSize = value; base.Invalidate(); } } /// /// 获取或设置数码管显示的内容 /// // Token: 0x170001B9 RID: 441 // (get) Token: 0x0600059B RID: 1435 RVA: 0x00037470 File Offset: 0x00035670 // (set) Token: 0x0600059C RID: 1436 RVA: 0x00037488 File Offset: 0x00035688 [Category("HslControls")] [DefaultValue("100.0")] [Description("获取或设置数码管显示的内容")] public string DisplayText { get { return this.displayText; } set { this.displayText = value; base.Invalidate(); } } /// /// 获取或设置数码管数字的背景色 /// // Token: 0x170001BA RID: 442 // (get) Token: 0x0600059D RID: 1437 RVA: 0x0003749C File Offset: 0x0003569C // (set) Token: 0x0600059E RID: 1438 RVA: 0x000374B4 File Offset: 0x000356B4 [Category("HslControls")] [DefaultValue(typeof(Color), "[62, 62, 62]")] [Description("获取或设置数码管数字的背景色")] public Color DisplayBackColor { get { return this.backColor; } set { this.backColor = value; this.backBrush.Dispose(); this.backBrush = new SolidBrush(this.backColor); base.Invalidate(); } } /// /// 获取或设置数码管数字的前景色 /// // Token: 0x170001BB RID: 443 // (get) Token: 0x0600059F RID: 1439 RVA: 0x000374E2 File Offset: 0x000356E2 // (set) Token: 0x060005A0 RID: 1440 RVA: 0x000374EA File Offset: 0x000356EA [Category("HslControls")] [DefaultValue(typeof(Color), "Tomato")] [Description("获取或设置数码管数字的前景色")] [EditorBrowsable(EditorBrowsableState.Always)] public override Color ForeColor { get { return base.ForeColor; } set { base.ForeColor = value; this.foreBrush.Dispose(); this.foreBrush = new SolidBrush(value); base.Invalidate(); } } /// /// 获取或设置数码管数字的单位文本 /// // Token: 0x170001BC RID: 444 // (get) Token: 0x060005A1 RID: 1441 RVA: 0x00037514 File Offset: 0x00035714 // (set) Token: 0x060005A2 RID: 1442 RVA: 0x0003751C File Offset: 0x0003571C [Category("HslControls")] [DefaultValue("")] [Description("获取或设置数码管数字的单位文本")] public string UnitText { get { return this.unitText; } set { this.unitText = value; base.Invalidate(); } } /// /// 获取或设置数码管两端的空闲长度 /// // Token: 0x170001BD RID: 445 // (get) Token: 0x060005A3 RID: 1443 RVA: 0x0003752D File Offset: 0x0003572D // (set) Token: 0x060005A4 RID: 1444 RVA: 0x00037535 File Offset: 0x00035735 [Category("HslControls")] [DefaultValue(10)] [Description("获取或设置数码管两端的空闲长度")] public int LeftRightOffect { get { return this.leftRightOffect; } set { this.leftRightOffect = value; base.Invalidate(); } } /// /// 获取或设置数码管小数点的大小 /// // Token: 0x170001BE RID: 446 // (get) Token: 0x060005A5 RID: 1445 RVA: 0x00037546 File Offset: 0x00035746 // (set) Token: 0x060005A6 RID: 1446 RVA: 0x0003754E File Offset: 0x0003574E [Category("HslControls")] [DefaultValue(2)] [Description("获取或设置数码管小数点的大小")] public int LedPointSize { get { return this.ledPointSize; } set { this.ledPointSize = value; base.Invalidate(); } } // Token: 0x040002C6 RID: 710 private Color backColor = Color.FromArgb(62, 62, 62); // Token: 0x040002C7 RID: 711 private Brush backBrush = new SolidBrush(Color.FromArgb(62, 62, 62)); // Token: 0x040002C8 RID: 712 private Brush foreBrush = new SolidBrush(Color.Tomato); // Token: 0x040002C9 RID: 713 private int displayNumber = 6; // Token: 0x040002CA RID: 714 private int ledNumberSize = 12; // Token: 0x040002CB RID: 715 private string displayText = "100.0"; // Token: 0x040002CC RID: 716 private string supportChars = "0123456789AbCcdEFHhJLoPrU: -"; // Token: 0x040002CD RID: 717 private string unitText = string.Empty; // Token: 0x040002CE RID: 718 private int leftRightOffect = 10; // Token: 0x040002CF RID: 719 private int ledPointSize = 2; } }