UControl_ParaInfo.cs 7.8 KB

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