|
|
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
|
|
|
{
|
|
|
|
|
|
[Description("报警灯控件,支持闪烁,颜色设置")]
|
|
|
public partial class HslLanternAlarm : UserControl
|
|
|
{
|
|
|
|
|
|
private Color bottomColor = Color.DimGray;
|
|
|
|
|
|
// Token: 0x040002B5 RID: 693
|
|
|
private Brush bottomBrush = new SolidBrush(Color.DimGray);
|
|
|
|
|
|
// Token: 0x040002B6 RID: 694
|
|
|
private Color lightColor = Color.Green;
|
|
|
|
|
|
// Token: 0x040002B7 RID: 695
|
|
|
private Brush lightBrush = new SolidBrush(Color.Green);
|
|
|
|
|
|
// Token: 0x040002B8 RID: 696
|
|
|
private Color alarmColor = Color.Tomato;
|
|
|
|
|
|
// Token: 0x040002B9 RID: 697
|
|
|
private Color normalColor = Color.Green;
|
|
|
|
|
|
// Token: 0x040002BA RID: 698
|
|
|
private bool isAlarm = false;
|
|
|
|
|
|
// Token: 0x040002BB RID: 699
|
|
|
private bool alarmStatus = false;
|
|
|
|
|
|
// Token: 0x040002BC RID: 700
|
|
|
private Timer timer = new Timer();
|
|
|
|
|
|
// Token: 0x040002BD RID: 701
|
|
|
private StringFormat sf = null;
|
|
|
|
|
|
// Token: 0x040002BE RID: 702
|
|
|
private float buttonHeight = 0.1f;
|
|
|
///// <summary>
|
|
|
///// 清理所有正在使用的资源。
|
|
|
///// </summary>
|
|
|
///// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
|
|
//// Token: 0x0600057A RID: 1402 RVA: 0x00035E68 File Offset: 0x00034068
|
|
|
//protected override void Dispose(bool disposing)
|
|
|
//{
|
|
|
// bool flag = disposing && this.components != null;
|
|
|
// if (flag)
|
|
|
// {
|
|
|
// this.components.Dispose();
|
|
|
// }
|
|
|
// base.Dispose(disposing);
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
|
{
|
|
|
bool flag = this.isAlarm;
|
|
|
if (flag)
|
|
|
{
|
|
|
bool flag2 = this.alarmStatus;
|
|
|
if (flag2)
|
|
|
{
|
|
|
this.LightColor = this.AlarmColor;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.LightColor = this.NormalColor;
|
|
|
}
|
|
|
this.alarmStatus = !this.alarmStatus;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.LightColor = this.NormalColor;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
{
|
|
|
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
|
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
|
|
Graphics graphics = e.Graphics;
|
|
|
this.PaintHslControls(graphics, base.Width, base.Height);
|
|
|
base.OnPaint(e);
|
|
|
}
|
|
|
|
|
|
|
|
|
public void PaintHslControls(Graphics g, int width, int height)
|
|
|
{
|
|
|
int num = (this.buttonHeight >= 1f) ? ((int)this.buttonHeight) : ((int)(this.buttonHeight * (float)height));
|
|
|
int num2 = width * 4 / 10;
|
|
|
bool flag2 = height - num2 - 2 * num > 0;
|
|
|
if (flag2)
|
|
|
{
|
|
|
g.FillRectangle(this.lightBrush, width / 10, num2, width * 8 / 10, height - num2 - 2 * num);
|
|
|
}
|
|
|
g.FillPie(this.lightBrush, width / 10, 1, width * 8 / 10, num2 * 2, 180, 180);
|
|
|
g.FillRectangle(this.bottomBrush, new Rectangle(0, height - 1 - num, width, num));
|
|
|
g.FillRectangle(this.bottomBrush, new Rectangle(width / 20, height - 1 - num * 2, width - width / 10, num));
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public HslLanternAlarm()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
base.SuspendLayout();
|
|
|
base.AutoScaleMode = AutoScaleMode.None;
|
|
|
this.BackColor = Color.Transparent;
|
|
|
base.Name = "HslLanternAlarm";
|
|
|
base.Size = new Size(99, 129);
|
|
|
base.ResumeLayout(false);
|
|
|
|
|
|
|
|
|
this.sf = new StringFormat();
|
|
|
this.sf.Alignment = StringAlignment.Center;
|
|
|
this.sf.LineAlignment = StringAlignment.Center;
|
|
|
base.SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
|
|
|
base.SetStyle(ControlStyles.ResizeRedraw, true);
|
|
|
base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
|
|
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
this.timer.Interval = 500;
|
|
|
this.timer.Tick += this.Timer_Tick;
|
|
|
|
|
|
NormalColor = System.Drawing.Color.White;
|
|
|
AlarmColor = System.Drawing.Color.Red;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置控件的背景色
|
|
|
/// </summary>
|
|
|
// Token: 0x170001A9 RID: 425
|
|
|
// (get) Token: 0x06000567 RID: 1383 RVA: 0x00035B51 File Offset: 0x00033D51
|
|
|
// (set) Token: 0x06000568 RID: 1384 RVA: 0x00035B59 File Offset: 0x00033D59
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置控件的背景色")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "Transparent")]
|
|
|
[EditorBrowsable(EditorBrowsableState.Always)]
|
|
|
public override Color BackColor
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return base.BackColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
base.BackColor = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置底座的背景色
|
|
|
/// </summary>
|
|
|
// Token: 0x170001AA RID: 426
|
|
|
// (get) Token: 0x06000569 RID: 1385 RVA: 0x00035B64 File Offset: 0x00033D64
|
|
|
// (set) Token: 0x0600056A RID: 1386 RVA: 0x00035B7C File Offset: 0x00033D7C
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置底座的背景色")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "DimGray")]
|
|
|
public Color BottomColor
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.bottomColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.bottomColor = value;
|
|
|
this.bottomBrush.Dispose();
|
|
|
this.bottomBrush = new SolidBrush(value);
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置报警灯的颜色,可以设置为任意的颜色
|
|
|
/// </summary>
|
|
|
// Token: 0x170001AB RID: 427
|
|
|
// (get) Token: 0x0600056B RID: 1387 RVA: 0x00035BA8 File Offset: 0x00033DA8
|
|
|
// (set) Token: 0x0600056C RID: 1388 RVA: 0x00035BC0 File Offset: 0x00033DC0
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置报警灯的颜色,可以设置为任意的颜色")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "Tomato")]
|
|
|
public Color LightColor
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.lightColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.lightColor = value;
|
|
|
this.lightBrush.Dispose();
|
|
|
this.lightBrush = new SolidBrush(value);
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置报警状态下的颜色
|
|
|
/// </summary>
|
|
|
// Token: 0x170001AC RID: 428
|
|
|
// (get) Token: 0x0600056D RID: 1389 RVA: 0x00035BEC File Offset: 0x00033DEC
|
|
|
// (set) Token: 0x0600056E RID: 1390 RVA: 0x00035C04 File Offset: 0x00033E04
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置报警状态下的颜色")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "Tomato")]
|
|
|
public Color AlarmColor
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.alarmColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.alarmColor = value;
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置正常状态的背景色
|
|
|
/// </summary>
|
|
|
// Token: 0x170001AD RID: 429
|
|
|
// (get) Token: 0x0600056F RID: 1391 RVA: 0x00035C18 File Offset: 0x00033E18
|
|
|
// (set) Token: 0x06000570 RID: 1392 RVA: 0x00035C30 File Offset: 0x00033E30
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置正常状态的背景色")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "LightGray")]
|
|
|
public Color NormalColor
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.normalColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.normalColor = value;
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 一旦设置本属性,启动信号灯闪烁
|
|
|
/// </summary>
|
|
|
// Token: 0x170001AE RID: 430
|
|
|
// (get) Token: 0x06000571 RID: 1393 RVA: 0x00035C44 File Offset: 0x00033E44
|
|
|
// (set) Token: 0x06000572 RID: 1394 RVA: 0x00035C5C File Offset: 0x00033E5C
|
|
|
[Browsable(true)]
|
|
|
[Description("一旦设置本属性,启动信号灯闪烁,信号灯在正常色和报警色之间进行闪烁")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(false)]
|
|
|
public bool IsAlarm
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.isAlarm;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.isAlarm = value;
|
|
|
bool flag = this.isAlarm;
|
|
|
if (flag)
|
|
|
{
|
|
|
this.timer.Start();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.timer.Stop();
|
|
|
this.LightColor = this.NormalColor;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置报警灯闪烁的频率,单位是毫秒,默认为500
|
|
|
/// </summary>
|
|
|
// Token: 0x170001AF RID: 431
|
|
|
// (get) Token: 0x06000573 RID: 1395 RVA: 0x00035CA6 File Offset: 0x00033EA6
|
|
|
// (set) Token: 0x06000574 RID: 1396 RVA: 0x00035CB3 File Offset: 0x00033EB3
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置报警灯闪烁的频率,单位是毫秒,默认为500")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(500)]
|
|
|
public int AlarmFlushTime
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.timer.Interval;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.timer.Interval = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置当前报警灯控件底部的高度信息,如果小于0,则表示百分比,如果大于1,则表示绝对像素单位
|
|
|
/// </summary>
|
|
|
// Token: 0x170001B0 RID: 432
|
|
|
// (get) Token: 0x06000575 RID: 1397 RVA: 0x00035CC2 File Offset: 0x00033EC2
|
|
|
// (set) Token: 0x06000576 RID: 1398 RVA: 0x00035CCA File Offset: 0x00033ECA
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置当前报警灯控件底部的高度信息,如果小于0,则表示百分比,如果大于1,则表示绝对像素单位")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(0.1f)]
|
|
|
public float ButtonHeight
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.buttonHeight;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.buttonHeight = value;
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|