UControl_ParaInfo.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MeasureData;
  11. using FileManager;
  12. using System.Xml;
  13. namespace HOZProject
  14. {
  15. public partial class UControl_ParaInfo : UserControl
  16. {
  17. #region 成员变量
  18. /// <summary>
  19. /// 开始时间
  20. /// </summary>
  21. private string startTime;
  22. /// <summary>
  23. /// 结束时间
  24. /// </summary>
  25. private string endTime;
  26. /// <summary>
  27. /// 状态
  28. /// </summary>
  29. private int state;
  30. /// <summary>
  31. /// 位置
  32. /// </summary>
  33. private SemPosition position;
  34. private bool isSwitch;
  35. private string cutHoleName;
  36. private FormHOZMain formHOZMain;
  37. private TimeLineItem[] tlItem = null;
  38. private UCTimeLine uCTimeLine = null;
  39. public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
  40. public string StartTime { get => startTime; set => startTime = value; }
  41. public string EndTime { get => endTime; set => endTime = value; }
  42. public int State { get => state; set => state = value; }
  43. public SemPosition Position { get => position; set => position = value; }
  44. public string CutHoleName { get => cutHoleName; set => cutHoleName = value; }
  45. public bool IsSwitch { get => isSwitch; set => isSwitch = value; }
  46. public TimeLineItem[] TlItem { get => tlItem; set => tlItem = value; }
  47. #endregion
  48. public UControl_ParaInfo(FormHOZMain formHOZ)
  49. {
  50. InitializeComponent();
  51. FormHOZMainObject = formHOZ;
  52. //显示测量流程
  53. ShowMeasureFlow();
  54. }
  55. #region 显示开始与结束时间
  56. public void ShowTime()
  57. {
  58. lblShowStartTime.Text = startTime;
  59. lblShowEndTime.Text = endTime;
  60. }
  61. #endregion
  62. #region 当前进度
  63. public void UpdateCurrentMeasureSchedule()
  64. {
  65. if (TlItem != null)
  66. {
  67. //完成状态数量
  68. int finishCount = 0;
  69. //未完成状态数量
  70. int unFinishedCount = 0;
  71. foreach (TimeLineItem item in TlItem)
  72. {
  73. if (item.State>0)
  74. {
  75. finishCount++;
  76. }
  77. switch (FormHOZMainObject.m_MeasureType)
  78. {
  79. case (int)MeasureMsgManage.measureType.Photo:
  80. if (item.Type.ToUpper() == "PT" || item.Type.ToUpper() == "FIB")
  81. {
  82. continue;
  83. }
  84. else
  85. {
  86. unFinishedCount++;
  87. }
  88. break;
  89. case (int)MeasureMsgManage.measureType.FIB:
  90. if (item.Type.ToUpper() == "PT")
  91. {
  92. continue;
  93. }
  94. else
  95. {
  96. unFinishedCount++;
  97. }
  98. break;
  99. case (int)MeasureMsgManage.measureType.PT:
  100. unFinishedCount = TlItem.Length;
  101. break;
  102. }
  103. }
  104. try
  105. {
  106. int pbValue = (int)((float)finishCount / (float)unFinishedCount*100);
  107. pbMeasure.Value = pbValue;
  108. lblCompletedAmount.Text = pbValue + "%";
  109. }
  110. catch (Exception)
  111. {
  112. pbMeasure.Value = 0;
  113. }
  114. }
  115. }
  116. #endregion
  117. #region 隐藏属性层
  118. private void btnClose_Click(object sender, EventArgs e)
  119. {
  120. FormHOZMainObject.plPrarInfo.Visible = false;
  121. }
  122. #endregion
  123. #region 重绘时间轴
  124. /// <summary>
  125. /// 重绘时间轴
  126. /// </summary>
  127. public void TimeLineInvalidate()
  128. {
  129. plTimeLine.Invalidate();
  130. uCTimeLine.Invalidate();
  131. }
  132. #endregion
  133. #region 显示切孔参数信息
  134. /// <summary>
  135. /// 显示切孔参数信息
  136. /// </summary>
  137. public void ShowParaInfo()
  138. {
  139. int multiple = 1000;
  140. //设置Position参数
  141. lblX.Text = (Position.X * multiple).ToString("f3");
  142. lblY.Text = (Position.Y * multiple).ToString("f3");
  143. lblZ.Text = (Position.Z * multiple).ToString("f3");
  144. lblR.Text = Position.R.ToString();
  145. lblT.Text = Position.T.ToString();
  146. lblM.Text = Position.M.ToString();
  147. lblShowStartTime.Text = StartTime;
  148. lblShowEndTime.Text = EndTime;
  149. //设置切孔状态
  150. switch (State)
  151. {
  152. //准备
  153. case (int)MeasureThread.ThreadState.Ready:
  154. //修改切孔状态
  155. lblShowState.Text = "准备";
  156. break;
  157. //等待
  158. case (int)MeasureThread.ThreadState.Waiting:
  159. //修改切孔状态
  160. lblShowState.Text = "等待";
  161. break;
  162. //进行中
  163. case (int)MeasureThread.ThreadState.InProcess:
  164. //修改切孔状态
  165. lblShowState.Text = "进行中";
  166. break;
  167. //完成
  168. case (int)MeasureThread.ThreadState.Success:
  169. //修改切孔状态
  170. lblShowState.Text = "完成";
  171. break;
  172. //失败
  173. case (int)MeasureThread.ThreadState.Failed:
  174. lblShowState.Text = "失败";
  175. break;
  176. }
  177. lblCutHoleName.Text = CutHoleName;
  178. CkIsSwitch.Checked = IsSwitch;
  179. }
  180. #endregion
  181. #region 绑定流程信息
  182. /// <summary>
  183. /// 绑定流程信息
  184. /// </summary>
  185. /// <param name="flowCode"></param>
  186. private void ShowMeasureFlow()
  187. {
  188. if (TlItem == null)
  189. {
  190. TlItem = GetMeasureFlowStructInfo();
  191. }
  192. if (TlItem != null)
  193. {
  194. ShowUCTimeLine(TlItem);
  195. }
  196. }
  197. public void ShowUCTimeLine(TimeLineItem[] tlItem)
  198. {
  199. if (plTimeLine.Controls.Count == 0)
  200. {
  201. uCTimeLine = new UCTimeLine(tlItem, FormHOZMainObject.m_MeasureType);
  202. uCTimeLine.Dock = DockStyle.Fill;
  203. plTimeLine.Controls.Add(uCTimeLine);
  204. }
  205. }
  206. private TimeLineItem[] GetMeasureFlowStructInfo()
  207. {
  208. string xmlfullname = Application.StartupPath + @"\MeasureXML\MeasureStructXml.xml";
  209. XmlNodeList nodeList = XmlManager.GetXmlMeasureFlowNodeInfo(xmlfullname);
  210. if (nodeList != null)
  211. {
  212. return XmlConvertTimeListItem(nodeList);
  213. }
  214. return null;
  215. }
  216. private TimeLineItem[] XmlConvertTimeListItem(XmlNodeList nodeList)
  217. {
  218. List<TimeLineItem> timeLineList = new List<TimeLineItem>();
  219. for (int i = 0; i < nodeList.Count; i++)
  220. {
  221. if (Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value))
  222. {
  223. TimeLineItem tlItem = new TimeLineItem();
  224. tlItem.Details = nodeList[i].Attributes["Details"].Value;
  225. tlItem.Code = nodeList[i].Attributes["Code"].Value;
  226. tlItem.State = -1;
  227. tlItem.Title = nodeList[i].Attributes["Title"].Value;
  228. tlItem.IsData = Convert.ToBoolean(nodeList[i].Attributes["IsData"].Value);
  229. tlItem.Type = nodeList[i].Attributes["Type"].Value;
  230. tlItem.IsShow = Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value);
  231. tlItem.Index = Convert.ToInt32(nodeList[i].Attributes["Index"].Value);
  232. timeLineList.Add(tlItem);
  233. }
  234. }
  235. TimeLineItem[] timeLineItem = new TimeLineItem[timeLineList.Count];
  236. //按照Index进行升序
  237. timeLineItem = timeLineList.OrderBy(i => i.Index).ToArray();
  238. //清空时间轴列表
  239. timeLineList.Clear();
  240. return timeLineItem;
  241. }
  242. #endregion
  243. #region 关闭按钮 鼠标操作事件
  244. private void pbClose_MouseEnter(object sender, EventArgs e)
  245. {
  246. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Red;
  247. }
  248. private void pbClose_MouseLeave(object sender, EventArgs e)
  249. {
  250. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
  251. }
  252. #endregion
  253. #region 设置切孔是否检测
  254. private void CkIsSwitch_CheckedChanged(object sender, EventArgs e)
  255. {
  256. //设置切孔是否检测
  257. List<CutHole> cutHoles = formHOZMain.m_MeasureFile.ListCutHole;
  258. foreach (CutHole item in cutHoles)
  259. {
  260. if (item.HoleName == CutHoleName)
  261. {
  262. item.SWITCH = CkIsSwitch.Checked;
  263. //是否已保存
  264. if (formHOZMain.IsSave)
  265. {
  266. //保存测量文件
  267. formHOZMain.m_MeasureFile.Save();
  268. }
  269. break;
  270. }
  271. }
  272. }
  273. #endregion
  274. }
  275. }