版博士V2.0程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

1810 rindas
77 KiB

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