using CCWin.SkinControl; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MaiMuAOI.SysUI.ProcessStep.Ctrl { public partial class NewStepShow : UserControl { public NewStepShow() { InitializeComponent(); RoundRadius = 10; StepName = "步骤名称"; stepIndex = 0; stepData = 0.000; stepMax = 0.000; stepMin = 0.000; stepString = ""; stepStatus = StepStsEnum.Error; dl = "f4"; daralen = 4; } #region Properties private string dl = ""; private int daralen; [Description("数据显示长度")] [Category("自定义外观")] public int DataLen { get { return daralen; } set { if (value <= 0) { daralen = 4; dl = "f4"; } else { daralen = value; dl = $"f{daralen}"; } base.Refresh(); } } private int roundRadius; [Description("圆角半径(0为不要圆角)")] [Category("自定义外观")] public int RoundRadius { get { return roundRadius; } set { if (value < 0) { roundRadius = 0; } else { roundRadius = value; } base.Refresh(); } } private string stepName; [Description("步骤名称")] [Category("自定义外观")] public string StepName { get { return stepName; } set { stepName = value; this.NameLabel.Text = stepName; base.Refresh(); } } private int stepIndex; [Description("步骤序号")] [Category("自定义外观")] public int StepIndex { get { return stepIndex; } set { stepIndex = value; this.IndexLabel.Text = stepIndex.ToString(); base.Refresh(); } } private double stepData; [Description("步骤数据")] [Category("自定义外观")] public double StepData { get { return stepData; } set { stepData = value; this.RelData.Text = stepData.ToString(dl); base.Refresh(); } } private double stepMax; [Description("步骤数据Max")] [Category("自定义外观")] public double StepMax { get { return stepMax; } set { stepMax = value; this.MaxValue.Text = stepMax.ToString(dl); base.Refresh(); } } private double stepMin; [Description("步骤数据Min")] [Category("自定义外观")] public double StepMin { get { return stepMin; } set { stepMin = value; this.MinValue.Text = stepMin.ToString(dl); base.Refresh(); } } private double stepMaxMin; [Description("步骤数据极差")] [Category("自定义外观")] public double StepMaxMin { get { return stepMaxMin; } set { stepMaxMin = value; this.JCValue.Text = stepMaxMin.ToString(dl); base.Refresh(); } } private string stepString; [Description("数据详细")] [Category("自定义外观")] public string StepString { get { return stepString; } set { stepString = value; this.AllDataTextBox.Text = stepString; base.Refresh(); } } public enum StepStsEnum { Skip, Wait, Testing, OK, NG, Error } private StepStsEnum stepStatus; [Description("步骤状态")] [Category("自定义外观")] public StepStsEnum StepStatus { get { return stepStatus; } set { stepStatus = value; switch(stepStatus) { case StepStsEnum.Wait: this.StsLabel.Text = "等待"; this.StsLabel.ForeColor = Color.Black; break; case StepStsEnum.Testing: this.StsLabel.Text = "测试中..."; this.StsLabel.ForeColor = SystemColors.MenuHighlight; break; case StepStsEnum.OK: this.StsLabel.Text = "OK"; this.StsLabel.ForeColor = Color.LimeGreen; break; case StepStsEnum.NG: this.StsLabel.Text = "NG"; this.StsLabel.ForeColor = Color.Red; break; case StepStsEnum.Error: this.StsLabel.Text = "错误"; this.StsLabel.ForeColor = Color.DarkRed; break; case StepStsEnum.Skip: this.StsLabel.Text = "未启用"; this.StsLabel.ForeColor = Color.Black; break; } base.Refresh(); } } #endregion #region Override Methods /// /// 在控件尺寸变化时刷新 /// /// protected override void OnResize(EventArgs e) { base.OnResize(e); base.Refresh(); } /// /// 将控件边框修改成圆角 /// /// protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Round(this.Region, RoundRadius); } #endregion #region UI Methods /// /// 绘制控件的圆角 /// /// /// public void Round(System.Drawing.Region region, int radius) { System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath(); int x = 0; int y = 0; int thisWidth = this.Width; int thisHeight = this.Height; int angle = radius; // 半径非0为圆角矩形 if (angle > 0) { System.Drawing.Graphics g = CreateGraphics(); oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角 oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角 oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角 oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角 oPath.CloseAllFigures(); Region = new System.Drawing.Region(oPath); } //半径为0时为矩形 else { angle = 0; oPath.AddLine(x + angle, y, thisWidth - angle, y); // 顶端 oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle); // 右边 oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边 oPath.AddLine(x, y + angle, x, thisHeight - angle); // 左边 oPath.CloseAllFigures(); Region = new System.Drawing.Region(oPath); } } #endregion } }