123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using MeasureData;
- using FileManager;
- using System.Xml;
- namespace HOZProject
- {
- public partial class UControl_ParaInfo : UserControl
- {
- #region 参数定义
- /// <summary>
- /// 开始时间
- /// </summary>
- private string startTime;
- /// <summary>
- /// 结束时间
- /// </summary>
- private string endTime;
- /// <summary>
- /// 状态
- /// </summary>
- private string state;
- /// <summary>
- /// 位置
- /// </summary>
- private SemPosition position;
- private bool isSwitch;
- private string cutHoleName;
- private FormHOZMain formHOZMain;
- private TimeLineItem[] tlItem = null;
- private UCTimeLine uCTimeLine = null;
- public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
- public string StartTime { get => startTime; set => startTime = value; }
- public string EndTime { get => endTime; set => endTime = value; }
- public string State { get => state; set => state = value; }
- public SemPosition Position { get => position; set => position = value; }
- public string CutHoleName { get => cutHoleName; set => cutHoleName = value; }
- public bool IsSwitch { get => isSwitch; set => isSwitch = value; }
- public TimeLineItem[] TlItem { get => tlItem; set => tlItem = value; }
- #endregion
- public UControl_ParaInfo(FormHOZMain formHOZ)
- {
- InitializeComponent();
- FormHOZMainObject = formHOZ;
- //显示测量流程
- ShowMeasureFlow();
- }
- #region 关闭属性层
- private void btnClose_Click(object sender, EventArgs e)
- {
- foreach (Control item in FormHOZMainObject.plFill.Controls)
- {
- if (item is Panel)
- {
- foreach (Control itemControl in item.Controls)
- {
- if (itemControl.Name == this.Name)
- {
- item.Controls.Remove(this);
- this.Dispose();
- item.Visible = false;
- break;
- }
- }
- }
- }
- }
- #endregion
- #region 重绘时间轴
- /// <summary>
- /// 重绘时间轴
- /// </summary>
- public void TimeLineInvalidate()
- {
- plTimeLine.Invalidate();
- uCTimeLine.Invalidate();
- }
- #endregion
- #region 显示切孔参数信息
- /// <summary>
- /// 显示切孔参数信息
- /// </summary>
- public void ShowParaInfo()
- {
- int multiple = 1000;
- //设置Position参数
- lblX.Text = (Position.X * multiple).ToString("f3");
- lblY.Text = (Position.Y * multiple).ToString("f3");
- lblZ.Text = (Position.Z * multiple).ToString("f3");
- lblR.Text = Position.R.ToString();
- lblT.Text = Position.T.ToString();
- lblM.Text = Position.M.ToString();
- lblShowStartTime.Text = StartTime;
- lblShowEndTime.Text = EndTime;
- lblShowState.Text = State;
- lblCutHoleName.Text = CutHoleName;
- CkIsSwitch.Checked = IsSwitch;
- }
- #endregion
- #region 绑定流程信息
- /// <summary>
- /// 绑定流程信息
- /// </summary>
- /// <param name="flowCode"></param>
- private void ShowMeasureFlow()
- {
- if (TlItem == null)
- {
- TlItem = GetMeasureFlowStructInfo();
- }
- if (TlItem != null)
- {
- ShowUCTimeLine(TlItem);
- }
- }
- public void ShowUCTimeLine(TimeLineItem[] tlItem)
- {
- if (plTimeLine.Controls.Count == 0)
- {
- uCTimeLine = new UCTimeLine(tlItem, FormHOZMainObject.m_MeasureType);
- uCTimeLine.Dock = DockStyle.Fill;
- plTimeLine.Controls.Add(uCTimeLine);
- }
- }
- private TimeLineItem[] GetMeasureFlowStructInfo()
- {
- string xmlfullname = Application.StartupPath + @"\MeasureXML\MeasureStructXml.xml";
- XmlNodeList nodeList = XmlManager.GetXmlMeasureFlowNodeInfo(xmlfullname);
- if (nodeList != null)
- {
- return XmlConvertTimeListItem(nodeList);
- }
- return null;
- }
- private TimeLineItem[] XmlConvertTimeListItem(XmlNodeList nodeList)
- {
- List<TimeLineItem> timeLineList = new List<TimeLineItem>();
- for (int i = 0; i < nodeList.Count; i++)
- {
- if (Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value))
- {
- TimeLineItem tlItem = new TimeLineItem();
- tlItem.Details = nodeList[i].Attributes["Details"].Value;
- tlItem.Code = nodeList[i].Attributes["Code"].Value;
- //tlItem.State = -1;
- tlItem.Title = nodeList[i].Attributes["Title"].Value;
- tlItem.IsData = Convert.ToBoolean(nodeList[i].Attributes["IsData"].Value);
- tlItem.Type = nodeList[i].Attributes["Type"].Value;
- tlItem.IsShow = Convert.ToBoolean(nodeList[i].Attributes["IsShow"].Value);
- tlItem.Index = Convert.ToInt32(nodeList[i].Attributes["Index"].Value);
- timeLineList.Add(tlItem);
- }
- }
- TimeLineItem[] timeLineItem = new TimeLineItem[timeLineList.Count];
- //按照Index进行升序
- timeLineItem = timeLineList.OrderBy(i => i.Index).ToArray();
- //清空时间轴列表
- timeLineList.Clear();
- return timeLineItem;
- }
- #endregion
- #region 关闭按钮 鼠标操作事件
- private void pbClose_MouseEnter(object sender, EventArgs e)
- {
- pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Red;
- }
- private void pbClose_MouseLeave(object sender, EventArgs e)
- {
- pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
- }
- #endregion
- #region 设置切孔是否检测
- private void CkIsSwitch_CheckedChanged(object sender, EventArgs e)
- {
- //设置切孔是否检测
- List<CutHole> cutHoles = formHOZMain.m_MeasureFile.ListCutHole;
- foreach (CutHole item in cutHoles)
- {
- if (item.HoleName == CutHoleName)
- {
- item.SWITCH = CkIsSwitch.Checked;
- //是否已保存
- if (formHOZMain.IsSave)
- {
- //保存测量文件
- formHOZMain.m_MeasureFile.Save();
- }
- break;
- }
- }
- }
- #endregion
- }
- }
|