UControl_ParaInfo.cs 7.2 KB

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