UControl_ParaInfo.cs 7.6 KB

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