MeasureMsgManage.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using MeasureThread;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. namespace HOZProject
  11. {
  12. public class MeasureMsgManage
  13. {
  14. public enum measureType
  15. {
  16. Photo=0,
  17. FIB=1,
  18. PT=2
  19. }
  20. /// <summary>
  21. /// 线程消息处理,显示内容
  22. /// </summary>
  23. /// <param name="formHOZ">主窗体对象</param>
  24. /// <param name="args">消息对象</param>
  25. public static void ShowMsgContent(FormHOZMain formHOZ, ThreadStatusEventArgs args)
  26. {
  27. #region 判断线程是否停止
  28. switch (args.Step_Code)
  29. {
  30. case "0-0":
  31. //停止线程
  32. if (formHOZ.m_BackgroundWorker.IsBusy)
  33. {
  34. formHOZ.m_BackgroundWorker.CancelAsync();
  35. }
  36. break;
  37. }
  38. #endregion
  39. if (IsCutHolePhotoInfo(formHOZ, args))
  40. {
  41. //设置图像
  42. FileStream fileStream = new FileStream(args.Picture_Information.Picture_FullPath, FileMode.Open, FileAccess.Read);
  43. formHOZ.pbImage.Image = Image.FromStream(fileStream);
  44. fileStream.Close();
  45. fileStream.Dispose();
  46. //流程内容
  47. string semParaContent = "电压:" + args.Picture_Information.Work_Voltage;
  48. semParaContent += " 放大倍数:" + args.Picture_Information.Magnification;
  49. semParaContent += " 工作距离:" + args.Picture_Information.Work_Distance;
  50. formHOZ.lblFlowContent.Text = semParaContent;
  51. }
  52. //修改切孔中流程状态
  53. ChageCutHoleFlowNodeState(formHOZ, args);
  54. }
  55. #region 显示切孔流程中拍照信息
  56. /// <summary>
  57. /// 是否当前编号是流程中有数据的节点
  58. /// </summary>
  59. /// <param name="formHOZ">主窗体对象</param>
  60. /// <param name="args">线程参数</param>
  61. /// <returns></returns>
  62. public static bool IsCutHolePhotoInfo(FormHOZMain formHOZ, ThreadStatusEventArgs args)
  63. {
  64. if (formHOZ.plPrarInfo.Controls.Count > 0)
  65. {
  66. foreach (Control item in formHOZ.plPrarInfo.Controls)
  67. {
  68. if (item is UserControl)
  69. {
  70. if (item.Name == args.HoleName)
  71. {
  72. UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
  73. TimeLineItem[] ParaItem = uControl_ParaInfo.TlItem;
  74. foreach (TimeLineItem tlItem in ParaItem)
  75. {
  76. if (tlItem.Code == args.Step_Code && tlItem.IsData)
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. #endregion
  88. #region 修改切孔中流程状态
  89. /// <summary>
  90. /// 修改切孔中流程状态
  91. /// </summary>
  92. /// <param name="formHOZ">主窗体对象</param>
  93. /// <param name="cutHoleName">切孔名称</param>
  94. /// <param name="Code">流程编号</param>
  95. /// <param name="state">状态</param>
  96. /// <returns></returns>
  97. public static bool ChageCutHoleFlowNodeState(FormHOZMain formHOZ, ThreadStatusEventArgs args)
  98. {
  99. if (formHOZ.plPrarInfo.Controls.Count > 0)
  100. {
  101. foreach (Control item in formHOZ.plPrarInfo.Controls)
  102. {
  103. if (item is UserControl)
  104. {
  105. if (item.Name == args.HoleName)
  106. {
  107. UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
  108. TimeLineItem[] ParaItem = uControl_ParaInfo.TlItem;
  109. foreach (TimeLineItem tlItem in ParaItem)
  110. {
  111. if (tlItem.Code == args.Step_Code)
  112. {
  113. tlItem.State = args.State?1:0;
  114. break;
  115. }
  116. }
  117. //更新进度条
  118. uControl_ParaInfo.UpdateCurrentMeasureSchedule();
  119. //重新绘制
  120. uControl_ParaInfo.TimeLineInvalidate();
  121. return true;
  122. }
  123. }
  124. }
  125. }
  126. return false;
  127. }
  128. #endregion
  129. }
  130. }