|
|
using System;
|
|
|
using System.ComponentModel;
|
|
|
using System.Drawing;
|
|
|
using System.Drawing.Drawing2D;
|
|
|
using System.Drawing.Text;
|
|
|
using System.Net;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace DNSD_Controls
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 一个简约的灯控件,支持纯色和渐变色的设置
|
|
|
/// </summary>
|
|
|
// Token: 0x02000041 RID: 65
|
|
|
[Description("一个圆形的信号灯,支持设置颜色,是否渐变")]
|
|
|
public class HslLanternSimple : UserControl
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 实例化一个灯控件信息
|
|
|
/// </summary>
|
|
|
// Token: 0x0600058C RID: 1420 RVA: 0x00036A68 File Offset: 0x00034C68
|
|
|
public HslLanternSimple()
|
|
|
{
|
|
|
this.InitializeComponent();
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
// Token: 0x0600058D RID: 1421 RVA: 0x00036B18 File Offset: 0x00034D18
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
{
|
|
|
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
|
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
|
|
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
|
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
|
|
|
this.PaintHslControls(e.Graphics, base.Width, base.Height);
|
|
|
base.OnPaint(e);
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc cref="M:HslControls.HslArrow.PaintHslControls(System.Drawing.Graphics,System.Single,System.Single)" />
|
|
|
// Token: 0x0600058E RID: 1422 RVA: 0x00036B7C File Offset: 0x00034D7C
|
|
|
public void PaintHslControls(Graphics g, int width, int height)
|
|
|
{
|
|
|
|
|
|
if (true)
|
|
|
{
|
|
|
int num = Math.Min(width, height);
|
|
|
num--;
|
|
|
Point point = new Point(num / 2, num / 2);
|
|
|
g.TranslateTransform((float)point.X, (float)point.Y);
|
|
|
float num2 = (float)(point.X * 17) / 20f;
|
|
|
float num3 = (float)point.X / 20f;
|
|
|
bool flag2 = num2 < 2f;
|
|
|
if (!flag2)
|
|
|
{
|
|
|
RectangleF rect = new RectangleF(-num2 - 2f * num3, -num2 - 2f * num3, 2f * num2 + 4f * num3, 2f * num2 + 4f * num3);
|
|
|
RectangleF rect2 = new RectangleF(-num2, -num2, 2f * num2, 2f * num2);
|
|
|
using (Pen pen = new Pen(this.colorBackground, num3))
|
|
|
{
|
|
|
g.DrawEllipse(pen, rect);
|
|
|
}
|
|
|
bool flag3 = !this.UseGradientColor;
|
|
|
if (flag3)
|
|
|
{
|
|
|
g.FillEllipse(this.brushBackground, rect2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GraphicsPath graphicsPath = new GraphicsPath();
|
|
|
graphicsPath.AddEllipse(-num2, -num2, 2f * num2, 2f * num2);
|
|
|
PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath);
|
|
|
pathGradientBrush.CenterPoint = new Point(0, 0);
|
|
|
pathGradientBrush.InterpolationColors = new ColorBlend
|
|
|
{
|
|
|
Positions = new float[]
|
|
|
{
|
|
|
0f,
|
|
|
1f
|
|
|
},
|
|
|
Colors = new Color[]
|
|
|
{
|
|
|
this.colorBackground,
|
|
|
this.centerColor
|
|
|
}
|
|
|
};
|
|
|
g.FillEllipse(pathGradientBrush, rect2);
|
|
|
using (Pen pen2 = new Pen(this.colorBackground))
|
|
|
{
|
|
|
g.DrawEllipse(pen2, -num2, -num2, 2f * num2, 2f * num2);
|
|
|
}
|
|
|
pathGradientBrush.Dispose();
|
|
|
graphicsPath.Dispose();
|
|
|
}
|
|
|
g.TranslateTransform((float)(-(float)point.X), (float)(-(float)point.Y));
|
|
|
bool flag4 = height - num > 0;
|
|
|
if (flag4)
|
|
|
{
|
|
|
bool flag5 = !string.IsNullOrEmpty(this.Text);
|
|
|
if (flag5)
|
|
|
{
|
|
|
using (Brush brush = new SolidBrush(this.ForeColor))
|
|
|
{
|
|
|
g.DrawString(this.Text, this.Font, brush, new Rectangle(0, num, num, height - num), this.sf);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置控件的背景色
|
|
|
/// </summary>
|
|
|
// Token: 0x170001B6 RID: 438
|
|
|
// (get) Token: 0x0600058F RID: 1423 RVA: 0x00036E34 File Offset: 0x00035034
|
|
|
// (set) Token: 0x06000590 RID: 1424 RVA: 0x00036E3C File Offset: 0x0003503C
|
|
|
[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: 0x170001B7 RID: 439
|
|
|
// (get) Token: 0x06000591 RID: 1425 RVA: 0x00036E48 File Offset: 0x00035048
|
|
|
// (set) Token: 0x06000592 RID: 1426 RVA: 0x00036E60 File Offset: 0x00035060
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置信号灯的背景色")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "LimeGreen")]
|
|
|
public Color LanternBackground
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.colorBackground;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.colorBackground = value;
|
|
|
Brush brush = this.brushBackground;
|
|
|
if (brush != null)
|
|
|
{
|
|
|
brush.Dispose();
|
|
|
}
|
|
|
this.brushBackground = new SolidBrush(this.colorBackground);
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置中心点的颜色,当且仅当UseGradientColor属性为True时生效
|
|
|
/// </summary>
|
|
|
// Token: 0x170001B8 RID: 440
|
|
|
// (get) Token: 0x06000593 RID: 1427 RVA: 0x00036E94 File Offset: 0x00035094
|
|
|
// (set) Token: 0x06000594 RID: 1428 RVA: 0x00036EAC File Offset: 0x000350AC
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置中心点的颜色,当且仅当UseGradientColor属性为True时生效")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(typeof(Color), "White")]
|
|
|
public Color CenterBackground
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.centerColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.centerColor = value;
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置当前的灯信号是否启用渐变色的画刷
|
|
|
/// </summary>
|
|
|
// Token: 0x170001B9 RID: 441
|
|
|
// (get) Token: 0x06000595 RID: 1429 RVA: 0x00036EC0 File Offset: 0x000350C0
|
|
|
// (set) Token: 0x06000596 RID: 1430 RVA: 0x00036ED8 File Offset: 0x000350D8
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置当前的灯信号是否启用渐变色的画刷")]
|
|
|
[Category("HslControls")]
|
|
|
[DefaultValue(false)]
|
|
|
public bool UseGradientColor
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.isUseGradientColor;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.isUseGradientColor = value;
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取或设置当前控件的文本
|
|
|
/// </summary>
|
|
|
// Token: 0x170001BA RID: 442
|
|
|
// (get) Token: 0x06000597 RID: 1431 RVA: 0x00036EEC File Offset: 0x000350EC
|
|
|
// (set) Token: 0x06000598 RID: 1432 RVA: 0x00036F04 File Offset: 0x00035104
|
|
|
[Browsable(true)]
|
|
|
[Description("获取或设置当前控件的文本")]
|
|
|
[Category("HslControls")]
|
|
|
[EditorBrowsable(EditorBrowsableState.Always)]
|
|
|
[Bindable(true)]
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
|
public override string Text
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return base.Text;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
base.Text = value;
|
|
|
base.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 触发一次鼠标点击的事件
|
|
|
/// </summary>
|
|
|
// Token: 0x06000599 RID: 1433 RVA: 0x00036F16 File Offset: 0x00035116
|
|
|
public void PerformClick()
|
|
|
{
|
|
|
this.OnClick(new EventArgs());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 清理所有正在使用的资源。
|
|
|
/// </summary>
|
|
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
|
|
// Token: 0x0600059A RID: 1434 RVA: 0x00036F28 File Offset: 0x00035128
|
|
|
protected override void Dispose(bool disposing)
|
|
|
{
|
|
|
bool flag = disposing && this.components != null;
|
|
|
if (flag)
|
|
|
{
|
|
|
this.components.Dispose();
|
|
|
}
|
|
|
base.Dispose(disposing);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设计器支持所需的方法 - 不要修改
|
|
|
/// 使用代码编辑器修改此方法的内容。
|
|
|
/// </summary>
|
|
|
// Token: 0x0600059B RID: 1435 RVA: 0x00036F60 File Offset: 0x00035160
|
|
|
private void InitializeComponent()
|
|
|
{
|
|
|
base.SuspendLayout();
|
|
|
base.AutoScaleMode = AutoScaleMode.None;
|
|
|
this.BackColor = Color.Transparent;
|
|
|
base.Name = "HslLanternSimple";
|
|
|
base.Size = new Size(78, 94);
|
|
|
base.ResumeLayout(false);
|
|
|
}
|
|
|
|
|
|
// Token: 0x040002C7 RID: 711
|
|
|
private Color colorBackground = Color.LimeGreen;
|
|
|
|
|
|
// Token: 0x040002C8 RID: 712
|
|
|
private Brush brushBackground = new SolidBrush(Color.LimeGreen);
|
|
|
|
|
|
// Token: 0x040002C9 RID: 713
|
|
|
private StringFormat sf = null;
|
|
|
|
|
|
// Token: 0x040002CA RID: 714
|
|
|
private Color centerColor = Color.White;
|
|
|
|
|
|
// Token: 0x040002CB RID: 715
|
|
|
private bool isUseGradientColor = false;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 必需的设计器变量。
|
|
|
/// </summary>
|
|
|
// Token: 0x040002CC RID: 716
|
|
|
private IContainer components = null;
|
|
|
}
|
|
|
} |