UControl_ParaInfo.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. /// <summary>
  18. /// 开始时间
  19. /// </summary>
  20. private string startTime;
  21. /// <summary>
  22. /// 结束时间
  23. /// </summary>
  24. private string endTime;
  25. /// <summary>
  26. /// 状态
  27. /// </summary>
  28. private string state;
  29. /// <summary>
  30. /// 位置
  31. /// </summary>
  32. private SemPosition position;
  33. private bool isSwitch;
  34. private string cutHoleName;
  35. private FormHOZMain formHOZMain;
  36. private TimeLineItem[] tlItem = null;
  37. private UCTimeLine uCTimeLine=null;
  38. private int flowCode = 1;
  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. public UControl_ParaInfo(FormHOZMain formHOZ)
  48. {
  49. InitializeComponent();
  50. FormHOZMainObject = formHOZ;
  51. ShowMeasureFlow("1");
  52. }
  53. private void btnClose_Click(object sender, EventArgs e)
  54. {
  55. foreach (Control item in FormHOZMainObject.plFill.Controls)
  56. {
  57. if (item is Panel)
  58. {
  59. foreach (Control itemControl in item.Controls)
  60. {
  61. if (itemControl.Name == this.Name)
  62. {
  63. item.Controls.Remove(this);
  64. this.Dispose();
  65. item.Visible = false;
  66. break;
  67. }
  68. }
  69. }
  70. }
  71. }
  72. public void ShowUCTimeLine(TimeLineItem[] tlItem)
  73. {
  74. if (plTimeLine.Controls.Count == 0)
  75. {
  76. uCTimeLine = new UCTimeLine(tlItem);
  77. uCTimeLine.Dock = DockStyle.Fill;
  78. plTimeLine.Controls.Add(uCTimeLine);
  79. }
  80. }
  81. public void TimeLineInvalidate()
  82. {
  83. plTimeLine.Invalidate();
  84. uCTimeLine.Invalidate();
  85. }
  86. /// <summary>
  87. /// 显示切孔参数信息
  88. /// </summary>
  89. public void ShowParaInfo()
  90. {
  91. int multiple = 1000;
  92. //设置Position参数
  93. lblX.Text = (Position.X * multiple).ToString("f3");
  94. lblY.Text = (Position.Y * multiple).ToString("f3");
  95. lblZ.Text = (Position.Z * multiple).ToString("f3");
  96. lblR.Text = Position.R.ToString();
  97. lblT.Text = Position.T.ToString();
  98. lblM.Text = Position.M.ToString();
  99. lblShowStartTime.Text = StartTime;
  100. lblShowEndTime.Text = EndTime;
  101. lblShowState.Text = State;
  102. lblCutHoleName.Text = CutHoleName;
  103. CkIsSwitch.Checked = IsSwitch;
  104. }
  105. /// <summary>
  106. /// 绑定流程信息
  107. /// </summary>
  108. /// <param name="flowCode"></param>
  109. private void ShowMeasureFlow(string flowCode)
  110. {
  111. if (TlItem == null)
  112. {
  113. TlItem = GetMeasureFlowStructInfo(flowCode);
  114. }
  115. if (TlItem != null)
  116. {
  117. ShowUCTimeLine(TlItem);
  118. }
  119. }
  120. private TimeLineItem[] GetMeasureFlowStructInfo(string MeasureCode)
  121. {
  122. string xmlfullname = Application.StartupPath+ @"\MeasureXML\MeasureStructXml.xml";
  123. XmlNodeList nodeList = XmlManager.GetXmlMeasureFlowNodeInfo(xmlfullname, MeasureCode);
  124. if (nodeList != null)
  125. {
  126. return XmlConvertTimeListItem(nodeList);
  127. }
  128. return null;
  129. }
  130. private TimeLineItem[] XmlConvertTimeListItem(XmlNodeList nodeList)
  131. {
  132. TimeLineItem[] timeLineItem = new TimeLineItem[nodeList.Count];
  133. for (int i = 0; i < nodeList.Count; i++)
  134. {
  135. TimeLineItem tlItem = new TimeLineItem();
  136. tlItem.Details = nodeList[i].Attributes["Details"].Value;
  137. tlItem.Code = nodeList[i].Attributes["Code"].Value;
  138. tlItem.State = 0;
  139. tlItem.Title = nodeList[i].Attributes["Title"].Value;
  140. tlItem.IsData = Convert.ToBoolean(nodeList[i].Attributes["IsData"].Value);
  141. timeLineItem[i] = tlItem;
  142. }
  143. return timeLineItem;
  144. }
  145. }
  146. }