using CCWin.SkinControl;
using DocumentFormat.OpenXml.EMMA;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using DocumentFormat.OpenXml.Office2019.Excel.RichData;
using GeBoShi.SysCtrl;
using GeBoShi.UI;
using GeBoShi.UI.DataQuery;
using GeBoShi.UI.InageShow;
using GeBoShi.UI.Load;
using GeBoShi.UI.Product;
using GeBoShi.UI.SysSet;
using HZH_Controls;
using HZH_Controls.Controls;
using HZH_Controls.Forms;
using ImageToolKits;
using MaiMuControl;
using MaiMuControl.Device;
using MaiMuControl.Device.CamDev;
using Models;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.WebControls.WebParts;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace GeBoShi
{
public partial class Main : Form
{
[DllImport("user32.dll ", EntryPoint = "SetParent")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); //将外部窗体嵌入程序
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpszClass, string lpszWindow); //按照窗体类名或窗体标题查找窗体
object AddTextLock = new object();
bool backgroundWorkerDo;
private Stopwatch RunStartTime = new Stopwatch();
///
/// 显示颜色现在对应30色,确保label在30个以内
///
Color[] ChartColor = new Color[30] { Color.Red, Color.Blue, Color.Green, Color.YellowGreen, Color.Orange,
Color.Peru, Color.DarkRed,Color.GreenYellow, Color.Pink , Color.Brown,
Color.CadetBlue, Color.OrangeRed, Color.Cyan, Color.Lime, Color.Magenta, Color.Tan, Color.Sienna,
Color.DarkGray, Color.SaddleBrown, Color.DarkBlue, Color.Firebrick,Color.Gainsboro,Color.Honeydew,Color.Khaki,Color.Lavender,
Color.LightGoldenrodYellow,Color.Navy, Color.Khaki, Color.IndianRed,Color.Lavender};
Process process = null;
IntPtr appWin;
public Main()
{
InitializeComponent();
UIStyle.SetUIStyle(this);
//process = Process.Start(@"C:\WINDOWS\system32\osk.exe");
//process.WaitForInputIdle();
//appWin = FindWindow(null, "屏幕键盘");
//SetParent(appWin, this.keyPanel.Handle);
this.keyPanel.Visible = false;
this.uiTitel1.FatherForm = this;
this.uiTitel1.UserMenuStrip = this.menuStrip1;
this.uiTitel1.ShowContrlBox(true, true, true);
this.uiTitel1.ShowMenu();
this.DoubleBuffered = true;//设置本窗体
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
SysMgr.Instance.MainRuning += main_running;
SysMgr.Instance.AutoRuning += auto_runing;
#region dataGridView设置
skinDataGridView1.AllowUserToAddRows = skinDataGridView1.AllowUserToDeleteRows = false;//用户添加删除行
skinDataGridView1.AllowUserToResizeRows = false;//用户调整行大小 //显示行号与列宽度自动调整
skinDataGridView1.RowHeadersVisible = true;
skinDataGridView1.RowHeadersWidth = 50;
//dataGridView1.ColumnHeadersHeightSizeMode = dataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
skinDataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;//数据量过百绑定太变
skinDataGridView1.RowTemplate.Height = 30;
//skinDataGridView1.RowPostPaint += (sender, e) =>//序号列头
//{
// showRowNum_onDataGrid_RowPostPaint(this.skinDataGridView1, sender, e);
//};
for (int i = 0; i < skinDataGridView1.Columns.Count; i++)//禁止点击列头排序
skinDataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
this.skinDataGridView1.CellClick += skinDataGridView1_CellClick; ;
#endregion
this.lblDefectLen.Top = toolStrip1.Top + 10;
this.lblDefectLen.Left = toolStrip1.Width - 300;
this.lblDefectSpeed.Top = toolStrip1.Top + 10 + lblDefectLen.Height + 5;
this.lblDefectSpeed.Left = toolStrip1.Width - 300;
this.lbFK.Text = "当前幅宽:";
}
#region 初始化
///
/// 初始化
///
///
private bool InitSystem()
{
//进入初始化,初始化失败则中断
InitFrm initFrm = new InitFrm();
initFrm.ShowDialog();
if (initFrm.DialogResult == DialogResult.OK)
{
//初始化成功
}
else
{
initFrm.Dispose();
return false;
}
initFrm.Dispose();
return true;
}
#endregion
#region 界面刷新
private void showRowNum_onDataGrid_RowPostPaint(DataGridView dgv, object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rectangle, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
private void ResetUI(bool clearSN)
{
//保持产品名称和料号
//txtProductName.Text = txtProductCode.Text = txtProductSN.Text = "";
if (clearSN)
cbPdtSN.Text = "";
this.logTxt.Text = "正常状态";
this.tsbtnImpStop.Enabled = false;
this.tsbtnStart.Enabled = true;
this.tsbtnStop.Enabled = false;
this.cbPdtSN.Enabled = true;
this.pictureBox1.Image = null;
pictureBox1.Refresh();
tslabelTime.Text = "实时测试队列";
skinDataGridView1.DataSource = null;
this.skinDataGridView1.Rows.Clear();
ResetChart();
lblDefectLen.Text = $"检测长度: 0 米";
lblDefectSpeed.Text = $"检测速度: 0 米/分钟";
ucSwitch1.Checked = SysMgr.Instance.GetDefectPause();
this.Refresh();
}
void ResetChart()
{
chart1.Series.Clear();
chart1.Series.Add("SELECT");
chart1.Series["SELECT"].ChartType = SeriesChartType.Point;
chart1.Series["SELECT"].MarkerSize = 25;
chart1.Series["SELECT"].MarkerColor = Color.Black;
chart1.Series["SELECT"].MarkerStyle = MarkerStyle.Star6;
//chart1.Series["SELECT"].Enabled = false;
//chart1.ChartAreas[0].AxisX.Title = "宽度(cm)";
//chart1.ChartAreas[0].AxisY.Title = "长度(m)";
chart3.Series.Clear();
chart3.Series.Add("面宽");
//chart3.ChartAreas[0].AxisX.Title = "长度(m)";
//chart3.ChartAreas[0].AxisY.Title = "宽度(cm)";
chart3.Series["面宽"].ChartType = SeriesChartType.Line;
chart3.Series["面宽"].MarkerSize = 5;
chart3.Series["面宽"].MarkerColor = Color.Blue;
chart3.Series["面宽"].MarkerStyle = MarkerStyle.Circle;
}
#endregion
#region 权限判断
private void UserRightCheck()
{
this.tsmPdtMgr.Enabled = SysMgr.Instance.UserMgr.RightControl(GeBoShi.UI.User.UserRightEnum.Product);
this.tsmSysDataFind.Visible = SysMgr.Instance.UserMgr.RightControl(GeBoShi.UI.User.UserRightEnum.Statistics);
this.tsmUserList.Enabled = SysMgr.Instance.UserMgr.RightControl(GeBoShi.UI.User.UserRightEnum.User);
this.tsmUserRight.Enabled = SysMgr.Instance.UserMgr.RightControl(GeBoShi.UI.User.UserRightEnum.Role);
if (this.tsmUserList.Enabled == false && this.tsmUserRight.Enabled == false)
this.tsmSysUserMgr.Visible = false;
else
this.tsmSysUserMgr.Visible = true;
this.tsmDebug.Enabled = SysMgr.Instance.UserMgr.RightControl(GeBoShi.UI.User.UserRightEnum.Debug);
this.tsmSysSet.Enabled = SysMgr.Instance.UserMgr.RightControl(GeBoShi.UI.User.UserRightEnum.ParamsSetting);
if (this.tsmDebug.Enabled == false && this.tsmSysSet.Enabled == false)
this.stmSysSet.Visible = false;
else
this.stmSysSet.Visible = true;
}
#endregion
#region 运行判断
///
/// 系统是否在运行
///
///
private bool SystemIsRun()
{
//if (SysMgr.Instance.IsRuning)
//{
// FrmDialog.ShowDialog(this, "设备正在运行中!", "警告", false);
// //MessageBox.Show("设备正在运行中!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return false;
//}
return true;
}
#endregion
#region 界面事件
private void Main_Load(object sender, EventArgs e)
{
//登入
if (SysMgr.Instance.LoginSystem())
{
//登入成功
if (InitSystem())
{
this.Cursor = Cursors.WaitCursor;
//this.WindowState = FormWindowState.Normal;
this.Top = 0;
this.Left = 0;
this.Width = SystemInformation.WorkingArea.Width;
this.Height = SystemInformation.WorkingArea.Height;
//this.WindowState = FormWindowState.Maximized;
//this.splitContainer1.SplitterDistance = this.Width / 3;
//this.tabControl1.ItemSize = new System.Drawing.Size(this.tabControl1.Width / 2 - 10, 26);
ResetUI(true);
this.Show();
this.tsslLoginInfo.Text = $"操作员:{SysMgr.Instance.UserMgr.LoginUser.Code}({SysMgr.Instance.UserMgr.LoginUser.Name})";
this.statusStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
this.tsslLoginTime.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsslLoginInfo.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsState.Text = "";
//更新数据库格式
Service.InitDB.initDB(ConfMgr.Instance.DBConStr);
//权限判断
UserRightCheck();
//开启后台
//timer1.Enabled = true;
backgroundWorkerDo = true;
backgroundWorker1.RunWorkerAsync();
//s_BackWorker = true;
//backgroundWorker.RunWorkerAsync();
//开启云端连接
//SysMgr.Instance.InitCloudConnect();
//开启产品服务
//SysMgr.Instance.InitPdtService();
//开启处理事件反馈
SysMgr.Instance.InitDefectEvent();
//加载产品料号
SysMgr.Instance.LoadProductCodeList();
//加载产品选择
LoadPdtList(SysMgr.Instance.ProductCodeList);
this.Cursor = Cursors.Default;
//运行前检测磁盘空间
SysMgr.CheckDisk(this, 100);
}
else
{
Application.Exit();
}
}
else
{
Application.Exit();
}
}
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (SystemIsRun())
{
DialogResult dr = DialogResult.Cancel;
if (SysMgr.Instance.IsInit)
{
dr = FrmDialog.ShowDialog(this, "确定要退出当前系统?", "警告", true);
}
else
dr = DialogResult.OK;
if (dr == DialogResult.Cancel)
{
e.Cancel = true;
}
else
{
backgroundWorkerDo = false;
//Thread.Sleep(300);
Thread.Sleep(300);
if (SysMgr.Instance.IsInit)
SysMgr.Instance.Close();
//SysMgr.Instance.MainRuning -= main_running;
}
}
else
e.Cancel = true;
}
private void Main_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
this.Top = 0;
this.Left = 0;
this.Width = SystemInformation.WorkingArea.Width;
this.Height = SystemInformation.WorkingArea.Height;
//this.tabControl1.ItemSize = new System.Drawing.Size(this.tabControl1.Width / 2 - 10, 26);
}
}
#endregion
#region 菜单
#region 退出
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
#region 用户
private void tsmUserRight_Click(object sender, EventArgs e)
{
SysMgr.Instance.UserPermissiomMgr();
}
private void tsmUserList_Click(object sender, EventArgs e)
{
SysMgr.Instance.UserListMgr();
}
#endregion
#region 系统设置
private void MainFrm_Paint(object sender, PaintEventArgs e)
{
this.tsbtnReset.Visible = ConfMgr.Instance.SysConfigParams.ShowResetBtn;
//this.tabControl1.ItemSize = new System.Drawing.Size(this.tabControl1.Width / 2 - 10, 26);
}
private void tsmSysSet_Click(object sender, EventArgs e)
{
if (SystemIsRun())
{
//SysMgr.Instance.StatusMgr.GotoSetParams();
//SysMgr.Instance.SendStatus();
SysSetFrm frm = new SysSetFrm();
frm.ShowDialog();
MainFrm_Paint(null, null);
//SysMgr.Instance.StatusMgr.GotoNormalStandby();
//SysMgr.Instance.SendStatus();
}
}
private void tsmDebug_Click(object sender, EventArgs e)
{
}
#endregion
#endregion
#region 检测管理
private string[] pdtlistData;
private void LoadPdtList(List list)
{
this.cbDefectCode.Items.Clear();
while (true)
{
bool bk = true;
for (int i = 0; i < list.Count; i++)
{
if (list[i] == null || string.IsNullOrEmpty(list[i]))
{
list.Remove(list[i]);
bk = false;
}
}
if (bk)
{
break;
}
}
this.pdtlistData = list.ToArray();
cbDefectCode.Items.AddRange(pdtlistData);//比使用DataSource速度要快一些
cbDefectCode.TextUpdate += cobList_TextUpdate;//重新绑定事件
cbDefectCode.KeyDown += CobList_KeyDown;
this.cbDefectCode.Text = "";
cbDefectCode.Focus();
cbDefectCode.SelectAll();
}
private void tsmPdtMgr_Click(object sender, EventArgs e)
{
if (SystemIsRun())
{
ProductListFrm frm = new ProductListFrm();
frm.WindowState = FormWindowState.Maximized;
frm.ShowDialog();
//加载产品料号
SysMgr.Instance.LoadProductCodeList();
//加载产品选择
LoadPdtList(SysMgr.Instance.ProductCodeList);
}
}
private void CobList_KeyDown(object sender, KeyEventArgs e)
{
ComboBox ctrl = sender as ComboBox;
if (e.KeyCode == Keys.Enter)
{
if (ctrl.Items.Count == 1)
ctrl.Text = ctrl.Items[0].ToString();
}
}
private void cobList_TextUpdate(object sender, EventArgs e)
{
ComboBox ctrl = sender as ComboBox;
if (ctrl.Text != null)
{
string str = ctrl.Text; //获取cb_material控件输入内
//清空combobox
ctrl.DataSource = null;
ctrl.Items.Clear();
string[] workOrderFiltered;
workOrderFiltered = pdtlistData.Where(x => x.IndexOf(str, StringComparison.CurrentCultureIgnoreCase) != -1).ToArray();//忽略大小写
ctrl.Items.AddRange(workOrderFiltered);//比使用DataSource速度要快一些
// 不存在符合条件时
//设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
ctrl.Cursor = Cursors.Default; //保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置
if (workOrderFiltered.Length > 0)
{
if (!ctrl.DroppedDown)
ctrl.DroppedDown = true; // 自动弹出下拉框
}
ctrl.SelectionStart = str.Length; // 设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
}
}
#endregion
#region 按钮
private void tsbtnStart_Click(object sender, EventArgs e)
{
if (!SysMgr.Instance.IsRuning)
{
//低报警自动复位
if (SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Warning)
{
if (SysMgr.Instance.StatusMgr.Warning == WarningEnum.Low)
{
SysMgr.Instance.StatusMgr.ClearWarning();
SysMgr.Instance.StatusMgr.GotoNormalStandby();
}
}
//提示正在报警中
if (SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Warning)
{
FrmDialog.ShowDialog(this, "系统报警中!无法启动运行!", "警告", false);
return;
}
//运行前检测磁盘空间
SysMgr.CheckDisk(this, 100);
this.Cursor = Cursors.WaitCursor;
System.Windows.Forms.Application.DoEvents();
if (SysMgr.Instance.StatusMgr.Status != SystemStsEnum.Pause)
{
ResetUI(false);
AddTextEvent("运行", $"启动自动检测流程");
//获取测试产品信息
string name = "";
string batch = "";
string reel = "";
string len = "";
string defname = this.cbDefectCode.Text;
if(string.IsNullOrEmpty(name))
{
name = "default";
}
if (SysMgr.Instance.StartRun(this, this.cbPdtSN.Text, ref defname, ref name, ref batch, ref reel, ref len))
{
this.tsbtnImpStop.Enabled = true;
this.tsbtnStop.Enabled = true;
this.tsbtnStart.Enabled = false;
//锁定信息
this.cbPdtSN.Enabled = false;
this.cbDefectCode.Enabled = false;
//记录开始运行时间
RunStartTime.Restart();
//重新显示
this.cbDefectCode.Text = defname;
ResetChart();
}
}
else //暂停状态开始
{
if (SysMgr.Instance.ReStartRun())
{
this.tsbtnStop.Enabled = true;
this.tsbtnStart.Enabled = false;
}
}
this.Cursor = Cursors.Default;
}
}
private void tsbtnReset_Click(object sender, EventArgs e)
{
}
private void tsbtnStop_Click(object sender, EventArgs e)
{
AddTextEvent("暂停", "手动暂停");
this.tsbtnStart.Enabled = true;
SysMgr.Instance.Stop();
SysMgr.Instance.StatusMgr.GotoPause();
SysMgr.Instance.SendStatus();
SysMgr.Instance.LedPause();
}
private void tsbtnWarning_Click(object sender, EventArgs e)
{
if (SysMgr.Instance.StatusMgr.Warning != WarningEnum.Normal)
{
AddTextEvent("清除", "手动清除报警");
SysMgr.Instance.StatusMgr.ClearWarning();
SysMgr.Instance.LedReady();
if (SysMgr.Instance.IsAuto)
SysMgr.Instance.StatusMgr.GotoPause();
else
SysMgr.Instance.StatusMgr.GotoNormalStandby();
SysMgr.Instance.SendStatus();
}
}
///
/// 结束验布
///
///
///
private void tsbtnImpStop_Click(object sender, EventArgs e)
{
AddTextEvent("结束验布", "手动结束验布");
SysMgr.Instance.StatusMgr.GotoPause();
SysMgr.Instance.DefectEnd(this);
this.tsbtnStop.Enabled = false;
this.tsbtnStart.Enabled = true;
this.tsbtnImpStop.Enabled = false;
SysMgr.Instance.StatusMgr.GotoNormalStandby();
SysMgr.Instance.SendStatus();
SysMgr.Instance.LedReady();
}
int cnnnt = 10;
private void tsbGoHome_Click(object sender, EventArgs e)
{
#if false
//测试散点
chart1.Series.Clear();
chart1.ChartAreas[0].AxisX.Title = "宽度(cm)";
chart1.ChartAreas[0].AxisY.Title = "长度(m)";
chart1.Series.Add("皱印");
chart1.Series["皱印"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
chart1.Series["皱印"].MarkerSize = 10;
chart1.Series["皱印"].MarkerColor = Color.Red;
chart1.Series["皱印"].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
for (int i = 0; i < cnnnt; i++)
this.chart1.Series["皱印"].Points.AddXY(i%5,i);
chart1.Series.Add("划伤");
chart1.Series["划伤"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
chart1.Series["划伤"].MarkerSize = 10;
chart1.Series["划伤"].MarkerColor = Color.Blue;
chart1.Series["划伤"].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
for (int i = 0; i < cnnnt; i++)
this.chart1.Series["划伤"].Points.AddXY(i % 5 + 0.5, i + 0.3);
chart1.ChartAreas[0].AxisY.Maximum = ((int)(this.chart1.Series["划伤"].Points.FindMaxByValue().YValues.Max() /10) + 1) * 10 + 5;
chart1.ChartAreas[0].AxisY.ScaleView.Scroll(System.Windows.Forms.DataVisualization.Charting.ScrollType.Last);
cnnnt +=20;
MemoryStream ms = new MemoryStream();
chart1.SaveImage(ms, ChartImageFormat.Bmp);
Bitmap bmp = new Bitmap(ms);
bmp.Save("111.jpg");
ms.Close();
#endif
//测试散点
chart3.Series.Clear();
//chart3.ChartAreas[0].AxisX.Title = "长度(m)";
//chart3.ChartAreas[0].AxisY.Title = "宽度(cm)";
chart3.Series.Add("面宽");
string tt = "面宽";
if (chart3.Series.FindByName(tt) == null)
chart3.Series.Add("面宽");
else
{
chart3.Series["面宽"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart3.Series["面宽"].MarkerSize = 5;
chart3.Series["面宽"].MarkerColor = Color.Blue;
chart3.Series["面宽"].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
Random rm = new Random();
for (int i = 0; i < cnnnt; i++)
this.chart3.Series["面宽"].Points.AddXY(i, rm.Next(140, 160));
cnnnt += 20;
}
//chart3.Series[0].f
//chart3.ChartAreas["ChartArea1"].AxisX.ScaleView.Scroll(ScrollType.Last);
}
private void 本地数据库查询ToolStripMenuItem_Click(object sender, EventArgs e)
{
DataQueryFrm frm = new DataQueryFrm();
frm.WindowState = FormWindowState.Maximized;
frm.ShowDialog();
}
#endregion
#region 显示图像和消息
private void logTxt_TextChanged(object sender, EventArgs e)
{
}
private void lstLog_DrawItem(object sender, DrawItemEventArgs e)
{
//e.DrawBackground();
//if (e.Index < 0) return;
//try
//{
// string str = lstLog.Items[e.Index].ToString();
// e.Graphics.DrawString(str.Substring(1), e.Font,
// new SolidBrush(str[0] == 'R' ? Color.Red : (str[0] == 'Y' ? Color.Orange : Color.Black)),
// e.Bounds);
//}
//catch (Exception ex)
//{
// e.Graphics.DrawString(ex.Message, e.Font,
// new SolidBrush(Color.Red),
// e.Bounds);
//}
}
///
/// 异步输出日志
///
/// 模板标识
/// 内容
///
private void AddTextEvent(string tag, string msg, WarningEnum level = WarningEnum.Normal, bool Show = true)
{
lock (AddTextLock)
{
if (tag != null && tag != "")
tag = $" - [{tag}]";
var now = DateTime.Now;
string tmsg = now.ToString("HH:mm:ss fff") + tag + " - " + msg;
//msg = (level == WarningEnum.Normal ? "B" : level == WarningEnum.Low ? "Y" : "R") + msg;
this.logTxt.Text = tmsg;
this.logTxt.ForeColor = (level == WarningEnum.Normal ? Color.White : level == WarningEnum.Low ? Color.Orange : Color.Red);
//报警弹窗
if (level != WarningEnum.Normal)
{
this.BeginInvoke(new System.Action(() =>
{
MessageBox.Show(tmsg, level == WarningEnum.Low ? "警告" : "报警", MessageBoxButtons.OK, level == WarningEnum.Low ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
}));
}
}
}
private void main_running(object sender, MainEventArgs e)
{
ShowMessage(e);
}
private delegate void ShowMessageDelegate(MainEventArgs e);
private void ShowMessage(MainEventArgs e)
{
if (InvokeRequired)
{
ShowMessageDelegate smd = new ShowMessageDelegate(ShowMessage);
this.BeginInvoke(smd, e);
}
else
{
AddTextEvent(e.Tag, e.Message, e.Warning, e.show);
}
}
///
/// 自动运行流程显示
///
///
///
private void auto_runing(object sender, RunEventArgs e)
{
ShowUIEvent(e);
}
private delegate void ShowUIEventDelegate(RunEventArgs e);
Bitmap bmp0;
Bitmap bmp1;
Bitmap bmp2;
private void ReDrawDefectPoints(List