MeasureMsgManage.cs 6.0 KB

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