MeasureMsgManage.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. if (formHOZ.IsClose)
  37. {
  38. formHOZ.Close();
  39. }
  40. }
  41. break;
  42. }
  43. #endregion
  44. //是否当前编号是流程中有数据的节点
  45. if (IsCutHolePhotoInfo(formHOZ, args))
  46. {
  47. if (!args.Picture_Information.Picture_FullPath.Equals(""))
  48. {
  49. //显示状态信息
  50. ShowStateMessage(formHOZ, args);
  51. //设置图像
  52. FileStream fileStream = new FileStream(args.Picture_Information.Picture_FullPath, FileMode.Open, FileAccess.Read);
  53. formHOZ.pbImage.Image = Image.FromStream(fileStream);
  54. fileStream.Close();
  55. fileStream.Dispose();
  56. //流程内容
  57. string semParaContent = "电压:" + args.Picture_Information.Work_Voltage;
  58. semParaContent += " 放大倍数:" + args.Picture_Information.Magnification;
  59. semParaContent += " 工作距离:" + args.Picture_Information.Work_Distance;
  60. formHOZ.lblFlowContent.Text = semParaContent;
  61. }
  62. }
  63. //修改切孔中流程状态
  64. ChageCutHoleFlowNodeState(formHOZ, args);
  65. }
  66. /// <summary>
  67. /// 显示状态信息
  68. /// </summary>
  69. /// <param name="formHOZ"></param>
  70. /// <param name="args"></param>
  71. private static void ShowStateMessage(FormHOZMain formHOZ,ThreadStatusEventArgs args)
  72. {
  73. //显示状态信息
  74. if (args.Step_Code == "1-2")
  75. {
  76. formHOZ.lblStateMessage.Text = "正在对焦中...请等待";
  77. }
  78. else
  79. {
  80. formHOZ.lblStateMessage.Text = "";
  81. }
  82. }
  83. #region 显示切孔流程中拍照信息
  84. /// <summary>
  85. /// 是否当前编号是流程中有数据的节点
  86. /// </summary>
  87. /// <param name="formHOZ">主窗体对象</param>
  88. /// <param name="args">线程参数</param>
  89. /// <returns></returns>
  90. public static bool IsCutHolePhotoInfo(FormHOZMain formHOZ, ThreadStatusEventArgs args)
  91. {
  92. if (formHOZ.plPrarInfo.Controls.Count > 0)
  93. {
  94. foreach (Control item in formHOZ.plPrarInfo.Controls)
  95. {
  96. if (item is UserControl)
  97. {
  98. if (item.Name == args.HoleName)
  99. {
  100. UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
  101. TimeLineItem[] ParaItem = uControl_ParaInfo.TlItem;
  102. foreach (TimeLineItem tlItem in ParaItem)
  103. {
  104. if (tlItem.Code == args.Step_Code && tlItem.IsData)
  105. {
  106. return true;
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. #endregion
  116. #region 修改切孔中流程状态
  117. /// <summary>
  118. /// 修改切孔中流程状态
  119. /// </summary>
  120. /// <param name="formHOZ">主窗体对象</param>
  121. /// <param name="cutHoleName">切孔名称</param>
  122. /// <param name="Code">流程编号</param>
  123. /// <param name="state">状态</param>
  124. /// <returns></returns>
  125. public static bool ChageCutHoleFlowNodeState(FormHOZMain formHOZ, ThreadStatusEventArgs args)
  126. {
  127. if (formHOZ.plPrarInfo.Controls.Count > 0)
  128. {
  129. foreach (Control item in formHOZ.plPrarInfo.Controls)
  130. {
  131. if (item is UserControl)
  132. {
  133. if (item.Name == args.HoleName)
  134. {
  135. UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
  136. TimeLineItem[] ParaItem = uControl_ParaInfo.TlItem;
  137. foreach (TimeLineItem tlItem in ParaItem)
  138. {
  139. if (tlItem.Code == args.Step_Code)
  140. {
  141. tlItem.State = args.State?1:0;
  142. break;
  143. }
  144. }
  145. //更新进度条
  146. uControl_ParaInfo.UpdateCurrentMeasureSchedule();
  147. //重新绘制
  148. uControl_ParaInfo.TimeLineInvalidate();
  149. return true;
  150. }
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. #endregion
  157. }
  158. }