using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Text;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DNSD_Controls
{
///
/// 表格控件
///
// Token: 0x0200005B RID: 91
[Description("一个表格控件")]
public class HslTable : UserControl
{
///
/// 实例化一个表格对象
///
// Token: 0x060007A5 RID: 1957 RVA: 0x00044274 File Offset: 0x00042474
public HslTable()
{
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);
bool flag = this.GetService(typeof(IDesignerHost)) != null || LicenseManager.UsageMode == LicenseUsageMode.Designtime;
if (flag)
{
this.tableValues.Add(new string[]
{
"φ31-61-2.5",
"1000",
"A类型",
"800 nm",
""
});
}
}
///
/// 获取或设置控件的背景色
///
// Token: 0x17000261 RID: 609
// (get) Token: 0x060007A6 RID: 1958 RVA: 0x00044442 File Offset: 0x00042642
// (set) Token: 0x060007A7 RID: 1959 RVA: 0x0004444A File Offset: 0x0004264A
[Browsable(true)]
[Description("获取或设置控件的背景色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "Transparent")]
[EditorBrowsable(EditorBrowsableState.Always)]
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
///
/// 获取或设置当前控件的文本
///
// Token: 0x17000262 RID: 610
// (get) Token: 0x060007A8 RID: 1960 RVA: 0x00044454 File Offset: 0x00042654
// (set) Token: 0x060007A9 RID: 1961 RVA: 0x0004446C File Offset: 0x0004266C
[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();
}
}
///
/// 获取或设置控件的前景色
///
// Token: 0x17000263 RID: 611
// (get) Token: 0x060007AA RID: 1962 RVA: 0x0004447E File Offset: 0x0004267E
// (set) Token: 0x060007AB RID: 1963 RVA: 0x00044486 File Offset: 0x00042686
[Browsable(true)]
[Description("获取或设置控件的前景色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "Gray")]
[EditorBrowsable(EditorBrowsableState.Always)]
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
Brush brush = this.textBrush;
if (brush != null)
{
brush.Dispose();
}
this.textBrush = new SolidBrush(value);
}
}
///
/// 获取或设置控件的表格边框的颜色
///
// Token: 0x17000264 RID: 612
// (get) Token: 0x060007AC RID: 1964 RVA: 0x000444AF File Offset: 0x000426AF
// (set) Token: 0x060007AD RID: 1965 RVA: 0x000444B7 File Offset: 0x000426B7
[Browsable(true)]
[Description("获取或设置控件的表格边框的颜色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "LightGray")]
public Color BorderColor
{
get
{
return this.borderColor;
}
set
{
this.borderColor = value;
Pen pen = this.borderPen;
if (pen != null)
{
pen.Dispose();
}
this.borderPen = new Pen(value);
base.Invalidate();
}
}
///
/// 获取或设置当前的标题的文本颜色
///
// Token: 0x17000265 RID: 613
// (get) Token: 0x060007AE RID: 1966 RVA: 0x000444E6 File Offset: 0x000426E6
// (set) Token: 0x060007AF RID: 1967 RVA: 0x000444EE File Offset: 0x000426EE
[Browsable(true)]
[Description("获取或设置当前的标题的文本颜色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "DimGray")]
public Color HeaderColor
{
get
{
return this.headerColor;
}
set
{
this.headerColor = value;
Brush brush = this.headerBrush;
if (brush != null)
{
brush.Dispose();
}
this.headerBrush = new SolidBrush(value);
base.Invalidate();
}
}
///
/// 获取或设置当前的最大标题的文本颜色
///
// Token: 0x17000266 RID: 614
// (get) Token: 0x060007B0 RID: 1968 RVA: 0x0004451D File Offset: 0x0004271D
// (set) Token: 0x060007B1 RID: 1969 RVA: 0x00044525 File Offset: 0x00042725
[Browsable(true)]
[Description("获取或设置当前的最大标题的文本颜色")]
[Category("HslControls")]
[DefaultValue(typeof(Color), "DarkSlateGray")]
public Color TopHeaderColor
{
get
{
return this.topTextColor;
}
set
{
this.topTextColor = value;
Brush brush = this.topTextBrush;
if (brush != null)
{
brush.Dispose();
}
this.topTextBrush = new SolidBrush(value);
base.Invalidate();
}
}
///
/// 获取或设置当前表格的数据行的行数,不包括顶部最大的标题行
///
// Token: 0x17000267 RID: 615
// (get) Token: 0x060007B2 RID: 1970 RVA: 0x00044554 File Offset: 0x00042754
// (set) Token: 0x060007B3 RID: 1971 RVA: 0x0004456C File Offset: 0x0004276C
[Browsable(true)]
[Description("获取或设置当前表格的数据行的行数,不包括顶部最大的标题行")]
[Category("HslControls")]
[DefaultValue(5)]
public int RowsTotalCount
{
get
{
return this.rowsTotalCount;
}
set
{
//bool flag = this.rowsTotalCount > 0;
//if (flag)
{
this.rowsTotalCount = value;
base.Invalidate();
}
}
}
///
/// 获取或设置当前最大标题的文本信息,默认为今日生产计划
///
// Token: 0x17000268 RID: 616
// (get) Token: 0x060007B4 RID: 1972 RVA: 0x00044597 File Offset: 0x00042797
// (set) Token: 0x060007B5 RID: 1973 RVA: 0x0004459F File Offset: 0x0004279F
[Browsable(true)]
[Description("获取或设置当前最大标题的文本信息,默认为今日生产计划")]
[Category("HslControls")]
[DefaultValue("今日生产计划")]
public string TopHeaderText
{
get
{
return this.topHeaderText;
}
set
{
this.topHeaderText = value;
base.Invalidate();
}
}
///
/// 获取或设置当前辅助标题的文本信息,默认为9月2日
///
// Token: 0x17000269 RID: 617
// (get) Token: 0x060007B6 RID: 1974 RVA: 0x000445B0 File Offset: 0x000427B0
// (set) Token: 0x060007B7 RID: 1975 RVA: 0x000445B8 File Offset: 0x000427B8
[Browsable(true)]
[Description("获取或设置当前辅助标题的文本信息,默认为9月2日")]
[Category("HslControls")]
[DefaultValue("9月2日")]
public string AssistHeaderText
{
get
{
return this.assistHeaderText;
}
set
{
this.assistHeaderText = value;
base.Invalidate();
}
}
///
/// 获取或设置当前最大标题的高度,如果小于1就是百分比,如果大于1就是绝对值
///
// Token: 0x1700026A RID: 618
// (get) Token: 0x060007B8 RID: 1976 RVA: 0x000445C9 File Offset: 0x000427C9
// (set) Token: 0x060007B9 RID: 1977 RVA: 0x000445D1 File Offset: 0x000427D1
[Browsable(true)]
[Description("获取或设置当前最大标题的高度,如果小于1就是百分比,如果大于1就是绝对值")]
[Category("HslControls")]
[DefaultValue(0.25f)]
public float TopHeaderHeight
{
get
{
return this.headHeight;
}
set
{
this.headHeight = value;
base.Invalidate();
}
}
///
/// 列的宽度信息设置,数组的长度决定了列的数量
///
// Token: 0x1700026B RID: 619
// (get) Token: 0x060007BA RID: 1978 RVA: 0x000445E2 File Offset: 0x000427E2
// (set) Token: 0x060007BB RID: 1979 RVA: 0x000445EA File Offset: 0x000427EA
[Category("HslControls")]
[Description("列的宽度信息设置,数组的长度决定了列的数量")]
[TypeConverter(typeof(CollectionConverter))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public float[] ColumnWidth
{
get
{
return this.columnWidth;
}
set
{
this.columnWidth = value;
base.Invalidate();
}
}
///
/// 列的标题信息设置,数组长度应该刚好是列的数组,如果少于,多出来的列则为空,如果大于,多出来的列则不显示
///
// Token: 0x1700026C RID: 620
// (get) Token: 0x060007BC RID: 1980 RVA: 0x000445FB File Offset: 0x000427FB
// (set) Token: 0x060007BD RID: 1981 RVA: 0x00044603 File Offset: 0x00042803
[Category("HslControls")]
[Description("列的标题信息设置,数组长度应该刚好是列的数组,如果少于,多出来的列则为空,如果大于,多出来的列则不显示")]
[TypeConverter(typeof(CollectionConverter))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public string[] ColumnHeader
{
get
{
return this.columnHeader;
}
set
{
this.columnHeader = value;
base.Invalidate();
}
}
///
/// 获取或设置顶部标题的字体大小,默认18
///
// Token: 0x1700026D RID: 621
// (get) Token: 0x060007BE RID: 1982 RVA: 0x00044614 File Offset: 0x00042814
// (set) Token: 0x060007BF RID: 1983 RVA: 0x0004461C File Offset: 0x0004281C
[Browsable(true)]
[Description("获取或设置顶部标题的字体大小,默认18")]
[Category("HslControls")]
[DefaultValue(28f)]
public float TopHeaderTextSize
{
get
{
return this.headTextSize;
}
set
{
this.headTextSize = value;
base.Invalidate();
}
}
///
/// 获取或设置是否显示列标题的文本信息
///
// Token: 0x1700026E RID: 622
// (get) Token: 0x060007C0 RID: 1984 RVA: 0x0004462D File Offset: 0x0004282D
// (set) Token: 0x060007C1 RID: 1985 RVA: 0x00044635 File Offset: 0x00042835
[Browsable(true)]
[Description("获取或设置是否显示列标题的文本信息")]
[Category("HslControls")]
[DefaultValue(true)]
public bool IsShowColumnHeader
{
get
{
return this.isShowColumnHeader;
}
set
{
this.isShowColumnHeader = value;
base.Invalidate();
}
}
///
// Token: 0x060007C2 RID: 1986 RVA: 0x00044648 File Offset: 0x00042848
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
bool flag = base.Width < 20 || base.Height < 20;
if (!flag)
{
this.PaintHslControls(e.Graphics, base.Width, (float)base.Height);
}
}
///
/// 可以在任意的画刷上绘制当前的控件的图形
///
/// 画刷
/// 宽度信息
/// 高度信息
// Token: 0x060007C3 RID: 1987 RVA: 0x000446A4 File Offset: 0x000428A4
public void PaintHslControls(Graphics g, int width, float height)
{
if (true)
{
float num = (this.headHeight < 1f) ? (height * this.headHeight) : this.headHeight;
float num2 = (this.rowsTotalCount == 0) ? (height - num) : ((height - num) / (float)this.rowsTotalCount);
bool flag2 = this.headHeight > 0f;
if (flag2)
{
RectangleF layoutRectangle = new RectangleF(0f, 0f, (float)width, num);
using (Font font = new Font(this.Font.FontFamily, this.headTextSize))
{
g.DrawString(this.topHeaderText, font, this.topTextBrush, layoutRectangle, this.sf);
SizeF sizeF = g.MeasureString(this.topHeaderText, font);
g.DrawString(this.assistHeaderText, this.Font, this.topTextBrush, new PointF((float)width * 0.5f + sizeF.Width / 2f, layoutRectangle.Height / 2f + (float)font.Height / 2f - (float)this.Font.Height - 1f));
}
}
bool flag3 = this.isShowColumnHeader;
if (flag3)
{
for (int i = 0; i < this.columnHeader.Length; i++)
{
bool flag4 = i + 1 < this.columnWidth.Length;
if (flag4)
{
RectangleF layoutRectangle2 = new RectangleF((float)width * this.columnWidth[i], num, (float)width * (this.columnWidth[i + 1] - this.columnWidth[i]), num2);
bool flag5 = !string.IsNullOrEmpty(this.columnHeader[i]);
if (flag5)
{
g.DrawString(this.columnHeader[i], this.Font, this.headerBrush, layoutRectangle2, this.sf);
}
}
}
}
g.DrawLine(this.borderPen, 0, 0, width - 1, 0);
bool flag6 = this.headHeight > 0f;
if (flag6)
{
g.DrawLine(this.borderPen, 0, (int)num, width - 1, (int)num);
}
for (int j = 1; j < this.rowsTotalCount; j++)
{
g.DrawLine(this.borderPen, 0, (int)((float)j * num2 + num), width - 1, (int)((float)j * num2 + num));
}
g.DrawLine(this.borderPen, 0f, height - 1f, (float)(width - 1), height - 1f);
g.DrawLine(this.borderPen, 0f, 0f, 0f, height - 1f);
g.DrawLine(this.borderPen, (float)(width - 1), 0f, (float)(width - 1), height - 1f);
for (int k = 0; k < this.columnWidth.Length - 1; k++)
{
g.DrawLine(this.borderPen, (float)((int)((float)width * this.columnWidth[k])), (float)((int)num), (float)((int)((float)width * this.columnWidth[k])), height - 1f);
}
for (int l = 0; l < this.tableValues.Count; l++)
{
for (int m = 0; m < this.columnHeader.Length; m++)
{
bool flag7 = m + 1 < this.columnWidth.Length;
if (flag7)
{
RectangleF rectangle = new RectangleF((float)width * this.columnWidth[m], num2 * (float)(l + (this.isShowColumnHeader ? 1 : 0)) + num, (float)width * (this.columnWidth[m + 1] - this.columnWidth[m]) - 1f, num2 - 1f);
bool flag8 = m < this.tableValues[l].Length;
if (flag8)
{
bool flag9 = this.OnDrawCellTextEvent == null;
if (flag9)
{
this.DrawCellText(g, l, m, rectangle, this.tableValues[l][m], this.sf);
}
else
{
this.OnDrawCellTextEvent(g, l, m, rectangle, this.tableValues[l][m], this.sf);
}
}
}
}
}
}
}
///
/// 当绘制单元格的时候触发
///
// Token: 0x1400000B RID: 11
// (add) Token: 0x060007C4 RID: 1988 RVA: 0x00044B04 File Offset: 0x00042D04
// (remove) Token: 0x060007C5 RID: 1989 RVA: 0x00044B3C File Offset: 0x00042D3C
public event HslTable.DrawCellTextDelegate OnDrawCellTextEvent;
///
/// 绘制单元格是核心方法,你也可以根据自己的需求进行重写,实现一些特殊的图形或是颜色显示
///
/// 绘图上下文
/// 行索引
/// 列索引
/// 文本的区域
/// 文本的值
/// 文本的对齐方式
// Token: 0x060007C6 RID: 1990 RVA: 0x00044B71 File Offset: 0x00042D71
public virtual void DrawCellText(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf)
{
g.DrawString(value, this.Font, this.textBrush, rectangle, sf);
}
///
/// 从底部新增一条数据信息
///
/// 数据信息
// Token: 0x060007C7 RID: 1991 RVA: 0x00044B8D File Offset: 0x00042D8D
public void AddRowDown(string[] values)
{
this.AddRowDown(new List
{
values
});
}
///
/// 从底部新增多条数据信息
///
/// 数据信息
// Token: 0x060007C8 RID: 1992 RVA: 0x00044BA4 File Offset: 0x00042DA4
public void AddRowDown(List values)
{
this.tableValues.AddRange(values);
bool flag = this.isShowColumnHeader;
if (flag)
{
while (this.tableValues.Count >= this.rowsTotalCount)
{
this.tableValues.RemoveAt(0);
}
}
else
{
while (this.tableValues.Count > this.rowsTotalCount)
{
this.tableValues.RemoveAt(0);
}
}
base.Invalidate();
}
///
/// 从顶部新增一条数据信息
///
/// 数据信息
// Token: 0x060007C9 RID: 1993 RVA: 0x00044C29 File Offset: 0x00042E29
public void AddRowTop(string[] values)
{
this.AddRowTop(new List
{
values
});
}
///
/// 从顶部新增一条数据信息
///
/// 数据信息
// Token: 0x060007CA RID: 1994 RVA: 0x00044C40 File Offset: 0x00042E40
public void AddRowTop(List values)
{
bool flag = values != null;
if (flag)
{
for (int i = 0; i < values.Count; i++)
{
this.tableValues.Insert(0, values[i]);
}
}
bool flag2 = this.isShowColumnHeader;
if (flag2)
{
while (this.tableValues.Count >= this.rowsTotalCount)
{
this.tableValues.RemoveAt(this.tableValues.Count - 1);
}
}
else
{
while (this.tableValues.Count > this.rowsTotalCount)
{
this.tableValues.RemoveAt(this.tableValues.Count - 1);
}
}
base.Invalidate();
}
///
/// 设置表的所有的数据信息
///
/// 数据值
// Token: 0x060007CB RID: 1995 RVA: 0x00044D09 File Offset: 0x00042F09
public void SetTableValue(List values)
{
this.tableValues = values;
base.Invalidate();
}
///
/// 设置当前的表格的指定单元的数据内容,需要传递单元格信息,数据值,是否刷新界面。
///
/// 所在的行号信息
/// 所在的列号信息
/// 数据值
/// 是否刷新界面
// Token: 0x060007CC RID: 1996 RVA: 0x00044D1C File Offset: 0x00042F1C
public void SetTableValue(int rowIndex, int colIndex, string value, bool updateUI = true)
{
bool flag = rowIndex >= this.tableValues.Count;
if (!flag)
{
bool flag2 = colIndex >= this.tableValues[rowIndex].Length;
if (!flag2)
{
this.tableValues[rowIndex][colIndex] = value;
if (updateUI)
{
base.Invalidate();
}
}
}
}
///
/// 获取指定行号,列号的单元格的文本信息,如果索引超出,返回NULL
///
/// 行号信息
/// 列号信息
/// 单元格文本信息
// Token: 0x060007CD RID: 1997 RVA: 0x00044D78 File Offset: 0x00042F78
public string GetTableValue(int rowIndex, int colIndex)
{
bool flag = rowIndex >= this.tableValues.Count;
string result;
if (flag)
{
result = null;
}
else
{
bool flag2 = colIndex >= this.tableValues[rowIndex].Length;
if (flag2)
{
result = null;
}
else
{
result = this.tableValues[rowIndex][colIndex];
}
}
return result;
}
///
/// 获取所有的数据信息
///
/// 单元格文本信息
// Token: 0x060007CE RID: 1998 RVA: 0x00044DD0 File Offset: 0x00042FD0
public List GetTableValue()
{
return this.tableValues;
}
///
/// 清理所有正在使用的资源。
///
/// 如果应释放托管资源,为 true;否则为 false。
// Token: 0x060007CF RID: 1999 RVA: 0x00044DE8 File Offset: 0x00042FE8
protected override void Dispose(bool disposing)
{
bool flag = disposing && this.components != null;
if (flag)
{
this.components.Dispose();
}
base.Dispose(disposing);
}
///
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
///
// Token: 0x060007D0 RID: 2000 RVA: 0x00044E20 File Offset: 0x00043020
private void InitializeComponent()
{
base.SuspendLayout();
base.AutoScaleMode = AutoScaleMode.None;
this.BackColor = Color.Transparent;
this.Font = new Font("微软雅黑", 9f, FontStyle.Regular, GraphicsUnit.Point, 134);
this.ForeColor = Color.Gray;
base.Name = "HslTable";
base.Size = new Size(444, 206);
base.ResumeLayout(false);
}
// Token: 0x040003C7 RID: 967
private StringFormat sf = null;
// Token: 0x040003C8 RID: 968
private Color borderColor = Color.LightGray;
// Token: 0x040003C9 RID: 969
private Pen borderPen = new Pen(Color.LightGray);
// Token: 0x040003CA RID: 970
private Brush textBrush = new SolidBrush(Color.Gray);
// Token: 0x040003CB RID: 971
private Color headerColor = Color.DimGray;
// Token: 0x040003CC RID: 972
private Brush headerBrush = new SolidBrush(Color.DimGray);
// Token: 0x040003CD RID: 973
private Color topTextColor = Color.DarkSlateGray;
// Token: 0x040003CE RID: 974
private Brush topTextBrush = new SolidBrush(Color.DarkSlateGray);
// Token: 0x040003CF RID: 975
private float headTextSize = 18f;
// Token: 0x040003D0 RID: 976
private float headHeight = 0.25f;
// Token: 0x040003D1 RID: 977
private int rowsTotalCount = 5;
// Token: 0x040003D2 RID: 978
private float[] columnWidth = new float[]
{
0f,
0.3f,
0.45f,
0.55f,
0.8f,
1f
};
// Token: 0x040003D3 RID: 979
private string[] columnHeader = new string[]
{
"规格",
"生产数量",
"工艺",
"完成度",
"特别说明"
};
// Token: 0x040003D4 RID: 980
private string topHeaderText = "今日生产计划";
// Token: 0x040003D5 RID: 981
private string assistHeaderText = "9月2日";
// Token: 0x040003D6 RID: 982
private List tableValues = new List();
// Token: 0x040003D7 RID: 983
private bool isShowColumnHeader = true;
///
/// 必需的设计器变量。
///
// Token: 0x040003D8 RID: 984
private IContainer components = null;
///
/// 绘制单元格的委托信息,可以自定义的实现一些高级的操作。
///
/// 绘图上下文
/// 行号
/// 列号
/// 绘图的区域
/// 本文内容
///
// Token: 0x020000FE RID: 254
// (Invoke) Token: 0x06000FCC RID: 4044
public delegate void DrawCellTextDelegate(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf);
}
}