UControl_ParaInfo.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. if (StartTime == "0001/1/1 0:00:00")
  59. {
  60. lblShowStartTime.Text = "";
  61. }
  62. else
  63. {
  64. lblShowStartTime.Text = StartTime;
  65. }
  66. if (EndTime == "0001/1/1 0:00:00")
  67. {
  68. lblShowEndTime.Text = "";
  69. }
  70. else
  71. {
  72. lblShowEndTime.Text = EndTime;
  73. }
  74. }
  75. #endregion
  76. #region 当前进度
  77. public void UpdateCurrentMeasureSchedule()
  78. {
  79. if (TlItem != null)
  80. {
  81. //完成状态数量
  82. int finishCount = 0;
  83. //未完成状态数量
  84. int unFinishedCount = 0;
  85. foreach (TimeLineItem item in TlItem)
  86. {
  87. if (item.State>0)
  88. {
  89. finishCount++;
  90. }
  91. switch (FormHOZMainObject.m_MeasureType)
  92. {
  93. case (int)MeasureMsgManage.measureType.Photo:
  94. if (item.Type.ToUpper() == "PT" || item.Type.ToUpper() == "FIB")
  95. {
  96. continue;
  97. }
  98. else
  99. {
  100. unFinishedCount++;
  101. }
  102. break;
  103. case (int)MeasureMsgManage.measureType.FIB:
  104. if (item.Type.ToUpper() == "PT")
  105. {
  106. continue;
  107. }
  108. else
  109. {
  110. unFinishedCount++;
  111. }
  112. break;
  113. case (int)MeasureMsgManage.measureType.PT:
  114. unFinishedCount = TlItem.Length;
  115. break;
  116. }
  117. }
  118. try
  119. {
  120. int pbValue = (int)((float)finishCount / (float)unFinishedCount*100);
  121. pbMeasure.Value = pbValue;
  122. lblCompletedAmount.Text = pbValue + "%";
  123. }
  124. catch (Exception)
  125. {
  126. pbMeasure.Value = 0;
  127. }
  128. }
  129. }
  130. #endregion
  131. #region 隐藏属性层
  132. private void btnClose_Click(object sender, EventArgs e)
  133. {
  134. FormHOZMainObject.plPrarInfo.Visible = false;
  135. }
  136. #endregion
  137. #region 重绘时间轴
  138. /// <summary>
  139. /// 重绘时间轴
  140. /// </summary>
  141. public void TimeLineInvalidate()
  142. {
  143. plTimeLine.Invalidate();
  144. uCTimeLine.Invalidate();
  145. }
  146. #endregion
  147. #region 显示切孔参数信息
  148. /// <summary>
  149. /// 显示切孔参数信息
  150. /// </summary>
  151. public void ShowParaInfo()
  152. {
  153. int multiple = 1000;
  154. //设置Position参数
  155. lblX.Text = (Position.X * multiple).ToString("f2");
  156. lblY.Text = (Position.Y * multiple).ToString("f2");
  157. lblZ.Text = (Position.Z * multiple).ToString("f2");
  158. lblR.Text = Position.R.ToString();
  159. lblT.Text = Position.T.ToString();
  160. lblM.Text = (Position.M * multiple).ToString();
  161. try
  162. {
  163. DateTime dtst = Convert.ToDateTime(StartTime);
  164. if (dtst.Year != System.DateTime.Now.Year)
  165. {
  166. lblShowStartTime.Text = "";
  167. }
  168. else
  169. {
  170. lblShowStartTime.Text = StartTime;
  171. }
  172. }
  173. catch
  174. {
  175. lblShowStartTime.Text = "";
  176. }
  177. try
  178. {
  179. DateTime dtet = Convert.ToDateTime(EndTime);
  180. if (dtet.Year != System.DateTime.Now.Year)
  181. {
  182. lblShowEndTime.Text = "";
  183. }
  184. else
  185. {
  186. lblShowEndTime.Text = EndTime;
  187. }
  188. }
  189. catch
  190. {
  191. lblShowEndTime.Text = "";
  192. }
  193. //设置切孔状态
  194. switch (State)
  195. {
  196. //准备
  197. case (int)MeasureThread.ThreadState.Ready:
  198. //修改切孔状态
  199. lblShowState.Text = "准备";
  200. break;
  201. //等待
  202. case (int)MeasureThread.ThreadState.Waiting:
  203. //修改切孔状态
  204. lblShowState.Text = "等待";
  205. break;
  206. //进行中
  207. case (int)MeasureThread.ThreadState.InProcess:
  208. //修改切孔状态
  209. lblShowState.Text = "进行中";
  210. break;
  211. //完成
  212. case (int)MeasureThread.ThreadState.Success:
  213. //修改切孔状态
  214. lblShowState.Text = "完成";
  215. break;
  216. //失败
  217. case (int)MeasureThread.ThreadState.Failed:
  218. lblShowState.Text = "失败";
  219. break;
  220. }
  221. lblCutHoleName.Text = CutHoleName;
  222. CkIsSwitch.Checked = IsSwitch;
  223. }
  224. #endregion
  225. #region 绑定流程信息
  226. /// <summary>
  227. /// 绑定流程信息
  228. /// </summary>
  229. /// <param name="flowCode"></param>
  230. private void ShowMeasureFlow()
  231. {
  232. if (TlItem == null)
  233. {
  234. TlItem = GetMeasureFlowStructInfo();
  235. }
  236. if (TlItem != null)
  237. {
  238. ShowUCTimeLine(TlItem);
  239. }
  240. }
  241. public void ShowUCTimeLine(TimeLineItem[] tlItem)
  242. {
  243. if (plTimeLine.Controls.Count == 0)
  244. {
  245. uCTimeLine = new UCTimeLine(tlItem, FormHOZMainObject.m_MeasureType);
  246. uCTimeLine.Dock = DockStyle.Fill;
  247. plTimeLine.Controls.Add(uCTimeLine);
  248. }
  249. }
  250. private TimeLineItem[] GetMeasureFlowStructInfo()
  251. {
  252. string xmlfullname = Application.StartupPath + @"\MeasureXML\MeasureStructXml.xml";
  253. XmlNodeList nodeList = XmlManager.GetXmlMeasureFlowNodeInfo(xmlfullname);
  254. if (nodeList != null)
  255. {
  256. return XmlConvertTimeListItem(nodeList);
  257. }
  258. return null;
  259. }
  260. private TimeLineItem[] XmlConvertTimeListItem(XmlNodeList nodeList)
  261. {
  262. List<TimeLineItem> timeLineList = new List<TimeLineItem>();
  263. for (int i = 0; i < nodeList.Count; i++)
  264. {
  265. if (Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value))
  266. {
  267. TimeLineItem tlItem = new TimeLineItem();
  268. tlItem.Details = nodeList[i].Attributes["Details"].Value;
  269. tlItem.Code = nodeList[i].Attributes["Code"].Value;
  270. tlItem.State = -1;
  271. tlItem.Title = nodeList[i].Attributes["Title"].Value;
  272. tlItem.IsData = Convert.ToBoolean(nodeList[i].Attributes["IsData"].Value);
  273. tlItem.Type = nodeList[i].Attributes["Type"].Value;
  274. tlItem.IsShow = Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value);
  275. tlItem.Index = Convert.ToInt32(nodeList[i].Attributes["Index"].Value);
  276. timeLineList.Add(tlItem);
  277. }
  278. }
  279. TimeLineItem[] timeLineItem = new TimeLineItem[timeLineList.Count];
  280. //按照Index进行升序
  281. timeLineItem = timeLineList.OrderBy(i => i.Index).ToArray();
  282. //清空时间轴列表
  283. timeLineList.Clear();
  284. return timeLineItem;
  285. }
  286. #endregion
  287. #region 关闭按钮 鼠标操作事件
  288. private void pbClose_MouseEnter(object sender, EventArgs e)
  289. {
  290. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Red;
  291. }
  292. private void pbClose_MouseLeave(object sender, EventArgs e)
  293. {
  294. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
  295. }
  296. #endregion
  297. #region 设置切孔是否检测
  298. private void CkIsSwitch_CheckedChanged(object sender, EventArgs e)
  299. {
  300. //设置切孔是否检测
  301. List<CutHole> cutHoles = formHOZMain.m_MeasureFile.ListCutHole;
  302. foreach (CutHole item in cutHoles)
  303. {
  304. if (item.HoleName == CutHoleName)
  305. {
  306. item.SWITCH = CkIsSwitch.Checked;
  307. //是否已保存
  308. if (formHOZMain.IsSave)
  309. {
  310. //保存测量文件
  311. formHOZMain.m_MeasureFile.Save();
  312. }
  313. break;
  314. }
  315. }
  316. }
  317. #endregion
  318. }
  319. }