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;

namespace HOZProject
{
    public partial class UControl_CutHole : UserControl
    {
        #region 成员变量
        private string cutHoleName;
        public string CutHoleName { get => cutHoleName; set => cutHoleName = value; }
        private string cutHoleCode;
        public string CutHoleCode { get => cutHoleCode; set => cutHoleCode = value; }
        private int cutHoleState;
        public int CutHoleState { get => cutHoleState; set => cutHoleState = value; }

        private FormHOZMain formHOZMain;
        public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
        private UControl_ParaInfo uControl_ParaInfo;
        public UControl_ParaInfo UControl_ParaInfo { get => uControl_ParaInfo; set => uControl_ParaInfo = value; } 
        #endregion

        public UControl_CutHole(FormHOZMain formHOZ)
        {
            InitializeComponent();
            FormHOZMainObject = formHOZ;
        }

        private void UContrl_CutHole_Load(object sender, EventArgs e)
        {
            btnCutHole.Text = CutHoleName;
        }

        private void tsShowProcess_Click(object sender, EventArgs e)
        {
        }


        private void tsShowParaInfo_Click(object sender, EventArgs e)
        {
            //显示处理信息
            ShowParaControl(UControl_ParaInfo.Name);
            //if (FormHOZMainObject.plPrarInfo.Visible)
            //{
            //    FormHOZMainObject.plPrarInfo.Visible = false;
            //}
            //else
            //{
            //    FormHOZMainObject.plPrarInfo.Visible = true;
            //}
            FormHOZMainObject.plPrarInfo.Visible = true;
        }

        /// <summary>
        /// 向主界面中的属性层中,添加切孔信息用户控件
        /// </summary>
        /// <param name="uControl_ParaInfo"></param>
        private void AddParaControl(UControl_ParaInfo uControl_ParaInfo)
        {
            bool isExist = false;
            if (FormHOZMainObject.plPrarInfo.Controls.Count == 0)
            {
                FormHOZMainObject.plPrarInfo.Controls.Add(uControl_ParaInfo);
                isExist = true;
            }
            else
            {
                foreach (Control item in FormHOZMainObject.plPrarInfo.Controls)
                {
                    if (item is UserControl)
                    {
                        if (item.Name == uControl_ParaInfo.Name)
                        {
                            isExist = true;
                            break;
                        }
                    }
                }
            }
            if (!isExist)
            {
                FormHOZMainObject.plPrarInfo.Controls.Add(uControl_ParaInfo);
            }
        }
        private void ShowParaControl(string cutHoleName)
        {
            foreach (Control item in FormHOZMainObject.plPrarInfo.Controls)
            {
                if (item is UserControl)
                {
                    if (item.Name == cutHoleName)
                    {
                        item.Visible = true;
                    }
                    else
                    {
                        item.Visible = false;
                    }
                }
            }
        }
    }
}
