using MeasureThread;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HOZProject
{
    public class MeasureMsgManage
    {
        /// <summary>
        /// 线程消息处理，显示内容
        /// </summary>
        /// <param name="formHOZ">主窗体对象</param>
        /// <param name="args">消息对象</param>
        public static void ShowMsgContent(FormHOZMain formHOZ, ThreadStatusEventArgs args)
        {
            switch (args.Step_Code)
            {
                case "1-3":
                    //设置图像
                    formHOZ.pbImage.Image = null;
                    //流程内容
                    formHOZ.lblFlowContent.Text = "1";
                    break;
                default:
                    //设置图像
                    formHOZ.pbImage.Image = null;//new Bitmap(@"C:\Users\think\Pictures\ico\001.jpg");
                    //流程内容
                    formHOZ.lblFlowContent.Text = "1";
                    break;

            }
        }

        #region 测试修改切孔中流程节点状态
        /// <summary>
        /// 修改切孔中流程状态
        /// </summary>
        /// <param name="formHOZ">主窗体对象</param>
        /// <param name="cutHoleName">切孔名称</param>
        /// <param name="Code">流程编号</param>
        /// <param name="state">状态</param>
        /// <returns></returns>
        public static bool ChageCutHoleFlowNodeState(FormHOZMain formHOZ, string cutHoleName, string Code, int state)
        {
            if (formHOZ.plPrarInfo.Controls.Count > 0)
            {
                foreach (Control item in formHOZ.plPrarInfo.Controls)
                {
                    if (item is UserControl)
                    {
                        if (item.Name == cutHoleName)
                        {
                            UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
                            TimeLineItem[] ParaItem = uControl_ParaInfo.TlItem;
                            foreach (TimeLineItem tlItem in ParaItem)
                            {
                                if (tlItem.Code == Code)
                                {
                                    tlItem.State = state;
                                    break;
                                }
                            }
                            //重新绘制
                            uControl_ParaInfo.TimeLineInvalidate();
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        #endregion
    }
}
