UControl_ParaInfo.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 string 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 string 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 UpdateCurrentMeasureSchedule()
  57. {
  58. if (TlItem != null)
  59. {
  60. //完成状态数量
  61. int finishCount = 0;
  62. //未完成状态数量
  63. int unFinishedCount = 0;
  64. foreach (TimeLineItem item in TlItem)
  65. {
  66. if (item.State>0)
  67. {
  68. finishCount++;
  69. }
  70. switch (FormHOZMainObject.m_MeasureType)
  71. {
  72. case (int)MeasureMsgManage.measureType.Photo:
  73. if (item.Type.ToUpper() == "PT" || item.Type.ToUpper() == "FIB")
  74. {
  75. continue;
  76. }
  77. else
  78. {
  79. unFinishedCount++;
  80. }
  81. break;
  82. case (int)MeasureMsgManage.measureType.FIB:
  83. if (item.Type.ToUpper() == "PT")
  84. {
  85. continue;
  86. }
  87. else
  88. {
  89. unFinishedCount++;
  90. }
  91. break;
  92. case (int)MeasureMsgManage.measureType.PT:
  93. unFinishedCount = TlItem.Length;
  94. break;
  95. }
  96. }
  97. try
  98. {
  99. int pbValue = (int)((float)finishCount / (float)unFinishedCount*100);
  100. pbMeasure.Value = pbValue;
  101. lblCompletedAmount.Text = pbValue + "%";
  102. }
  103. catch (Exception)
  104. {
  105. pbMeasure.Value = 0;
  106. }
  107. }
  108. }
  109. #endregion
  110. #region 隐藏属性层
  111. private void btnClose_Click(object sender, EventArgs e)
  112. {
  113. FormHOZMainObject.plPrarInfo.Visible = false;
  114. }
  115. #endregion
  116. #region 重绘时间轴
  117. /// <summary>
  118. /// 重绘时间轴
  119. /// </summary>
  120. public void TimeLineInvalidate()
  121. {
  122. plTimeLine.Invalidate();
  123. uCTimeLine.Invalidate();
  124. }
  125. #endregion
  126. #region 显示切孔参数信息
  127. /// <summary>
  128. /// 显示切孔参数信息
  129. /// </summary>
  130. public void ShowParaInfo()
  131. {
  132. int multiple = 1000;
  133. //设置Position参数
  134. lblX.Text = (Position.X * multiple).ToString("f3");
  135. lblY.Text = (Position.Y * multiple).ToString("f3");
  136. lblZ.Text = (Position.Z * multiple).ToString("f3");
  137. lblR.Text = Position.R.ToString();
  138. lblT.Text = Position.T.ToString();
  139. lblM.Text = Position.M.ToString();
  140. lblShowStartTime.Text = StartTime;
  141. lblShowEndTime.Text = EndTime;
  142. lblShowState.Text = State;
  143. lblCutHoleName.Text = CutHoleName;
  144. CkIsSwitch.Checked = IsSwitch;
  145. }
  146. #endregion
  147. #region 绑定流程信息
  148. /// <summary>
  149. /// 绑定流程信息
  150. /// </summary>
  151. /// <param name="flowCode"></param>
  152. private void ShowMeasureFlow()
  153. {
  154. if (TlItem == null)
  155. {
  156. TlItem = GetMeasureFlowStructInfo();
  157. }
  158. if (TlItem != null)
  159. {
  160. ShowUCTimeLine(TlItem);
  161. }
  162. }
  163. public void ShowUCTimeLine(TimeLineItem[] tlItem)
  164. {
  165. if (plTimeLine.Controls.Count == 0)
  166. {
  167. uCTimeLine = new UCTimeLine(tlItem, FormHOZMainObject.m_MeasureType);
  168. uCTimeLine.Dock = DockStyle.Fill;
  169. plTimeLine.Controls.Add(uCTimeLine);
  170. }
  171. }
  172. private TimeLineItem[] GetMeasureFlowStructInfo()
  173. {
  174. string xmlfullname = Application.StartupPath + @"\MeasureXML\MeasureStructXml.xml";
  175. XmlNodeList nodeList = XmlManager.GetXmlMeasureFlowNodeInfo(xmlfullname);
  176. if (nodeList != null)
  177. {
  178. return XmlConvertTimeListItem(nodeList);
  179. }
  180. return null;
  181. }
  182. private TimeLineItem[] XmlConvertTimeListItem(XmlNodeList nodeList)
  183. {
  184. List<TimeLineItem> timeLineList = new List<TimeLineItem>();
  185. for (int i = 0; i < nodeList.Count; i++)
  186. {
  187. if (Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value))
  188. {
  189. TimeLineItem tlItem = new TimeLineItem();
  190. tlItem.Details = nodeList[i].Attributes["Details"].Value;
  191. tlItem.Code = nodeList[i].Attributes["Code"].Value;
  192. tlItem.State = -1;
  193. tlItem.Title = nodeList[i].Attributes["Title"].Value;
  194. tlItem.IsData = Convert.ToBoolean(nodeList[i].Attributes["IsData"].Value);
  195. tlItem.Type = nodeList[i].Attributes["Type"].Value;
  196. tlItem.IsShow = Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value);
  197. tlItem.Index = Convert.ToInt32(nodeList[i].Attributes["Index"].Value);
  198. timeLineList.Add(tlItem);
  199. }
  200. }
  201. TimeLineItem[] timeLineItem = new TimeLineItem[timeLineList.Count];
  202. //按照Index进行升序
  203. timeLineItem = timeLineList.OrderBy(i => i.Index).ToArray();
  204. //清空时间轴列表
  205. timeLineList.Clear();
  206. return timeLineItem;
  207. }
  208. #endregion
  209. #region 关闭按钮 鼠标操作事件
  210. private void pbClose_MouseEnter(object sender, EventArgs e)
  211. {
  212. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Red;
  213. }
  214. private void pbClose_MouseLeave(object sender, EventArgs e)
  215. {
  216. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
  217. }
  218. #endregion
  219. #region 设置切孔是否检测
  220. private void CkIsSwitch_CheckedChanged(object sender, EventArgs e)
  221. {
  222. //设置切孔是否检测
  223. List<CutHole> cutHoles = formHOZMain.m_MeasureFile.ListCutHole;
  224. foreach (CutHole item in cutHoles)
  225. {
  226. if (item.HoleName == CutHoleName)
  227. {
  228. item.SWITCH = CkIsSwitch.Checked;
  229. //是否已保存
  230. if (formHOZMain.IsSave)
  231. {
  232. //保存测量文件
  233. formHOZMain.m_MeasureFile.Save();
  234. }
  235. break;
  236. }
  237. }
  238. }
  239. #endregion
  240. }
  241. }