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.

581 lines
18 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.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: 0x02000005 RID: 5
[Description("一个箭头控件,支持设置不同的方向,颜色,文本信息")]
public class HslArrow : UserControl
{
/// <summary>
/// 实例化一个默认的箭头控件
/// </summary>
// Token: 0x06000016 RID: 22 RVA: 0x000112AC File Offset: 0x0000F4AC
public HslArrow()
{
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);
}
/// <summary>
/// 获取或设置控件的背景色
/// </summary>
// Token: 0x17000003 RID: 3
// (get) Token: 0x06000017 RID: 23 RVA: 0x00011393 File Offset: 0x0000F593
// (set) Token: 0x06000018 RID: 24 RVA: 0x0001139B File Offset: 0x0000F59B
[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: 0x17000004 RID: 4
// (get) Token: 0x06000019 RID: 25 RVA: 0x000113A8 File Offset: 0x0000F5A8
// (set) Token: 0x0600001A RID: 26 RVA: 0x000113C0 File Offset: 0x0000F5C0
[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: 0x17000005 RID: 5
// (get) Token: 0x0600001B RID: 27 RVA: 0x000113D2 File Offset: 0x0000F5D2
// (set) Token: 0x0600001C RID: 28 RVA: 0x000113DA File Offset: 0x0000F5DA
[Browsable(true)]
[Description("获取或设置控件的前景色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "White")]
[EditorBrowsable(EditorBrowsableState.Always)]
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
/// <summary>
/// 获取或设置箭头控件的边缘颜色
/// </summary>
// Token: 0x17000006 RID: 6
// (get) Token: 0x0600001D RID: 29 RVA: 0x000113E4 File Offset: 0x0000F5E4
// (set) Token: 0x0600001E RID: 30 RVA: 0x000113FC File Offset: 0x0000F5FC
[Browsable(true)]
[Description("获取或设置箭头控件的边缘颜色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "DimGray")]
public virtual Color EdgeColor
{
get
{
return this.edgeColor;
}
set
{
this.edgeColor = value;
this.edgePen = new Pen(value, 1f);
base.Invalidate();
}
}
/// <summary>
/// 获取或设置箭头控件的方向
/// </summary>
// Token: 0x17000007 RID: 7
// (get) Token: 0x0600001F RID: 31 RVA: 0x00011420 File Offset: 0x0000F620
// (set) Token: 0x06000020 RID: 32 RVA: 0x00011438 File Offset: 0x0000F638
[Browsable(true)]
[Description("获取或设置箭头控件的方向")]
[Category("HslControls")]
[DefaultValue(typeof(ArrowDirection), "Right")]
public virtual ArrowDirection ArrowDirection
{
get
{
return this.arrowDirection;
}
set
{
this.arrowDirection = value;
base.Invalidate();
}
}
// Token: 0x17000008 RID: 8
// (get) Token: 0x06000021 RID: 33 RVA: 0x0001144C File Offset: 0x0000F64C
// (set) Token: 0x06000022 RID: 34 RVA: 0x00011464 File Offset: 0x0000F664
[Browsable(true)]
[Description("获取或设置箭头是否应用于两头,默认只有一个箭头")]
[Category("HslControls")]
[DefaultValue(false)]
public virtual bool ArrowBoth
{
get
{
return this.arrowBoth;
}
set
{
this.arrowBoth = value;
base.Invalidate();
}
}
/// <summary>
/// 获取或设置箭头背景的颜色
/// </summary>
// Token: 0x17000009 RID: 9
// (get) Token: 0x06000023 RID: 35 RVA: 0x00011478 File Offset: 0x0000F678
// (set) Token: 0x06000024 RID: 36 RVA: 0x00011490 File Offset: 0x0000F690
[Browsable(true)]
[Description("获取或设置箭头背景的颜色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "DodgerBlue")]
public virtual Color ArrowBackColor
{
get
{
return this.arrowBackColor;
}
set
{
this.arrowBackColor = value;
Brush brush = this.brushArrow;
if (brush != null)
{
brush.Dispose();
}
this.brushArrow = new SolidBrush(value);
base.Invalidate();
}
}
/// <summary>
/// 获取或设置横向宽度的比例值范围0-1
/// </summary>
// Token: 0x1700000A RID: 10
// (get) Token: 0x06000025 RID: 37 RVA: 0x000114C0 File Offset: 0x0000F6C0
// (set) Token: 0x06000026 RID: 38 RVA: 0x000114D8 File Offset: 0x0000F6D8
[Browsable(true)]
[Description("获取或设置横向宽度的比例值范围0-1")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "DodgerBlue")]
public virtual float FactorX
{
get
{
return this.factorX;
}
set
{
bool flag = value >= 0f && value <= 1f;
if (flag)
{
this.factorX = value;
base.Invalidate();
}
}
}
/// <summary>
/// 获取或设置纵向宽度的比例值范围0-0.5
/// </summary>
// Token: 0x1700000B RID: 11
// (get) Token: 0x06000027 RID: 39 RVA: 0x00011510 File Offset: 0x0000F710
// (set) Token: 0x06000028 RID: 40 RVA: 0x00011528 File Offset: 0x0000F728
[Browsable(true)]
[Description("获取或设置纵向宽度的比例值范围0-0.5")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "DodgerBlue")]
public virtual float FactorY
{
get
{
return this.factorY;
}
set
{
bool flag = value >= 0f && value <= 0.5f;
if (flag)
{
this.factorY = value;
base.Invalidate();
}
}
}
/// <summary>
/// 获取或设置本箭头控件是否使用渐进色
/// </summary>
// Token: 0x1700000C RID: 12
// (get) Token: 0x06000029 RID: 41 RVA: 0x00011560 File Offset: 0x0000F760
// (set) Token: 0x0600002A RID: 42 RVA: 0x00011568 File Offset: 0x0000F768
[Category("HslControls")]
[Description("获取或设置本箭头控件是否使用渐进色")]
[Browsable(true)]
[DefaultValue(true)]
public virtual bool UseGradient
{
get
{
return this.useGradient;
}
set
{
this.useGradient = value;
base.Invalidate();
}
}
/// <summary>
/// 重绘控件的
/// </summary>
/// <param name="e">重绘事件</param>
// Token: 0x0600002B RID: 43 RVA: 0x0001157C File Offset: 0x0000F77C
protected override void OnPaint(PaintEventArgs e)
{
Graphics graphics = e.Graphics;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
this.PaintHslControls(graphics, (float)base.Width, (float)base.Height);
base.OnPaint(e);
}
/// <summary>
/// 绘制当前控件的界面到指定的绘图上下文里面默认位置00需要指定宽度和高度信息
/// </summary>
/// <param name="g">绘图上下文</param>
/// <param name="width">宽度信息</param>
/// <param name="height">高度信息</param>
// Token: 0x0600002C RID: 44 RVA: 0x000115C0 File Offset: 0x0000F7C0
public void PaintHslControls(Graphics g, float width, float height)
{
bool flag = false;
if (true)
{
PointF[] array = null;
RectangleF layoutRectangle = default(RectangleF);
ArrowDirection arrowDirection = this.arrowDirection;
ArrowDirection arrowDirection2 = arrowDirection;
if (arrowDirection2 <= ArrowDirection.Up)
{
if (arrowDirection2 != ArrowDirection.Left)
{
if (arrowDirection2 == ArrowDirection.Up)
{
bool flag2 = !this.arrowBoth;
if (flag2)
{
array = new PointF[]
{
new PointF(width * 0.5f, 0f),
new PointF(width - 1f, height * (1f - this.factorX)),
new PointF(width * (1f - this.factorY), height * (1f - this.factorX)),
new PointF(width * (1f - this.factorY), height - 1f),
new PointF(width * this.factorY, height - 1f),
new PointF(width * this.factorY, height * (1f - this.factorX)),
new PointF(0f, height * (1f - this.factorX)),
new PointF(width * 0.5f, 0f)
};
layoutRectangle = new RectangleF(width * this.factorY, height * (1f - this.factorX) / 2f, width * (1f - this.factorY * 2f), height * (1f - (1f - this.factorX) / 2f));
}
else
{
array = new PointF[]
{
new PointF(width * 0.5f, 0f),
new PointF(width - 1f, height * (1f - this.factorX)),
new PointF(width * (1f - this.factorY), height * (1f - this.factorX)),
new PointF(width * (1f - this.factorY), height * this.factorX),
new PointF(width - 1f, height * this.factorX),
new PointF(width / 2f, height - 1f),
new PointF(0f, height * this.factorX),
new PointF(width * this.factorY, height * this.factorX),
new PointF(width * this.factorY, height * (1f - this.factorX)),
new PointF(0f, height * (1f - this.factorX)),
new PointF(width * 0.5f, 0f)
};
layoutRectangle = new RectangleF(width * this.factorY, 0f, width * (1f - this.factorY * 2f), height - 1f);
}
}
}
else
{
bool flag3 = !this.arrowBoth;
if (flag3)
{
array = new PointF[]
{
new PointF(0f, height * 0.5f),
new PointF(width * (1f - this.factorX), 0f),
new PointF(width * (1f - this.factorX), height * this.factorY),
new PointF(width - 1f, height * this.factorY),
new PointF(width - 1f, height * (1f - this.factorY)),
new PointF(width * (1f - this.factorX), height * (1f - this.factorY)),
new PointF(width * (1f - this.factorX), height - 1f),
new PointF(0f, height * 0.5f)
};
layoutRectangle = new RectangleF((1f - this.factorX) / 2f * width, height * this.factorY, width * (1f - (1f - this.factorX) / 2f), height * (1f - this.factorY * 2f));
}
else
{
array = new PointF[]
{
new PointF(0f, height * 0.5f),
new PointF(width * (1f - this.factorX), 0f),
new PointF(width * (1f - this.factorX), height * this.factorY),
new PointF(width * this.factorX, height * this.factorY),
new PointF(width * this.factorX, 0f),
new PointF(width - 1f, height * 0.5f),
new PointF(width * this.factorX, height - 1f),
new PointF(width * this.factorX, height * (1f - this.factorY)),
new PointF(width * (1f - this.factorX), height * (1f - this.factorY)),
new PointF(width * (1f - this.factorX), height - 1f),
new PointF(0f, height * 0.5f)
};
layoutRectangle = new RectangleF(0f, height * this.factorY, width - 1f, height * (1f - this.factorY * 2f));
}
}
}
else if (arrowDirection2 != ArrowDirection.Right)
{
if (arrowDirection2 == ArrowDirection.Down)
{
bool flag4 = !this.arrowBoth;
if (flag4)
{
array = new PointF[]
{
new PointF(width * (1f - this.factorY), 0f),
new PointF(width * (1f - this.factorY), height * this.factorX),
new PointF(width - 1f, height * this.factorX),
new PointF(width / 2f, height - 1f),
new PointF(0f, height * this.factorX),
new PointF(width * this.factorY, height * this.factorX),
new PointF(width * this.factorY, 0f),
new PointF(width * (1f - this.factorY), 0f)
};
layoutRectangle = new RectangleF(width * this.factorY, 0f, width * (1f - this.factorY * 2f), height * (1f - (1f - this.factorX) / 2f));
}
else
{
array = new PointF[]
{
new PointF(width * 0.5f, 0f),
new PointF(width - 1f, height * (1f - this.factorX)),
new PointF(width * (1f - this.factorY), height * (1f - this.factorX)),
new PointF(width * (1f - this.factorY), height * this.factorX),
new PointF(width - 1f, height * this.factorX),
new PointF(width / 2f, height - 1f),
new PointF(0f, height * this.factorX),
new PointF(width * this.factorY, height * this.factorX),
new PointF(width * this.factorY, height * (1f - this.factorX)),
new PointF(0f, height * (1f - this.factorX)),
new PointF(width * 0.5f, 0f)
};
layoutRectangle = new RectangleF(width * this.factorY, 0f, width * (1f - this.factorY * 2f), height - 1f);
}
}
}
else
{
bool flag5 = !this.arrowBoth;
if (flag5)
{
array = new PointF[]
{
new PointF(0f, height * this.factorY),
new PointF(width * this.factorX, height * this.factorY),
new PointF(width * this.factorX, 0f),
new PointF(width - 1f, height * 0.5f),
new PointF(width * this.factorX, height - 1f),
new PointF(width * this.factorX, height * (1f - this.factorY)),
new PointF(0f, height * (1f - this.factorY)),
new PointF(0f, height * this.factorY)
};
layoutRectangle = new RectangleF(0f, height * this.factorY, width * (1f - (1f - this.factorX) / 2f), height * (1f - this.factorY * 2f));
}
else
{
array = new PointF[]
{
new PointF(width * this.factorX, height * this.factorY),
new PointF(width * this.factorX, 0f),
new PointF(width - 1f, height * 0.5f),
new PointF(width * this.factorX, height - 1f),
new PointF(width * this.factorX, height * (1f - this.factorY)),
new PointF(width * (1f - this.factorX), height * (1f - this.factorY)),
new PointF(width * (1f - this.factorX), height - 1f),
new PointF(0f, height * 0.5f),
new PointF(width * (1f - this.factorX), 0f),
new PointF(width * (1f - this.factorX), height * this.factorY),
new PointF(width * this.factorX, height * this.factorY)
};
layoutRectangle = new RectangleF(0f, height * this.factorY, width - 1f, height * (1f - this.factorY * 2f));
}
}
bool flag6 = array == null;
if (!flag6)
{
bool flag7 = this.useGradient;
if (flag7)
{
ColorBlend colorBlend = new ColorBlend();
colorBlend.Positions = new float[]
{
0f,
0.5f,
1f
};
colorBlend.Colors = new Color[]
{
this.arrowBackColor,
HslHelper.GetColorLight(this.arrowBackColor),
this.arrowBackColor
};
bool flag8 = this.arrowDirection == ArrowDirection.Up || this.arrowDirection == ArrowDirection.Down;
if (flag8)
{
using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(new PointF(0f, 0f), new PointF(width - 1f, 0f), this.arrowBackColor, this.arrowBackColor))
{
linearGradientBrush.InterpolationColors = colorBlend;
g.FillPolygon(linearGradientBrush, array);
}
}
else
{
using (LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(new PointF(0f, 0f), new PointF(0f, height - 1f), this.arrowBackColor, this.arrowBackColor))
{
linearGradientBrush2.InterpolationColors = colorBlend;
g.FillPolygon(linearGradientBrush2, array);
}
}
}
else
{
g.FillPolygon(this.brushArrow, array);
}
g.DrawPolygon(this.edgePen, array);
using (Brush brush = new SolidBrush(this.ForeColor))
{
g.DrawString(this.Text, this.Font, brush, layoutRectangle, this.sf);
}
}
}
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
// Token: 0x0600002D RID: 45 RVA: 0x00012364 File Offset: 0x00010564
protected override void Dispose(bool disposing)
{
bool flag = disposing && this.components != null;
if (flag)
{
this.components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
// Token: 0x0600002E RID: 46 RVA: 0x0001239C File Offset: 0x0001059C
private void InitializeComponent()
{
base.SuspendLayout();
base.AutoScaleMode = AutoScaleMode.None;
this.BackColor = Color.Transparent;
this.ForeColor = Color.White;
base.Name = "HslArrow";
base.Size = new Size(176, 49);
base.ResumeLayout(false);
}
// Token: 0x04000010 RID: 16
private StringFormat sf = null;
// Token: 0x04000011 RID: 17
private Color edgeColor = Color.Gray;
// Token: 0x04000012 RID: 18
private Pen edgePen = new Pen(Color.Gray, 1f);
// Token: 0x04000013 RID: 19
private Color arrowBackColor = Color.DodgerBlue;
// Token: 0x04000014 RID: 20
private Brush brushArrow = new SolidBrush(Color.DodgerBlue);
// Token: 0x04000015 RID: 21
private ArrowDirection arrowDirection = ArrowDirection.Right;
// Token: 0x04000016 RID: 22
private float factorX = 0.75f;
// Token: 0x04000017 RID: 23
private float factorY = 0.27f;
// Token: 0x04000018 RID: 24
private bool useGradient = true;
// Token: 0x04000019 RID: 25
private bool arrowBoth = false;
/// <summary>
/// 必需的设计器变量。
/// </summary>
// Token: 0x0400001A RID: 26
private IContainer components = null;
}
}