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 参数定义
///
/// 开始时间
///
private string startTime;
///
/// 结束时间
///
private string endTime;
///
/// 状态
///
private string state;
///
/// 位置
///
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 重绘时间轴
///
/// 重绘时间轴
///
public void TimeLineInvalidate()
{
plTimeLine.Invalidate();
uCTimeLine.Invalidate();
}
#endregion
#region 显示切孔参数信息
///
/// 显示切孔参数信息
///
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 绑定流程信息
///
/// 绑定流程信息
///
///
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 timeLineList = new List();
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 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
}
}