版博士V2.0程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

1792 linhas
76 KiB

  1. using CCWin;
  2. using CCWin.SkinClass;
  3. using CCWin.SkinControl;
  4. using HalconDotNet;
  5. using HZH_Controls.Forms;
  6. using MaiMuAOI.Properties;
  7. using MaiMuAOI.SysCtrl;
  8. using MaiMuAOI.SysUI.DefectPicShow;
  9. using MaiMuAOI.SysUI.Load;
  10. using MaiMuAOI.SysUI.ProcessStep;
  11. using MaiMuAOI.SysUI.ProcessStep.Ctrl;
  12. using MaiMuAOI.SysUI.ProductAndStep;
  13. using MaiMuAOI.SysUI.SysSet;
  14. using MaiMuAOI.SysUI.Web;
  15. using MaiMuAOI.UI.SysSet;
  16. using MaiMuControl.Device;
  17. using MaiMuControl.Device.CamDev;
  18. using MaiMuControl.Device.IOCardDev;
  19. using MaiMuControl.SysStatusMgr.StatusMgr;
  20. using Models;
  21. using Newtonsoft.Json.Linq;
  22. using OpenCvSharp;
  23. using ProductionControl;
  24. using System;
  25. using System.Collections.Generic;
  26. using System.ComponentModel;
  27. using System.Data;
  28. using System.Diagnostics;
  29. using System.Drawing;
  30. using System.Drawing.Imaging;
  31. using System.Linq;
  32. using System.Text;
  33. using System.Threading;
  34. using System.Threading.Tasks;
  35. using System.Windows.Forms;
  36. using static MaiMuAOI.SysCtrl.SysMgr;
  37. namespace MaiMuAOI
  38. {
  39. public partial class MainFrm : Form
  40. {
  41. private Service.ProductService svcProduct = new Service.ProductService();
  42. object AddTextLock = new object();
  43. object AddPicLock = new object();
  44. bool backgroundWorkerDo;
  45. bool DisEnableBuzz;
  46. bool DisEnableDoor;
  47. private Stopwatch RunStartTime = new Stopwatch();
  48. public MainFrm()
  49. {
  50. InitializeComponent();
  51. this.uiTitel1.FatherForm = this;
  52. this.uiTitel1.UserMenuStrip = this.menuStrip1;
  53. this.uiTitel1.ShowContrlBox(true, true, true);
  54. this.uiTitel1.ShowMenu();
  55. this.DoubleBuffered = true;//设置本窗体
  56. SetStyle(ControlStyles.UserPaint, true);
  57. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  58. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
  59. SysMgr.Instance.MainRuning += main_running;
  60. SysMgr.Instance.AutoRuning += auto_runing;
  61. SysMgr.Instance.AutoShowImg += auto_ShowMoreImg;
  62. SysMgr.Instance.AutoSizeShowImg += auto_SizeShowMoreImg;
  63. //显示行号与列宽度自动调整
  64. dgvProcess.RowHeadersVisible = true;
  65. dgvProcess.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
  66. dgvProcess.RowPostPaint += (sender, e) =>
  67. {
  68. SysMgr.showRowNum_onDataGrid_RowPostPaint(this.dgvProcess, sender, e);
  69. };
  70. dgvProcess.DefaultCellStyle.ForeColor = System.Drawing.Color.Black;
  71. this.lblTimeLen.Top = toolStrip1.Top + 10;
  72. this.lblTimeLen.Left = toolStrip1.Width - 300;
  73. this.lblOutput.Top = toolStrip1.Top + 10 + lblTimeLen.Height + 5;
  74. this.lblOutput.Left = toolStrip1.Width - 300;
  75. this.chkBuzzer.Top = toolStrip1.Top + 20;
  76. this.chkDoorSensor.Top = toolStrip1.Top + 20;
  77. }
  78. #region 私有方法
  79. /// <summary>
  80. /// 初始化
  81. /// </summary>
  82. /// <returns></returns>
  83. private bool InitSystem()
  84. {
  85. //进入初始化,初始化失败则中断
  86. InitFrm initFrm = new InitFrm();
  87. initFrm.ShowDialog();
  88. if (initFrm.DialogResult == DialogResult.OK)
  89. {
  90. //初始化成功
  91. }
  92. else
  93. {
  94. initFrm.Dispose();
  95. return false;
  96. }
  97. initFrm.Dispose();
  98. return true;
  99. }
  100. /// <summary>
  101. /// 系统是否在运行
  102. /// </summary>
  103. /// <returns></returns>
  104. private bool SystemIsRun()
  105. {
  106. if (SysMgr.Instance.IsRuning)
  107. {
  108. FrmDialog.ShowDialog(this, "设备正在运行中!", "警告", false);
  109. //MessageBox.Show("设备正在运行中!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  110. return false;
  111. }
  112. return true;
  113. }
  114. private void ClearDefectBmps()
  115. {
  116. this.pnlBmpList.Controls.Clear();
  117. this.gboxDefectList.Text = $"缺陷图像";
  118. this.gboxDefectList.Tag = 0;
  119. this.pnlSizeBmpList.Controls.Clear();
  120. this.gboxSizeDefectList.Text = $"尺寸图像";
  121. this.gboxSizeDefectList.Tag = 0;
  122. this.lblDefectAddTag.Text = "";
  123. this.lblDefectAddTag.Tag = 0;
  124. }
  125. private void ResetUI(bool clearSN)
  126. {
  127. //保持产品名称和料号
  128. //txtProductName.Text = txtProductCode.Text = txtProductSN.Text = "";
  129. if(clearSN)
  130. cbProductSN.Text = "";
  131. lblTension.ForeColor = Color.White;
  132. lblTension.Text = "0.00";
  133. lblTensionMax.Text = "0.00";
  134. lblTensionMin.Text = "0.00";
  135. lblHeight.ForeColor = Color.White;
  136. lblHeight.Text = "0.00";
  137. lblHeightMax.Text = "0.00";
  138. lblHeightMin.Text = "0.00";
  139. lblLineWidth.ForeColor = Color.White;
  140. lblLineWidth.Text = "0.00";
  141. lblLineWidthMax.Text = "0.00";
  142. lblLineWidthMin.Text = "0.00";
  143. lblPT.ForeColor = Color.White;
  144. lblPT.Text = "0.00";
  145. lblPTMax.Text = "0.00";
  146. lblPTMin.Text = "0.00";
  147. lblCompareResult.ForeColor = Color.White;
  148. lblCompareResult.Text = "无";
  149. //lblCompareCount.Text = "未通过:";
  150. lblDefectResult.ForeColor = Color.White;
  151. lblDefectResult.Text = "无";
  152. lblDefectResultCount.Text = "无";
  153. this.dgvProcess.DataSource = null;
  154. this.dgvProcess.DataSource = null;
  155. this.lstLog.Items.Clear();
  156. this.ClearDefectBmps();
  157. this.flpProcessStep.Controls.Clear();
  158. this.picScanner0.Image = null;
  159. picScanner0.Refresh();
  160. this.picScanner1.Image = null;
  161. picScanner1.Refresh();
  162. this.tsbtnStop.Enabled = false;
  163. this.cbOrderCode.Enabled = true;
  164. this.cbProductCode.Enabled = true;
  165. this.cbProductSN.Enabled = true;
  166. lblTimeLen.Text = "检测时长: 0 秒";
  167. tslabelTime.Text = "实时测试:0.00s";
  168. tslbSaveSts.Text = "保存队列:0";
  169. int daout = 0;
  170. if(ConfMgr.Instance.GetDailyOutput(out daout))
  171. {
  172. lblOutput.Text = $"当日产量: {daout} 个";
  173. }
  174. MainFrm_Paint(null, null);
  175. this.Refresh();
  176. }
  177. private void UserRightCheck()
  178. {
  179. this.tsmStepMgr.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Step);
  180. this.tsmPdtMgr.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Product);
  181. this.web数据查询ToolStripMenuItem.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Statistics);
  182. this.本地数据库查询ToolStripMenuItem.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Order);
  183. if (this.web数据查询ToolStripMenuItem.Enabled == false && this.本地数据库查询ToolStripMenuItem.Enabled == false)
  184. this.tsmSysDataFind.Visible = false;
  185. else
  186. this.tsmSysDataFind.Visible = true;
  187. //this.tsmSysDataFind.Visible = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Statistics);
  188. this.tsmUserList.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.User);
  189. this.tsmUserRight.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Role);
  190. if(this.tsmUserList.Enabled == false && this.tsmUserRight.Enabled == false)
  191. this.tsmSysUserMgr.Visible = false;
  192. else
  193. this.tsmSysUserMgr.Visible = true;
  194. this.tsmDebug.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Debug);
  195. this.快速调试ToolStripMenuItem.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.Debug);
  196. this.tsmSysSet.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.SysSetting);
  197. this.tsmSysPoints.Enabled = SysMgr.Instance.UserMgr.RightControl(MaiMuControl.SysStatusMgr.UserMgr.UserRightEnum.ParamsSetting);
  198. if (this.tsmDebug.Enabled == false && this.tsmSysSet.Enabled == false && this.快速调试ToolStripMenuItem.Enabled == false && this.tsmSysPoints.Enabled == false)
  199. this.stmSysSet.Visible = false;
  200. else
  201. this.stmSysSet.Visible = true;
  202. }
  203. #endregion
  204. private void MainFrm_Load(object sender, EventArgs e)
  205. {
  206. //登入
  207. if (SysMgr.Instance.LoginSystem())
  208. {
  209. //登入成功
  210. if (InitSystem())
  211. {
  212. this.Cursor = Cursors.WaitCursor;
  213. //this.WindowState = FormWindowState.Normal;
  214. this.Top = 0;
  215. this.Left = 0;
  216. this.Width = SystemInformation.WorkingArea.Width;
  217. this.Height = SystemInformation.WorkingArea.Height;
  218. //this.WindowState = FormWindowState.Maximized;
  219. this.splitContainer1.SplitterDistance = this.Width / 3;
  220. ResetUI(true);
  221. this.Show();
  222. this.dgvProcess.AutoGenerateColumns = false;
  223. this.tsslLoginInfo.Text = $"操作员:{SysMgr.Instance.UserMgr.LoginUser.Code}({SysMgr.Instance.UserMgr.LoginUser.Name})";
  224. //this.tsslLoginTime.Text = $" 登录时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}";
  225. this.statusStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
  226. this.tsslLoginTime.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
  227. this.tsslLoginInfo.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
  228. this.tsAxisState.Text = "";
  229. //设置流程卡显示
  230. this.tabControl1.SelectTab(0);
  231. //this.tabControl1.SelectTab(1);
  232. //更新数据库格式
  233. Service.InitDB.initDB();
  234. //权限判断
  235. UserRightCheck();
  236. //开启后台
  237. //timer1.Enabled = true;
  238. backgroundWorkerDo = true;
  239. backgroundWorker1.RunWorkerAsync();
  240. //s_BackWorker = true;
  241. //backgroundWorker.RunWorkerAsync();
  242. //开启web服务器
  243. SysMgr.Instance.InitWebServer();
  244. //开启云端连接
  245. SysMgr.Instance.InitCloudConnect();
  246. //开启产品服务
  247. SysMgr.Instance.InitPdtService();
  248. //开启处理事件反馈
  249. SysMgr.Instance.InitDefectEvent();
  250. //加载产品料号
  251. SysMgr.Instance.LoadProductCodeList();
  252. //加载产品选择
  253. LoadPdtList(SysMgr.Instance.ProductCodeList);
  254. LoadSNList(SysMgr.Instance.ProductSNList);
  255. this.Cursor = Cursors.Default;
  256. //运行前检测磁盘空间
  257. SysMgr.CheckDisk(this, 100);
  258. if (ConfMgr.Instance.SysConfigParams.CustomerName == "JA")
  259. lbJA.Visible = true;
  260. else
  261. lbJA.Visible = false;
  262. }
  263. else
  264. {
  265. Application.Exit();
  266. }
  267. }
  268. else
  269. {
  270. Application.Exit();
  271. }
  272. }
  273. private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
  274. {
  275. if (SystemIsRun())
  276. {
  277. DialogResult dr = DialogResult.Cancel;
  278. if (SysMgr.Instance.GetSaveQueueCnt() > 0)
  279. {
  280. dr = FrmDialog.ShowDialog(this, "图片正在保存,是否继续退出?", "警告", true);
  281. }
  282. else { dr = DialogResult.OK; }
  283. if (dr == DialogResult.OK)
  284. {
  285. if (SysMgr.Instance.IsInit)
  286. {
  287. dr = FrmDialog.ShowDialog(this, "确定要退出当前系统?", "警告", true);
  288. }
  289. else
  290. dr = DialogResult.OK;
  291. if (dr == DialogResult.Cancel)
  292. {
  293. e.Cancel = true;
  294. }
  295. else
  296. {
  297. backgroundWorkerDo = false;
  298. //Thread.Sleep(300);
  299. Thread.Sleep(300);
  300. if (SysMgr.Instance.IsInit)
  301. SysMgr.Instance.Close();
  302. //SysMgr.Instance.MainRuning -= main_running;
  303. }
  304. }
  305. else
  306. {
  307. e.Cancel = true;
  308. }
  309. }
  310. else
  311. e.Cancel = true;
  312. }
  313. #region 主界面
  314. private void toolStrip1_Paint(object sender, PaintEventArgs e)
  315. {
  316. if ((sender as ToolStrip).RenderMode == ToolStripRenderMode.System)
  317. {
  318. Rectangle rect = new Rectangle(0, 0, this.toolStrip1.Width, this.toolStrip1.Height - 2);
  319. e.Graphics.SetClip(rect);
  320. }
  321. }
  322. private void chkBuzzer_CheckedChanged(object sender, EventArgs e)
  323. {
  324. DisEnableBuzz = chkBuzzer.Checked;
  325. }
  326. private void chkDoorSensor_CheckedChanged(object sender, EventArgs e)
  327. {
  328. DisEnableDoor = chkDoorSensor.Checked;
  329. }
  330. private void MainFrm_Shown(object sender, EventArgs e)
  331. {
  332. }
  333. private void tsbCC_Click(object sender, EventArgs e)
  334. {
  335. if(this.tsbCC.Text == "尺寸启用")
  336. {
  337. this.tsbCC.Text = "尺寸禁用";
  338. this.tsbCC.Image = Resources.ccClose;
  339. SysMgr.Instance.SetSizeEnable(false);
  340. }
  341. else
  342. {
  343. this.tsbCC.Text = "尺寸启用";
  344. this.tsbCC.Image = Resources.ccOpen;
  345. SysMgr.Instance.SetSizeEnable(true);
  346. }
  347. }
  348. private void tsbQX_Click(object sender, EventArgs e)
  349. {
  350. if (this.tsbQX.Text == "缺陷启用")
  351. {
  352. this.tsbQX.Text = "缺陷禁用";
  353. this.tsbQX.Image = Resources.qxClose;
  354. SysMgr.Instance.SetDefectEnable(false);
  355. }
  356. else
  357. {
  358. this.tsbQX.Text = "缺陷启用";
  359. this.tsbQX.Image = Resources.qxOpen;
  360. SysMgr.Instance.SetDefectEnable(true);
  361. }
  362. }
  363. #endregion
  364. #region 菜单按钮
  365. private void tsmSysSet_Click(object sender, EventArgs e)
  366. {
  367. if (SystemIsRun())
  368. {
  369. SysMgr.Instance.StatusMgr.GotoSetParams();
  370. SysMgr.Instance.SendStatus();
  371. SysSetFrm frm = new SysSetFrm();
  372. frm.ShowDialog();
  373. MainFrm_Paint(null, null);
  374. SysMgr.Instance.StatusMgr.GotoNormalStandby();
  375. SysMgr.Instance.SendStatus();
  376. }
  377. }
  378. private void tsmUserRight_Click(object sender, EventArgs e)
  379. {
  380. SysMgr.Instance.UserPermissiomMgr();
  381. }
  382. private void tsmUserList_Click(object sender, EventArgs e)
  383. {
  384. SysMgr.Instance.UserListMgr();
  385. }
  386. private void tsmDebug_Click(object sender, EventArgs e)
  387. {
  388. if (SystemIsRun())
  389. {
  390. SysMgr.Instance.StatusMgr.GotoDebug();
  391. SysMgr.Instance.SendStatus();
  392. SysDebugFrm frm = new SysDebugFrm();
  393. frm.ShowDialog();
  394. SysMgr.Instance.StatusMgr.GotoNormalStandby();
  395. SysMgr.Instance.SendStatus();
  396. }
  397. }
  398. private void tsmSysPoints_Click(object sender, EventArgs e)
  399. {
  400. if (SystemIsRun())
  401. {
  402. SysMgr.Instance.StatusMgr.GotoSetParams();
  403. SysMgr.Instance.SendStatus();
  404. SysPointsFrm frm = new SysPointsFrm();
  405. frm.ShowDialog();
  406. SysMgr.Instance.StatusMgr.GotoNormalStandby();
  407. SysMgr.Instance.SendStatus();
  408. }
  409. }
  410. private void tsmSysDataFind_Click(object sender, EventArgs e)
  411. {
  412. //WebFrm frm = new WebFrm("查询统计", $"reportRecordSN?CustomerVer=B",
  413. // "http://127.0.0.1:" + ConfMgr.Instance.SysConfigParams.HttpServerPort.ToString() + "/static/index.html#/");
  414. //WebFrm frm = new WebFrm("查询统计", $"reportRecordSN?CustomerVer=B");
  415. //frm.WindowState = FormWindowState.Maximized;
  416. //frm.Show();
  417. }
  418. private void web数据查询ToolStripMenuItem_Click(object sender, EventArgs e)
  419. {
  420. WebFrm frm = new WebFrm("查询统计", $"reportRecordSN?CustomerVer=B");
  421. frm.WindowState = FormWindowState.Maximized;
  422. frm.Show();
  423. }
  424. private void 本地数据库查询ToolStripMenuItem_Click(object sender, EventArgs e)
  425. {
  426. DataQueryFrm frm = new DataQueryFrm();
  427. frm.WindowState = FormWindowState.Maximized;
  428. frm.Show();
  429. }
  430. private void 系统管理ToolStripMenuItem_Click(object sender, EventArgs e)
  431. {
  432. if (SystemIsRun())
  433. {
  434. ProductListFrm frm = new ProductListFrm();
  435. frm.ShowDialog();
  436. //加载产品料号
  437. SysMgr.Instance.LoadProductCodeList();
  438. //加载产品选择
  439. LoadPdtList(SysMgr.Instance.ProductCodeList);
  440. }
  441. }
  442. private void toolStripMenuItem1_Click(object sender, EventArgs e)
  443. {
  444. if (SystemIsRun())
  445. {
  446. StepListFrm frm = new StepListFrm();
  447. frm.ShowDialog();
  448. }
  449. }
  450. private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
  451. {
  452. this.Close();
  453. }
  454. private void tsmInfoUS_Click(object sender, EventArgs e)
  455. {
  456. SysInfoFrm frm = new SysInfoFrm();
  457. frm.ShowDialog();
  458. }
  459. private void tsmReadLog_Click(object sender, EventArgs e)
  460. {
  461. SysLogFrm frm = new SysLogFrm();
  462. frm.ShowDialog();
  463. }
  464. private void tsmHelpInfo_Click(object sender, EventArgs e)
  465. {
  466. //MessageBox.Show(SysUpdata.Updata, "更新信息");
  467. SysUpdataInfoFrm frm = new SysUpdataInfoFrm(SysUpdata.Updata);
  468. frm.ShowDialog();
  469. }
  470. private void tsmSoftFile_Click(object sender, EventArgs e)
  471. {
  472. string fileName = ConfMgr.Instance.SpecificationPath;//输入打开文件路径
  473. Process.Start(fileName);//使用process进程打开
  474. }
  475. private void 快速调试ToolStripMenuItem_Click(object sender, EventArgs e)
  476. {
  477. DebugTestFrm frm = new DebugTestFrm();
  478. //frm.TopMost = true;
  479. frm.ShowDialog();
  480. }
  481. #endregion
  482. #region 显示图像和消息
  483. private void lstLog_DrawItem(object sender, DrawItemEventArgs e)
  484. {
  485. e.DrawBackground();
  486. if (e.Index < 0) return;
  487. try
  488. {
  489. string str = lstLog.Items[e.Index].ToString();
  490. e.Graphics.DrawString(str.Substring(1), e.Font,
  491. new SolidBrush(str[0] == 'R' ? Color.Red : (str[0] == 'Y' ? Color.Orange : Color.Black)),
  492. e.Bounds);
  493. }
  494. catch(Exception ex)
  495. {
  496. e.Graphics.DrawString(ex.Message, e.Font,
  497. new SolidBrush( Color.Red ),
  498. e.Bounds);
  499. }
  500. }
  501. /// <summary>
  502. /// 异步输出日志
  503. /// </summary>
  504. /// <param name="tag">模板标识</param>
  505. /// <param name="msg">内容</param>
  506. /// <param name="type"></param>
  507. private void AddTextEvent(string tag, string msg, WarningEnum level = WarningEnum.Normal)
  508. {
  509. lock (AddTextLock)
  510. {
  511. if (tag != null && tag != "")
  512. tag = $" - [{tag}]";
  513. var now = DateTime.Now;
  514. msg = now.ToString("HH:mm:ss fff") + tag + " - " + msg;
  515. msg = (level == WarningEnum.Normal ? "B" : level == WarningEnum.Low ? "Y" : "R") + msg;
  516. if (this.lstLog.Items.Count > 1000)
  517. this.lstLog.Items.Clear();
  518. lstLog.Items.Insert(0, msg);
  519. }
  520. }
  521. private void main_running(object sender, MainEventArgs e)
  522. {
  523. ShowMessage(e);
  524. }
  525. private delegate void ShowMessageDelegate(MainEventArgs e);
  526. private void ShowMessage(MainEventArgs e)
  527. {
  528. if (InvokeRequired)
  529. {
  530. ShowMessageDelegate smd = new ShowMessageDelegate(ShowMessage);
  531. this.BeginInvoke(smd, e);
  532. }
  533. else
  534. {
  535. AddTextEvent(e.Tag, e.Message, e.Warning);
  536. }
  537. }
  538. /// <summary>
  539. /// 自动运行流程显示
  540. /// </summary>
  541. /// <param name="sender"></param>
  542. /// <param name="e"></param>
  543. private void auto_runing(object sender, RunEventArgs e)
  544. {
  545. ShowUIEvent(e);
  546. }
  547. private delegate void ShowUIEventDelegate(RunEventArgs e);
  548. Bitmap bmp0;
  549. Bitmap bmp1;
  550. private void ShowUIEvent(RunEventArgs e)
  551. {
  552. if (InvokeRequired)
  553. {
  554. ShowUIEventDelegate smd = new ShowUIEventDelegate(ShowUIEvent);
  555. this.BeginInvoke(smd, e);
  556. }
  557. else
  558. {
  559. try
  560. {
  561. if (e.Cmd == 0) //显示SN和流程
  562. {
  563. this.cbProductSN.Text = e.SN;
  564. if (e.NewStep)
  565. {
  566. this.tabControl1.SelectTab(1);
  567. ShowNewStepProcess(e.StepProcessesList);
  568. }
  569. else
  570. {
  571. this.tabControl1.SelectTab(0);
  572. this.dgvProcess.DataSource = new BindingSource(e.StepProcessesList, null);
  573. }
  574. }
  575. else if (e.Cmd == 1) //显示当前运行步骤
  576. {
  577. this.dgvProcess.Rows[e.StepIndex].Selected = true;
  578. dgvProcess.CurrentCell = dgvProcess.Rows[e.StepIndex].Cells[1];
  579. }
  580. else if (e.Cmd == 2) //显示当前运行步骤 和步骤详情
  581. {
  582. this.dgvProcess.Rows[e.StepIndex].Cells["colValue"].Value = e.Mesg;
  583. }
  584. else if (e.Cmd == 3) //图纸比对结果
  585. {
  586. this.lblCompareResult.Text = (e.CompareResult ? "通过" : $"未通过");
  587. this.lblCompareResultCount.Text = e.Cnt.ToString();
  588. if (!e.CompareResult)
  589. {
  590. this.lblCompareResult.ForeColor = Color.Red;
  591. }
  592. else
  593. this.lblCompareResult.ForeColor = Color.Lime;
  594. }
  595. else if (e.Cmd == 4) //缺陷结果
  596. {
  597. lblDefectResult.Text = "未通过";
  598. lblDefectResultCount.Text = $"总数:{e.Cnt},详细:{e.CompareResultString}";
  599. this.toolTip1.SetToolTip(lblDefectResultCount, lblDefectResultCount.Text);
  600. this.lblDefectResult.Text = (e.CompareResult ? "通过" : "未通过");
  601. if (!e.CompareResult)
  602. {
  603. this.lblDefectResult.ForeColor = Color.Red;
  604. }
  605. else
  606. this.lblDefectResult.ForeColor = Color.Lime;
  607. }
  608. else if (e.Cmd == 5) //加载缺陷小图
  609. {
  610. ;
  611. }
  612. else if (e.Cmd == 6) //显示主图
  613. {
  614. if (e.PicIndex == 0)
  615. {
  616. bmp0 = (Bitmap)CamDev.HImageToBitmap(e.Pic).Clone();
  617. picScanner0.Image = bmp0;
  618. picScanner0.Refresh();
  619. }
  620. else
  621. {
  622. bmp1 = (Bitmap)CamDev.HImageToBitmap(e.Pic).Clone();
  623. picScanner1.Image = bmp1;
  624. picScanner1.Refresh();
  625. }
  626. }
  627. else if (e.Cmd == 7) //显示测试时间
  628. {
  629. lblTimeLen.Text = "检测时长: " + e.Time.ToString("0.000") + " 秒";
  630. }
  631. else if (e.Cmd == 8) //显示测试时间
  632. {
  633. lblOutput.Text = "当日产量: " + e.Num.ToString("0") + " 个";
  634. }
  635. else if (e.Cmd == 10) //测试结束
  636. {
  637. this.tsbtnStart.Enabled = true;
  638. this.tsbtnStop.Enabled = false;
  639. this.cbOrderCode.Enabled = true;
  640. this.cbProductCode.Enabled = true;
  641. this.cbProductSN.Enabled = true;
  642. //演示重新开始
  643. Thread.Sleep(1000);
  644. if(SysMgr.Instance.GetYanShiValue())
  645. {
  646. tsbtnStart_Click(null, null);
  647. }
  648. }
  649. else if (e.Cmd == 21) //厚度显示
  650. {
  651. double value = Math.Round(e.Value.Average(), 2);
  652. double valueMax = e.Value.Max();
  653. double valueMin = e.Value.Min();
  654. Color color = (e.Value_up + e.Value_low > 0 && (value > e.Value_up || value < e.Value_low)) ? Color.Red : Color.White;
  655. Color colorMax = (e.Value_up + e.Value_low > 0 && (valueMax > e.Value_up || valueMax < e.Value_low)) ? Color.Red : Color.White;
  656. Color colorMin = (e.Value_up + e.Value_low > 0 && (valueMin > e.Value_up || valueMin < e.Value_low)) ? Color.Red : Color.White;
  657. this.lblHeight.Text = Math.Round(value, 2).ToString();
  658. this.lblHeight.ForeColor = color;
  659. this.lblHeightMax.Text = Math.Round(valueMax, 2).ToString();
  660. this.lblHeightMax.ForeColor = colorMax;
  661. this.lblHeightMin.Text = Math.Round(valueMin, 2).ToString();
  662. this.lblHeightMin.ForeColor = colorMin;
  663. }
  664. else if (e.Cmd == 22) //PT显示
  665. {
  666. double value = Math.Round(e.Value.Average(), 4);
  667. double valueMax = e.Value.Max();
  668. double valueMin = e.Value.Min();
  669. Color color = (e.Value_up + e.Value_low > 0 && (value > e.Value_up || value < e.Value_low)) ? Color.Red : Color.White;
  670. Color colorMax = (e.Value_up + e.Value_low > 0 && (valueMax > e.Value_up || valueMax < e.Value_low)) ? Color.Red : Color.White;
  671. Color colorMin = (e.Value_up + e.Value_low > 0 && (valueMin > e.Value_up || valueMin < e.Value_low)) ? Color.Red : Color.White;
  672. this.lblPT.Text = Math.Round(value, 4).ToString();
  673. this.lblPT.ForeColor = color;
  674. this.lblPTMax.Text = Math.Round(valueMax, 4).ToString();
  675. this.lblPTMax.ForeColor = colorMax;
  676. this.lblPTMin.Text = Math.Round(valueMin, 4).ToString();
  677. this.lblPTMin.ForeColor = colorMin;
  678. }
  679. else if (e.Cmd == 23) //线宽显示
  680. {
  681. double value = Math.Round(e.Value.Average(), 2);
  682. double valueMax = e.Value.Max();
  683. double valueMin = e.Value.Min();
  684. Color color = (e.Value_up + e.Value_low > 0 && (value > e.Value_up || value < e.Value_low)) ? Color.Red : Color.White;
  685. Color colorMax = (e.Value_up + e.Value_low > 0 && (valueMax > e.Value_up || valueMax < e.Value_low)) ? Color.Red : Color.White;
  686. Color colorMin = (e.Value_up + e.Value_low > 0 && (valueMin > e.Value_up || valueMin < e.Value_low)) ? Color.Red : Color.White;
  687. this.lblLineWidth.Text = Math.Round(value, 2).ToString();
  688. this.lblLineWidth.ForeColor = color;
  689. this.lblLineWidthMax.Text = Math.Round(valueMax, 2).ToString();
  690. this.lblLineWidthMax.ForeColor = colorMax;
  691. this.lblLineWidthMin.Text = Math.Round(valueMin, 2).ToString();
  692. this.lblLineWidthMin.ForeColor = colorMin;
  693. }
  694. else if (e.Cmd == 30) //新流程 厚度, 张力, pt, 线宽显示
  695. {
  696. Control[] controls = flpProcessStep.Controls.Find("Step_" + (e.StepIndex +1), true);
  697. //滚动条滚动
  698. //int scrollStep = (this.flpProcessStep.VerticalScroll.Maximum / (flpProcessStep.Controls.Count - 1));
  699. this.flpProcessStep.VerticalScroll.Value = e.StepIndex * controls[0].Height > this.flpProcessStep.VerticalScroll.Maximum? this.flpProcessStep.VerticalScroll.Maximum: e.StepIndex * controls[0].Height;
  700. if (!e.ProcessType)
  701. {
  702. NewStepShow newStepShow = controls[0] as NewStepShow;
  703. if (e.Mesg == "镜头变焦")
  704. {
  705. newStepShow.ShowLimitAndVal(false);
  706. string str1 = e.Value_ave == 0 ? "开启自动聚焦" : "关闭自动聚焦";
  707. string str2 = e.Value_up == 0 ? "自动变倍" : "手动变倍";
  708. string str3 = e.Value_low == 0 ? "自动Z轴聚焦" : "手动Z轴聚焦";
  709. string ShowData = e.Mesg + $"-{str1}-{str2}-{str3}";
  710. newStepShow.StepString = ShowData;
  711. }
  712. if (e.Mesg == "光源设置")
  713. {
  714. newStepShow.ShowLimitAndVal(false);
  715. string ShowData = e.Mesg + $":通道号:{e.Value_up},亮度:{e.Value_low}";
  716. newStepShow.StepString = ShowData;
  717. }
  718. else
  719. {
  720. //显示上下限
  721. if (e.Limit_low != -1 && e.Limit_up != -1 && e.StVal != -1)
  722. {
  723. newStepShow.ShowLimit(true);
  724. newStepShow.LimitMax = e.Limit_up;
  725. newStepShow.LimitMin = e.Limit_low;
  726. newStepShow.StdVal = e.StVal;
  727. }
  728. else
  729. newStepShow.ShowLimit(false);
  730. newStepShow.StepMax = e.Value_up;
  731. newStepShow.StepMin = e.Value_low;
  732. newStepShow.StepData = e.Value_ave;
  733. newStepShow.StepMaxMin = e.Value_up - e.Value_low;
  734. if (e.Value != null && e.Value.Count > 0)
  735. {
  736. string ShowData = e.Mesg + $"1:{e.Value[0].ToString($"f{newStepShow.DataLen}")}";
  737. for (int i = 1; i < e.Value.Count; i++)
  738. {
  739. ShowData += $",{e.Mesg}{i + 1}:{e.Value[i].ToString($"f{newStepShow.DataLen}")}";
  740. }
  741. newStepShow.StepString = ShowData;
  742. }
  743. else
  744. newStepShow.StepString = e.Mesg;
  745. }
  746. if (e.ProcessSts == 1)
  747. newStepShow.StepStatus = NewStepShow.StepStsEnum.Testing;
  748. else if (e.ProcessSts == 2)
  749. newStepShow.StepStatus = NewStepShow.StepStsEnum.OK;
  750. else if (e.ProcessSts == 3)
  751. newStepShow.StepStatus = NewStepShow.StepStsEnum.NG;
  752. else if (e.ProcessSts == 0)
  753. newStepShow.StepStatus = NewStepShow.StepStsEnum.Skip;
  754. else if (e.ProcessSts == 4)
  755. newStepShow.StepStatus = NewStepShow.StepStsEnum.Error;
  756. }
  757. else
  758. {
  759. NewStepShowDefect newStepShowDef = controls[0] as NewStepShowDefect;
  760. if (newStepShowDef != null)
  761. {
  762. newStepShowDef.StepString = e.Mesg;
  763. if (e.ProcessSts == 1)
  764. newStepShowDef.StepStatus = NewStepShowDefect.StepStsEnum.Testing;
  765. else if (e.ProcessSts == 2)
  766. newStepShowDef.StepStatus = NewStepShowDefect.StepStsEnum.OK;
  767. else if (e.ProcessSts == 3)
  768. newStepShowDef.StepStatus = NewStepShowDefect.StepStsEnum.NG;
  769. else if (e.ProcessSts == 0)
  770. newStepShowDef.StepStatus = NewStepShowDefect.StepStsEnum.Skip;
  771. else if (e.ProcessSts == 4)
  772. newStepShowDef.StepStatus = NewStepShowDefect.StepStsEnum.Error;
  773. if (e.Value_ave == 0)
  774. {
  775. newStepShowDef.StepSizeData = (int)e.Value_up;
  776. if (e.Value_up > 0)
  777. newStepShowDef.StepSizeSts = NewStepShowDefect.StepResultEnum.NG;
  778. else if (e.Value_up < 0)
  779. newStepShowDef.StepSizeSts = NewStepShowDefect.StepResultEnum.None;
  780. else if (e.Value_up == 0)
  781. newStepShowDef.StepSizeSts = NewStepShowDefect.StepResultEnum.OK;
  782. else
  783. newStepShowDef.StepSizeSts = NewStepShowDefect.StepResultEnum.Error;
  784. }
  785. else
  786. {
  787. if (e.Value_low == 0)
  788. newStepShowDef.StepDefectData = (int)e.Value_low;
  789. else if (e.Value_low > 0)
  790. newStepShowDef.StepDefectData = newStepShowDef.StepDefectData + (int)e.Value_low;
  791. //if (e.Value_low > 0)
  792. // newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.NG;
  793. //else if (e.Value_low < 0)
  794. // newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.None;
  795. //else if ((e.Value_low == 0)&&(e.Value_up == 0))
  796. // newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.OK;
  797. if ((e.Value_up == -1) && (e.Value_low == -1))
  798. newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.Error;
  799. else if (e.Value_up == 1)
  800. newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.Testing;
  801. else if (e.Value_up == 0)
  802. {
  803. newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.Done;
  804. newStepShowDef.StepDefectData = (int)e.Value_low;
  805. }
  806. }
  807. }
  808. }
  809. }
  810. else if (e.Cmd == 31) //忽略流程 厚度, 张力, pt, 线宽显示
  811. {
  812. Control[] controls = flpProcessStep.Controls.Find("Step_" + (e.StepIndex + 1), true);
  813. if (controls != null)
  814. {
  815. if (!e.ProcessType)
  816. {
  817. NewStepShow newStepShow = controls[0] as NewStepShow;
  818. newStepShow.StepMax = 0;
  819. newStepShow.StepMin = 0;
  820. newStepShow.StepData = 0;
  821. string ShowData = e.Mesg;
  822. newStepShow.StepString = ShowData;
  823. if (e.ProcessSts == 4)
  824. newStepShow.StepStatus = NewStepShow.StepStsEnum.Error;
  825. else
  826. newStepShow.StepStatus = NewStepShow.StepStsEnum.Skip;
  827. }
  828. else
  829. {
  830. NewStepShowDefect newStepShowDef = controls[0] as NewStepShowDefect;
  831. newStepShowDef.StepStatus = NewStepShowDefect.StepStsEnum.Skip;
  832. newStepShowDef.StepDefectData = -1;
  833. newStepShowDef.StepDefectSts = NewStepShowDefect.StepResultEnum.None;
  834. newStepShowDef.StepSizeData = -1;
  835. newStepShowDef.StepSizeSts = NewStepShowDefect.StepResultEnum.None;
  836. newStepShowDef.StepString = "未启用或被禁用";
  837. newStepShowDef.StepString = e.Mesg;
  838. }
  839. }
  840. }
  841. else if (e.Cmd == 36) //显示主图
  842. {
  843. if (e.PicIndex == 0)
  844. {
  845. bmp0 = (Bitmap)e.Map.Clone();
  846. picScanner0.Image = bmp0;
  847. picScanner0.Refresh();
  848. }
  849. else
  850. {
  851. bmp1 = (Bitmap)e.Map.Clone();
  852. picScanner1.Image = bmp1;
  853. picScanner1.Refresh();
  854. }
  855. }
  856. Application.DoEvents();
  857. }
  858. catch { }
  859. }
  860. }
  861. void ShowNewStepProcess(List<StepProcess> list)
  862. {
  863. flpProcessStep.Controls.Clear();
  864. int index = 0;
  865. int splitWidth = 5;
  866. foreach (StepProcess stepProcess in list)
  867. {
  868. index++;
  869. if (stepProcess.ProcessCode != "SizeAndDefect")
  870. {
  871. NewStepShow newStepShow = new NewStepShow();
  872. int dl = 4;
  873. if(stepProcess.ProcessCode == "PointTest")
  874. {
  875. string tp = JObject.Parse(stepProcess.ProcessParams).Value<string>("TestType");
  876. var tdl = ConfMgr.Instance.SizeItemParamsList.Find(x => x.Name == tp);
  877. if (tdl != null) { dl = tdl.dataLen; }
  878. }
  879. newStepShow.DataLen = dl;
  880. newStepShow.Width = flpProcessStep.Width - splitWidth * 2 - 30;
  881. newStepShow.StepName = stepProcess.ProcessName;
  882. newStepShow.StepIndex = index;
  883. newStepShow.StepMax = 0;
  884. newStepShow.StepMin = 0;
  885. newStepShow.StepData = 0;
  886. newStepShow.StepString = "";
  887. newStepShow.StepStatus = NewStepShow.StepStsEnum.Wait;
  888. newStepShow.Margin = new Padding(splitWidth, splitWidth, 0, 0);
  889. newStepShow.Name = "Step_" + index;
  890. flpProcessStep.Controls.Add(newStepShow);
  891. }
  892. else
  893. {
  894. NewStepShowDefect newStepShowDefect = new NewStepShowDefect();
  895. newStepShowDefect.Width = flpProcessStep.Width - splitWidth * 2 - 30;
  896. newStepShowDefect.StepName = stepProcess.ProcessName;
  897. newStepShowDefect.StepIndex = index;
  898. bool opensize = JObject.Parse(stepProcess.ProcessParams).Value<bool>("OpenSize");
  899. newStepShowDefect.StepSizeSts = opensize ? NewStepShowDefect.StepResultEnum.Wait: NewStepShowDefect.StepResultEnum.None;
  900. newStepShowDefect.StepSizeData = -1;
  901. bool opendefect = JObject.Parse(stepProcess.ProcessParams).Value<bool>("OpenDefect");
  902. newStepShowDefect.StepDefectSts = opendefect? NewStepShowDefect.StepResultEnum.Wait: NewStepShowDefect.StepResultEnum.None;
  903. newStepShowDefect.StepDefectData = -1;
  904. newStepShowDefect.StepString = "";
  905. newStepShowDefect.StepStatus = NewStepShowDefect.StepStsEnum.Wait;
  906. newStepShowDefect.Margin = new Padding(splitWidth, splitWidth, 0, 0);
  907. newStepShowDefect.Name = "Step_" + index;
  908. flpProcessStep.Controls.Add(newStepShowDefect);
  909. }
  910. }
  911. }
  912. /// <summary>
  913. /// 缺陷小图多图显示
  914. /// </summary>
  915. /// <param name="sender"></param>
  916. /// <param name="e"></param>
  917. private void auto_ShowMoreImg(object sender, ImgEventArgs e)
  918. {
  919. ShowImgEvent(e);
  920. }
  921. private delegate void ShowImgEventDelegate(ImgEventArgs e);
  922. private void ShowImgEvent(ImgEventArgs e)
  923. {
  924. if (InvokeRequired)
  925. {
  926. ShowImgEventDelegate smd = new ShowImgEventDelegate(ShowImgEvent);
  927. this.BeginInvoke(smd, e);
  928. }
  929. else
  930. {
  931. //Task<int> tt = new Task<int>(() =>
  932. //{
  933. //lock (AddPicLock)
  934. {
  935. //加载缺陷小图
  936. //纵向显示
  937. int imgWidth = this.pnlBmpList.ClientSize.Width - 50;
  938. int imgHeight = (int)((e.Bitmaps[0].Height * 1.0f / e.Bitmaps[0].Width) * imgWidth + 0.5);
  939. int splitWidth = 20;
  940. int pnlWidth = this.pnlBmpList.ClientSize.Width;
  941. int index = (int)this.gboxDefectList.Tag;
  942. //横向显示
  943. //int imgHeight = this.pnlBmpList.Height - 50;
  944. //int imgWidth = (int)((e.Bitmaps[0].Width * 1.0f / e.Bitmaps[0].Height) * imgHeight + 0.5);
  945. //int splitWidth = 20;
  946. //int pnlWidth = this.pnlBmpList.Height;
  947. //int index = (int)this.gboxDefectList.Tag;
  948. int len = e.Info.Count();
  949. int range = 100;
  950. int uselen = len > 100 ? 100 : len;
  951. for (int x = 0; x < uselen / range + 1; x++)
  952. {
  953. for (int i = 0; i < (x < (uselen / range) ? range : uselen % range); i++)
  954. {
  955. foreach (var item in e.Info[(x * range + i)]) //单个info[x] = {"1":[["92.7542","80.85799","99.54083","86.05363","dk","0.52"]]}
  956. {
  957. //统计缺陷类型
  958. SysMgr.Instance.countDefectClass(item.Value);//[["92.7542","80.85799","99.54083","86.05363","dk","0.52"]]
  959. //
  960. PictureBox picbox = new PictureBox();
  961. picbox.Width = imgWidth;
  962. picbox.Height = imgHeight;
  963. picbox.Image = (Bitmap)e.Bitmaps[(x * range + i)].Clone();
  964. picbox.Name = "imgDefect_" + index;
  965. picbox.Tag = item.Key + "," + e.X + "," + e.Y;
  966. picbox.Click += new EventHandler(defectBmpBox_Click);
  967. picbox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  968. picbox.BorderStyle = BorderStyle.FixedSingle;
  969. //picbox.Margin = new Padding((pnlWidth - picbox.Height) / 2, splitWidth, 0, 0);
  970. picbox.Margin = new Padding((pnlWidth - picbox.Width) / 2, splitWidth, 0, 0);
  971. picbox.MouseHover += simpleTip_MouseHover;
  972. picbox.Visible = true;
  973. //this.Invoke(new MethodInvoker(() =>
  974. // {
  975. this.pnlBmpList.Controls.Add(picbox);
  976. //this.Refresh();
  977. //this.dgvProcess.Refresh();
  978. //this.lstLog.Refresh();
  979. //this.statusStrip1.Refresh();
  980. // }));
  981. break;
  982. }
  983. //
  984. index++;
  985. //Thread.Sleep(10);
  986. //Application.DoEvents();
  987. }
  988. //Application.DoEvents();
  989. //this.Invoke(new MethodInvoker(() =>
  990. //{
  991. //this.Refresh();
  992. pnlBmpList.VerticalScroll.Value = pnlBmpList.VerticalScroll.Maximum;
  993. //}));
  994. //Thread.Sleep(10);
  995. }
  996. //this.Invoke(new MethodInvoker(() =>
  997. //{
  998. //this.gboxDefectList.Tag = len + (int)this.gboxDefectList.Tag;
  999. this.gboxDefectList.Tag = index;
  1000. this.gboxDefectList.Text = $"缺陷图像:{index} 张";
  1001. }
  1002. //}));
  1003. //return 0;
  1004. // });
  1005. // tt.Start();
  1006. // await tt;
  1007. }
  1008. }
  1009. /// <summary>
  1010. /// 尺寸小图多图显示
  1011. /// </summary>
  1012. /// <param name="sender"></param>
  1013. /// <param name="e"></param>
  1014. private void auto_SizeShowMoreImg(object sender, ImgEventArgs e)
  1015. {
  1016. SizeShowImgEvent(e);
  1017. }
  1018. private delegate void SizeShowImgEventDelegate(ImgEventArgs e);
  1019. private void SizeShowImgEvent(ImgEventArgs e)
  1020. {
  1021. if (InvokeRequired)
  1022. {
  1023. SizeShowImgEventDelegate smd = new SizeShowImgEventDelegate(SizeShowImgEvent);
  1024. this.BeginInvoke(smd, e);
  1025. }
  1026. else
  1027. {
  1028. //Task<int> tt = new Task<int>(() =>
  1029. //{
  1030. //lock (AddPicLock)
  1031. //加载缺陷小图
  1032. //纵向显示
  1033. int imgWidth = this.pnlSizeBmpList.ClientSize.Width - 50;
  1034. int imgHeight = (int)((e.Bitmaps[0].Height * 1.0f / e.Bitmaps[0].Width) * imgWidth + 0.5);
  1035. int splitWidth = 20;
  1036. int pnlWidth = this.pnlSizeBmpList.ClientSize.Width;
  1037. int index = (int)this.gboxSizeDefectList.Tag;
  1038. //
  1039. PictureBox picbox = new PictureBox();
  1040. picbox.Width = imgWidth;
  1041. picbox.Height = imgHeight;
  1042. picbox.Image = (Bitmap)e.Bitmaps[0].Clone();
  1043. picbox.Name = "imgSize_" + index;
  1044. picbox.Tag = index + "," + e.X + "," + e.Y;
  1045. picbox.Click += new EventHandler(defectBmpBox2_Click);
  1046. picbox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  1047. picbox.BorderStyle = BorderStyle.FixedSingle;
  1048. //picbox.Margin = new Padding((pnlWidth - picbox.Height) / 2, splitWidth, 0, 0);
  1049. picbox.Margin = new Padding((pnlWidth - picbox.Width) / 2, splitWidth, 0, 0);
  1050. picbox.MouseHover += simpleTip_MouseHover;
  1051. picbox.Visible = true;
  1052. this.pnlSizeBmpList.Controls.Add(picbox);
  1053. index++;
  1054. pnlSizeBmpList.VerticalScroll.Value = pnlSizeBmpList.VerticalScroll.Maximum;
  1055. this.gboxSizeDefectList.Tag = index;
  1056. this.gboxSizeDefectList.Text = $"尺寸图像:{index} 张";
  1057. }
  1058. }
  1059. #endregion
  1060. #region 工具栏
  1061. private void tsbtnImpStop_Click(object sender, EventArgs e)
  1062. {
  1063. SysMgr.Instance.LedPause();
  1064. AddTextEvent("急停", "手动急停", WarningEnum.High);
  1065. this.tsbtnStart.Enabled = false;
  1066. this.tsbtnReset.Enabled = false;
  1067. SysMgr.Instance.StatusMgr.GotoWarning( WarningEnum.High, "急停", "手动急停");
  1068. SysMgr.Instance.SendStatus();
  1069. SysMgr.Instance.EmergencyStop();
  1070. }
  1071. private void tsbOpenLight_Click(object sender, EventArgs e)
  1072. {
  1073. if (this.tsbOpenLight.Text == "开灯")
  1074. {
  1075. SysMgr.Instance.OpenFloodlight(true);
  1076. this.tsbOpenLight.Text = "关灯";
  1077. }
  1078. else
  1079. {
  1080. SysMgr.Instance.OpenFloodlight(false);
  1081. this.tsbOpenLight.Text = "开灯";
  1082. }
  1083. }
  1084. private void tsbtnStart_Click(object sender, EventArgs e)
  1085. {
  1086. if (!SysMgr.Instance.IsRuning)
  1087. {
  1088. //低报警自动复位
  1089. if(SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Warning)
  1090. {
  1091. if (SysMgr.Instance.StatusMgr.Warning == WarningEnum.Low)
  1092. {
  1093. SysMgr.Instance.StatusMgr.ClearWarning();
  1094. SysMgr.Instance.StatusMgr.GotoNormalStandby();
  1095. }
  1096. }
  1097. //提示正在报警中
  1098. if (SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Warning)
  1099. {
  1100. FrmDialog.ShowDialog(this, "系统报警中!无法启动运行!", "警告", false);
  1101. return;
  1102. }
  1103. this.Cursor = Cursors.WaitCursor;
  1104. //System.Windows.Forms.Application.DoEvents();
  1105. if (SysMgr.Instance.StatusMgr.Status != SystemStsEnum.Pause)
  1106. {
  1107. ResetUI(false);
  1108. AddTextEvent("运行", $"启动自动检测流程");
  1109. this.lstLog.Refresh();
  1110. if (SysMgr.Instance.StartRun(this, this.cbOrderCode.Text, (int)this.numDefectCnt.Value, this.cbProductCode.Text, this.cbProductSN.Text))
  1111. {
  1112. this.tsbtnStop.Enabled = true;
  1113. this.tsbtnStart.Enabled = false;
  1114. //锁定信息
  1115. this.cbOrderCode.Enabled = false;
  1116. this.cbProductCode.Enabled = false;
  1117. this.cbProductSN.Enabled = false;
  1118. //记录开始运行时间
  1119. RunStartTime.Restart();
  1120. }
  1121. }
  1122. else //暂停状态开始
  1123. {
  1124. if (SysMgr.Instance.ReStartRun())
  1125. {
  1126. this.tsbtnStop.Enabled = true;
  1127. this.tsbtnStart.Enabled = false;
  1128. }
  1129. }
  1130. this.Cursor = Cursors.Default;
  1131. }
  1132. }
  1133. private void tsbtnStop_Click(object sender, EventArgs e)
  1134. {
  1135. AddTextEvent("暂停", "手动暂停");
  1136. this.tsbtnStart.Enabled = true;
  1137. SysMgr.Instance.StatusMgr.GotoPause();
  1138. SysMgr.Instance.SendStatus();
  1139. SysMgr.Instance.LedPause();
  1140. //this.tsbtnStart.Enabled = true;
  1141. }
  1142. private void tsbtnReset_Click(object sender, EventArgs e)
  1143. {
  1144. if (SystemIsRun())
  1145. {
  1146. DialogResult dr = DialogResult.Cancel;
  1147. dr = FrmDialog.ShowDialog(this, "确定要复位当前系统?", "警告", true);
  1148. if (dr == DialogResult.OK)
  1149. {
  1150. this.Cursor = Cursors.WaitCursor;
  1151. this.tsbtnStart.Enabled = false;
  1152. //this.tsbtnStop.Enabled = false;
  1153. //Task.Factory.StartNew(() =>
  1154. //{
  1155. SysMgr.Instance.LedRset(true);
  1156. SysMgr.Instance.GotoReadyPosAndIO();
  1157. SysMgr.Instance.LedRset(false);
  1158. this.tsbtnStart.Enabled = true;
  1159. this.tsbtnStop.Enabled = false;
  1160. //});
  1161. this.Cursor = Cursors.Default;
  1162. ResetUI(true);
  1163. //AddTextEvent("复位", "复位完成");
  1164. }
  1165. }
  1166. }
  1167. private void tsbtnWarning_Click(object sender, EventArgs e)
  1168. {
  1169. if(SysMgr.Instance.StatusMgr.Warning != WarningEnum.Normal)
  1170. {
  1171. AddTextEvent("清除", "手动清除报警");
  1172. SysMgr.Instance.StatusMgr.ClearWarning();
  1173. SysMgr.Instance.LedReady();
  1174. if (SysMgr.Instance.IsAuto)
  1175. SysMgr.Instance.StatusMgr.GotoPause();
  1176. else
  1177. SysMgr.Instance.StatusMgr.GotoNormalStandby();
  1178. SysMgr.Instance.SendStatus();
  1179. }
  1180. }
  1181. private void tsbGoHome_Click(object sender, EventArgs e)
  1182. {
  1183. if (SystemIsRun())
  1184. {
  1185. DialogResult dr = DialogResult.Cancel;
  1186. dr = FrmDialog.ShowDialog(this, "确定要复位当前系统所有硬件位置?", "警告", true);
  1187. if (dr == DialogResult.OK)
  1188. {
  1189. this.tsbtnStart.Enabled = false;
  1190. this.tsbtnReset.Enabled = false;
  1191. this.tsbtnStop.Enabled = false;
  1192. this.Cursor = Cursors.WaitCursor;
  1193. System.Windows.Forms.Application.DoEvents();
  1194. //Task.Factory.StartNew(() =>
  1195. //{
  1196. SysMgr.Instance.LedRset(true);
  1197. SysMgr.Instance.AllResetAndGoHome();
  1198. SysMgr.Instance.LedRset(false);
  1199. this.tsbtnStart.Enabled = true;
  1200. this.tsbtnReset.Enabled = true;
  1201. this.tsbtnStop.Enabled = false;
  1202. //});
  1203. this.Cursor = Cursors.Default;
  1204. }
  1205. }
  1206. }
  1207. //缺陷+比对与图纸查看
  1208. private void tsbtnDefectImage_Click(object sender, EventArgs e)
  1209. {
  1210. try
  1211. {
  1212. string gbxBmpPath = "";
  1213. Order temp_order = null;
  1214. if (SysMgr.Instance.GetDefectDistribution(out gbxBmpPath, out temp_order))
  1215. {
  1216. //
  1217. ToolStripButton btn = sender as ToolStripButton;
  1218. DefectImageShowFrm frm = new DefectImageShowFrm(gbxBmpPath , temp_order, string.IsNullOrEmpty(btn.Tag.ToString()) ? 0 : Convert.ToInt32(btn.Tag.ToString()));
  1219. frm.Show();
  1220. }
  1221. }
  1222. catch (Exception ex)
  1223. {
  1224. MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
  1225. }
  1226. }
  1227. #endregion
  1228. #region 小图操作
  1229. private void defectBmpBox_Click(object sender, EventArgs e)
  1230. {
  1231. PictureBox picbox = sender as PictureBox;
  1232. if (SysMgr.Instance.IsAuto || SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Auto)//检测中
  1233. {
  1234. //只查看
  1235. AddTextEvent("查看", $"运行中查看缺陷{SysMgr.Instance.IsAuto} - {SysMgr.Instance.StatusMgr.Status}");
  1236. ImageShowFrm frm = new ImageShowFrm(this.pnlBmpList.Controls, Convert.ToInt32(picbox.Name.Split(new char[] { '_' })[1]));
  1237. frm.ShowDialog(this);
  1238. }
  1239. else//完成
  1240. {
  1241. AddTextEvent("查看", $"查看缺陷{ConfMgr.Instance.SysConfigParams.OpenDefectSanp}");
  1242. ImageShowFrm frm = new ImageShowFrm(this.pnlBmpList.Controls,
  1243. Convert.ToInt32(picbox.Name.Split(new char[] { '_' })[1]), ConfMgr.Instance.SysConfigParams.OpenDefectSanp);
  1244. frm.ShowDialog(this);
  1245. }
  1246. }
  1247. private void defectBmpBox2_Click(object sender, EventArgs e)
  1248. {
  1249. PictureBox picbox = sender as PictureBox;
  1250. if (SysMgr.Instance.IsAuto || SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Auto)//检测中
  1251. {
  1252. //只查看
  1253. AddTextEvent("查看", $"运行中查看缺陷{SysMgr.Instance.IsAuto} - {SysMgr.Instance.StatusMgr.Status}");
  1254. ImageShowFrm frm = new ImageShowFrm(this.pnlSizeBmpList.Controls, Convert.ToInt32(picbox.Name.Split(new char[] { '_' })[1]));
  1255. frm.ShowDialog(this);
  1256. }
  1257. else//完成
  1258. {
  1259. AddTextEvent("查看", $"查看缺陷{ConfMgr.Instance.SysConfigParams.OpenDefectSanp}");
  1260. ImageShowFrm frm = new ImageShowFrm(this.pnlSizeBmpList.Controls,
  1261. Convert.ToInt32(picbox.Name.Split(new char[] { '_' })[1]));
  1262. frm.ShowDialog(this);
  1263. }
  1264. }
  1265. private void simpleTip_MouseHover(object sender, EventArgs e)
  1266. {
  1267. PictureBox pb = sender as PictureBox;
  1268. // 创建the ToolTip
  1269. ToolTip toolTip1 = new ToolTip();
  1270. // 设置显示样式
  1271. toolTip1.AutoPopDelay = 5000;//提示信息的可见时间
  1272. toolTip1.InitialDelay = 500;//事件触发多久后出现提示
  1273. toolTip1.ReshowDelay = 500;//指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框
  1274. toolTip1.ShowAlways = true;//是否显示提示框
  1275. // 设置伴随的对象.
  1276. toolTip1.SetToolTip(pb, pb.Name + "[" +pb.Tag.ToString() + "]");//设置提示按钮和提示内容
  1277. }
  1278. #endregion
  1279. #region 时钟捕获
  1280. GetPN pn = new GetPN();
  1281. private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  1282. {
  1283. while (backgroundWorkerDo)
  1284. {
  1285. try
  1286. {
  1287. this.Invoke(new MethodInvoker(() =>
  1288. {
  1289. this.tsslLoginTime.Text = $" 当前时间:{DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss")}";
  1290. }));
  1291. //检测按钮和实时状态
  1292. if (SysMgr.Instance.IsInit)
  1293. {
  1294. bool sts = SysMgr.Instance.WarningShowLed(DisEnableBuzz);
  1295. if (sts)
  1296. {
  1297. this.Invoke(new MethodInvoker(() =>
  1298. {
  1299. this.tsbtnStart.Enabled = true;
  1300. this.tsbtnStop.Enabled = false;
  1301. }));
  1302. }
  1303. int stsno = 0;
  1304. stsno = SysMgr.Instance.ButtonIOTrg(DisEnableDoor);
  1305. if (stsno == 1)
  1306. {
  1307. this.Invoke(new MethodInvoker(() =>
  1308. {
  1309. tsbtnStart_Click(null, null);
  1310. }));
  1311. }
  1312. else if (stsno == 2)
  1313. {
  1314. this.Invoke(new MethodInvoker(() =>
  1315. {
  1316. this.tsbtnStart.Enabled = true;
  1317. }));
  1318. SysMgr.Instance.LedPause();
  1319. }
  1320. else if (stsno == 3)
  1321. {
  1322. this.Invoke(new MethodInvoker(() =>
  1323. {
  1324. tsbtnReset_Click(null, null);
  1325. }));
  1326. }
  1327. else if (stsno == 4) //老流程张力读取
  1328. {
  1329. TensionResult tensionResult;
  1330. if (SysMgr.Instance.TensionGetValue(out tensionResult) >= 0)
  1331. {
  1332. this.Invoke(new MethodInvoker(() =>
  1333. {
  1334. this.lblTension.Text = Math.Round(tensionResult.value, 2).ToString();
  1335. this.lblTension.ForeColor = tensionResult.color;
  1336. this.lblTensionMax.Text = Math.Round(tensionResult.valueMax, 2).ToString();
  1337. this.lblTensionMax.ForeColor = tensionResult.colorMax;
  1338. this.lblTensionMin.Text = Math.Round(tensionResult.valueMin, 2).ToString();
  1339. this.lblTensionMin.ForeColor = tensionResult.colorMin;
  1340. }));
  1341. }
  1342. }
  1343. else if (stsno == 5) //新流程张力读取
  1344. {
  1345. //this.Invoke(new MethodInvoker(() =>
  1346. //{
  1347. // tsbtnReset_Click(null, null);
  1348. //}));
  1349. }
  1350. //显示实际位置
  1351. this.Invoke(new MethodInvoker(() =>
  1352. {
  1353. tsAxisState.Text = SysMgr.Instance.GetAxisPos();
  1354. }));
  1355. }
  1356. if (pn.P(SysMgr.Instance.IsRuning))
  1357. {
  1358. //继续计时
  1359. RunStartTime.Start();
  1360. }
  1361. if (pn.N(SysMgr.Instance.IsRuning))
  1362. {
  1363. //停止计时
  1364. RunStartTime.Stop();
  1365. }
  1366. if (SysMgr.Instance.IsRuning)
  1367. {
  1368. //实时显示
  1369. RunStartTime.Stop();
  1370. this.Invoke(new MethodInvoker(() =>
  1371. {
  1372. tslabelTime.Text = "实时测试:" + ((double)RunStartTime.ElapsedMilliseconds / 1000.0).ToString("0.000") + "s";
  1373. //this.Refresh();
  1374. }));
  1375. RunStartTime.Start();
  1376. }
  1377. this.Invoke(new MethodInvoker(() =>
  1378. {
  1379. tslbSaveSts.Text = $"保存队列:{SysMgr.Instance.GetSaveQueueCnt()}";
  1380. //this.Refresh();
  1381. }));
  1382. Thread.Sleep(100);
  1383. Application.DoEvents();
  1384. }
  1385. catch (Exception ex){
  1386. AddTextEvent("后台", $"出错-{ex.Message}", WarningEnum.Low);
  1387. }
  1388. }
  1389. }
  1390. /// <summary>
  1391. /// 信号上升沿下降沿捕获
  1392. /// </summary>
  1393. class GetPN
  1394. {
  1395. bool _P = false;
  1396. bool _N = false;
  1397. /// <summary>
  1398. /// 判断上升沿
  1399. /// </summary>
  1400. /// <param name="Value"></param>
  1401. /// <returns></returns>
  1402. public bool P(bool Value)
  1403. {
  1404. if (Value && !_P)
  1405. {
  1406. _P = true;
  1407. return true;
  1408. }
  1409. if (!Value)
  1410. _P = false;
  1411. return false;
  1412. }
  1413. /// <summary>
  1414. /// 判断下降沿
  1415. /// </summary>
  1416. /// <param name="Value"></param>
  1417. /// <returns></returns>
  1418. public bool N(bool Value)
  1419. {
  1420. if (!Value && _N)
  1421. {
  1422. _N = false;
  1423. return true;
  1424. }
  1425. if (Value)
  1426. _N = true;
  1427. return false;
  1428. }
  1429. }
  1430. #endregion
  1431. #region 料号和产品编码选择
  1432. private void txtProductCode_DoubleClick(object sender, EventArgs e)
  1433. {
  1434. try
  1435. {
  1436. string pdtName = SysMgr.Instance.SelectProduct();
  1437. if (!string.IsNullOrWhiteSpace(pdtName))
  1438. this.cbProductCode.Text = pdtName;
  1439. }
  1440. catch { }
  1441. }
  1442. private void txtProductCode_TextChanged(object sender, EventArgs e)
  1443. {
  1444. }
  1445. private void txtProductSN_DoubleClick(object sender, EventArgs e)
  1446. {
  1447. InputFrm frm = new InputFrm(null, "请输入网版编码:");
  1448. if (frm.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(frm.inputData))
  1449. {
  1450. this.cbProductSN.Text = frm.inputData;
  1451. }
  1452. else
  1453. {
  1454. this.cbProductSN.Text = "";
  1455. }
  1456. }
  1457. private string[] pdtlistData;
  1458. private string[] snlistData;
  1459. private void LoadPdtList(List<string> list)
  1460. {
  1461. try
  1462. {
  1463. this.cbProductCode.Items.Clear();
  1464. this.pdtlistData = list.ToArray();
  1465. cbProductCode.Items.AddRange(pdtlistData);//比使用DataSource速度要快一些
  1466. cbProductCode.TextUpdate += cobList_TextUpdate;//重新绑定事件
  1467. cbProductCode.KeyDown += CobList_KeyDown;
  1468. this.cbProductCode.Text = "";
  1469. cbProductCode.Focus();
  1470. cbProductCode.SelectAll();
  1471. }catch { }
  1472. }
  1473. private void LoadSNList(List<string> list)
  1474. {
  1475. this.cbProductSN.Items.Clear();
  1476. this.snlistData = list.ToArray();
  1477. cbProductSN.Items.AddRange(snlistData);//比使用DataSource速度要快一些
  1478. //cbProductSN.TextUpdate += cobList_TextUpdate;//重新绑定事件
  1479. cbProductSN.KeyDown += CobList_KeyDown;
  1480. this.cbProductSN.Text = "";
  1481. cbProductSN.Focus();
  1482. cbProductSN.SelectAll();
  1483. }
  1484. private void CobList_KeyDown(object sender, KeyEventArgs e)
  1485. {
  1486. try
  1487. {
  1488. ComboBox ctrl = sender as ComboBox;
  1489. if (e.KeyCode == Keys.Enter)
  1490. {
  1491. if (ctrl.Items.Count == 1)
  1492. ctrl.Text = ctrl.Items[0].ToString();
  1493. }
  1494. }
  1495. catch { }
  1496. }
  1497. private void cobList_TextUpdate(object sender, EventArgs e)
  1498. {
  1499. try
  1500. {
  1501. ComboBox ctrl = sender as ComboBox;
  1502. ctrl.AutoCompleteMode = AutoCompleteMode.None;
  1503. ctrl.AutoCompleteSource = AutoCompleteSource.None;
  1504. if (ctrl.Text != null)
  1505. {
  1506. string str = ctrl.Text; //获取cb_material控件输入内
  1507. //清空combobox
  1508. ctrl.DataSource = null;
  1509. ctrl.Items.Clear();
  1510. string[] workOrderFiltered;
  1511. if (ctrl.Name == "cbProductCode")
  1512. workOrderFiltered = pdtlistData.Where(x => x.IndexOf(str, StringComparison.CurrentCultureIgnoreCase) != -1).ToArray();//忽略大小写
  1513. else
  1514. workOrderFiltered = snlistData.Where(x => x.IndexOf(str, StringComparison.CurrentCultureIgnoreCase) != -1).ToArray();//忽略大小写
  1515. ctrl.Items.AddRange(workOrderFiltered);//比使用DataSource速度要快一些
  1516. // 不存在符合条件时
  1517. //设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
  1518. ctrl.SelectedIndex = -1;
  1519. //ctrl.SelectionStart = str.Length; // 设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
  1520. if (workOrderFiltered.Length > 0)
  1521. {
  1522. if (!ctrl.DroppedDown)
  1523. {
  1524. ctrl.DroppedDown = true; // 自动弹出下拉框
  1525. ctrl.SelectedText = str;
  1526. }
  1527. }
  1528. ctrl.Cursor = Cursors.Default; //保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置
  1529. ctrl.SelectionStart = str.Length; // 设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
  1530. }
  1531. }
  1532. catch { }
  1533. }
  1534. #endregion
  1535. #region 界面变化
  1536. private void MainFrm_SizeChanged(object sender, EventArgs e)
  1537. {
  1538. if (this.WindowState == FormWindowState.Maximized)
  1539. {
  1540. this.WindowState = FormWindowState.Normal;
  1541. this.Top = 0;
  1542. this.Left = 0;
  1543. this.Width = SystemInformation.WorkingArea.Width;
  1544. this.Height = SystemInformation.WorkingArea.Height;
  1545. }
  1546. }
  1547. private void tsmSysUserMgr_Click(object sender, EventArgs e)
  1548. {
  1549. }
  1550. private void tabPage1_Resize(object sender, EventArgs e)
  1551. {
  1552. int allWidth = this.tabPage1.Width;
  1553. this.flpnlResultData.Width = allWidth;
  1554. kanban1.Width = kanban2.Width = kanban3.Width = kanban4.Width = kanban5.Width = kanban6.Width = (flpnlResultData.Width - 30) / 6;
  1555. tabControl1.Region = new Region(new RectangleF(this.tabPage1.Left, this.tabPage1.Top, this.tabPage1.Width, this.tabPage1.Height));
  1556. }
  1557. private void tabPage2_Resize(object sender, EventArgs e)
  1558. {
  1559. int allWidth = this.tabPage2.Width;
  1560. tabControl1.Region = new Region(new RectangleF(this.tabPage2.Left, this.tabPage2.Top, this.tabPage2.Width, this.tabPage2.Height));
  1561. }
  1562. private void MainFrm_Paint(object sender, PaintEventArgs e)
  1563. {
  1564. this.tsbtnReset.Visible = ConfMgr.Instance.SysConfigParams.ShowResetBtn;
  1565. this.chkBuzzer.Visible = ConfMgr.Instance.SysConfigParams.ShowBuzz;
  1566. this.chkDoorSensor.Visible = ConfMgr.Instance.SysConfigParams.ShowDoorAlm;
  1567. this.tsbtnDefectImage.Visible = ConfMgr.Instance.SysConfigParams.ShowDistribution;
  1568. this.tsbtnSizeImage.Visible = ConfMgr.Instance.SysConfigParams.ShowDistribution;
  1569. toolStripSeparator7.Visible = ConfMgr.Instance.SysConfigParams.ShowDistribution;
  1570. this.tsbCC.Visible = ConfMgr.Instance.SysConfigParams.ShowSizeBtn;
  1571. this.tsbQX.Visible = ConfMgr.Instance.SysConfigParams.ShowDefectBtn;
  1572. toolStripSeparator8.Visible = ConfMgr.Instance.SysConfigParams.ShowSizeBtn || ConfMgr.Instance.SysConfigParams.ShowDefectBtn;
  1573. }
  1574. private void flpProcessStep_SizeChanged(object sender, EventArgs e)
  1575. {
  1576. int splitWidth = 5;
  1577. foreach (Control item in this.flpProcessStep.Controls)
  1578. {
  1579. item.Width = flpProcessStep.Width - splitWidth * 2 - 30;
  1580. }
  1581. this.flpProcessStep.Refresh();
  1582. this.gpbProcessList.Refresh();
  1583. }
  1584. private void cbProductSN_MouseDoubleClick(object sender, MouseEventArgs e)
  1585. {
  1586. this.cbProductSN.Text = "";
  1587. this.cbProductSN.Select();
  1588. }
  1589. #endregion
  1590. private void lblCompareResult_Click(object sender, EventArgs e)
  1591. {
  1592. if (SysMgr.Instance.lstCompareFailZoomImage.Count < 1) return;
  1593. PhotoFrm frm = new PhotoFrm(SysMgr.Instance.lstCompareFailZoomImage);
  1594. frm.ShowDialog();
  1595. }
  1596. #region 演示功能
  1597. private void tsbtnYanShi_Click(object sender, EventArgs e)
  1598. {
  1599. if (this.tsbtnYanShi.Text == "演示开启")
  1600. {
  1601. this.tsbtnYanShi.Text = "演示关闭";
  1602. this.tsbtnYanShi.Image = Resources.交互演示动画__1_;
  1603. SysMgr.Instance.SetYanShiEnable(false);
  1604. }
  1605. else
  1606. {
  1607. this.tsbtnYanShi.Text = "演示开启";
  1608. this.tsbtnYanShi.Image = Resources.交互演示动画;
  1609. SysMgr.Instance.SetYanShiEnable(true);
  1610. }
  1611. }
  1612. #endregion
  1613. }
  1614. }