using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using SmartX;
using INT_LKD_2.Forms;
using INT_LKD_2.DataStore;
using INT_LKD_2.DialogForms;

namespace INT_LKD_2.Controls
{
    public partial class ControlMenuRecipeSetting : UserControl
    {
        #region Field
        private string MessageBoxRange;

        private FormMenu m_ParentForm;

        private Collection<Control> CollControls;

        private ControlMenuRecipeData ChildControlRecipeData1;
        private ControlMenuRecipeData ChildControlRecipeData2;
        #endregion

        #region Constructor
        public ControlMenuRecipeSetting(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;
            this.Initialize();
        }
        #endregion

        #region Property
        public FormMenu ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }
        #endregion

        #region Method
        private void Initialize()
        {
            this.smartGroupBox1.Text = "Recipe > Setting";
            this.MessageBoxRange = "";

            this.CollControls = new Collection<Control>();
            this.CollControls.Add(this.labelNumber);
            this.CollControls.Add(this.labelPressureLevel);
            this.CollControls.Add(this.labelDispEmptyLevel);
            this.CollControls.Add(this.labelDispMinHeight);
            this.CollControls.Add(this.labelDispMaxDiff);
            this.CollControls.Add(this.labelDiffDelayTime);
            this.CollControls.Add(this.labelDiffLrLimit);
            this.CollControls.Add(this.labelDiffLrCycle);
            this.CollControls.Add(this.labelVacuumStart);
            this.CollControls.Add(this.labelVacuumHold1);
            this.CollControls.Add(this.labelVacuumHold2);
            this.CollControls.Add(this.labelVacuumBreak);
            this.CollControls.Add(this.radioButton1);
            this.CollControls.Add(this.radioButton2);
            this.CollControls.Add(this.radioButton3);
            this.CollControls.Add(this.radioButton4);
            this.CollControls.Add(this.radioButton5);
            this.CollControls.Add(this.radioButton6);
            this.CollControls.Add(this.buttonInspection);

            this.ChildControlRecipeData1 = new ControlMenuRecipeData(this.ParentForm);
            this.ChildControlRecipeData2 = new ControlMenuRecipeData(this.ParentForm);

            this.Controls.Add(this.ChildControlRecipeData1);
            this.Controls.Add(this.ChildControlRecipeData2);

            this.ChildControlRecipeData1.Location = new Point(3, 78);
            this.ChildControlRecipeData2.Location = new Point(3, 78);
            this.ChildControlRecipeData1.BringToFront();

            this.buttonSlave.ButtonDown();
            this.buttonMaster.ButtonUp();
        }

        private void UpdateDisplauUserControls(bool enable)
        {
            for (int i = 0; i < this.CollControls.Count; i++)
                this.CollControls[i].Enabled = enable;
        }
        private void UpdateDisplayUser(UserItem user)
        {
            switch (user.Group)
            {
                case Define.E_UserGroup.None:
                    this.UpdateDisplauUserControls(false);
                    break;
                case Define.E_UserGroup.Level1:
                    this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuRecipe);
                    break;
                case Define.E_UserGroup.Level2:
                    this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuRecipe);
                    break;
                case Define.E_UserGroup.Level3:
                    this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuRecipe);
                    break;
                case Define.E_UserGroup.Admin:
                    this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuRecipe);
                    break;
                case Define.E_UserGroup.Developer:
                    this.UpdateDisplauUserControls(true);
                    break;
                case Define.E_UserGroup.NotLogin:
                    this.UpdateDisplauUserControls(false);
                    break;
                case Define.E_UserGroup.LogOut:
                    this.UpdateDisplauUserControls(false);
                    break;
                default:
                    break;
            }
        }
        public void UpdateDisplayControlData(Recipe item)
        {
            string value = "";

            // Number
            value = item.NUMBER.ToString();
            if (this.labelNumber.Text != value)
                this.labelNumber.Text = value;
            // Pressure data
            // Pressure Level
            value = item.VACUUM_GUAGE_LEVEL;
            if (this.labelPressureLevel.Text != value)
                this.labelPressureLevel.Text = value;
            // Vacuum Relief
            value = item.VACUUM_START_SEC.ToString();
            if (this.labelVacuumStart.Text != value)
                this.labelVacuumStart.Text = value;
            // Vacuum Hold1
            value = item.VACUUM_HOLD1_SEC.ToString();
            if (this.labelVacuumHold1.Text != value)
                this.labelVacuumHold1.Text = value;
            // Vacuum Hold2
            value = item.VACUUM_HOLD2_SEC.ToString();
            if (this.labelVacuumHold2.Text != value)
                this.labelVacuumHold2.Text = value;
            // Vacuum Blowoff
            value = item.VACUUM_BREAK_SEC.ToString();
            if (this.labelVacuumBreak.Text != value)
                this.labelVacuumBreak.Text = value;

            // Differential Pressure Sensor
            // LR_Limit
            value = item.DIFF_LR_LIMIT;
            if (this.labelDiffLrLimit.Text != value)
                this.labelDiffLrLimit.Text = value;
            // LR_Cycle
            value = item.DIFF_LR_CYCLE.ToString();
            if (this.labelDiffLrCycle.Text != value)
                this.labelDiffLrCycle.Text = value;
            // Delay
            value = item.DIFF_LR_DELAY_SEC;
            if (this.labelDiffDelayTime.Text != value)
                this.labelDiffDelayTime.Text = value;

            // Displacement Sensor
            // Max_Diff
            value = item.DISP_JUDG_MAX_DIFF;
            if (this.labelDispMaxDiff.Text != value)
                this.labelDispMaxDiff.Text = value;
            // Empty_Level
            value = item.DISP_JUDG_EMPTY_LEVEL;
            if (this.labelDispEmptyLevel.Text != value)
                this.labelDispEmptyLevel.Text = value;
            // Min_Hight
            value = item.DISP_JUDG_MIN_HEIGHT;
            if (this.labelDispMinHeight.Text != value)
                this.labelDispMinHeight.Text = value;
            // OPT1
            if (item.DISP_JUDG_ENABLE == true)
            {
                this.buttonDispEnable.ButtonText = "ON";
                this.buttonDispEnable.ButtonDown();
            }
            else
            {
                this.buttonDispEnable.ButtonText = "OFF";
                this.buttonDispEnable.ButtonUp();
            }
            this.UpdateDisplayDispEnable(item.DISP_JUDG_ENABLE);
            this.ChildControlRecipeData1.UpdateDisplayDispControl(item.DISP_JUDG_ENABLE);
            this.ChildControlRecipeData2.UpdateDisplayDispControl(item.DISP_JUDG_ENABLE);
        }
        private void UpdateDisplayDispEnable(bool enable)
        {
            if (enable == true)
            {
                this.labelDispEmptyLevel.BackGroundColor = Color.White;
                this.labelDispMinHeight.BackGroundColor = Color.White;
                this.labelDispMaxDiff.BackGroundColor = Color.White;

                this.labelDispEmptyLevel.Enabled = true;
                this.labelDispMinHeight.Enabled = true;
                this.labelDispMaxDiff.Enabled = true;
            }
            else
            {
                this.labelDispEmptyLevel.BackGroundColor = Color.Silver;
                this.labelDispMinHeight.BackGroundColor = Color.Silver;
                this.labelDispMaxDiff.BackGroundColor = Color.Silver;

                this.labelDispEmptyLevel.Enabled = false;
                this.labelDispMinHeight.Enabled = false;
                this.labelDispMaxDiff.Enabled = false;
            }
        }

        // Process
        public void UpdateDisplayProcessStatus(Define.E_ProcessStatus status)
        {
            switch (status)
            {
                case Define.E_ProcessStatus._0_None:
                    break;
                case Define.E_ProcessStatus._1_Ready:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOn) this.labelProgress1.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;

                    this.UpdateDisplayUser(this.ParentForm.ParentForm.CurrentSystemStatus.CurrentUser);
                    break;
                case Define.E_ProcessStatus._2_ProductEntry:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOn) this.labelProgress2.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;

                    this.UpdateDisplauUserControls(false);
                    //this.ChildControlRecipeData1.InitializeData();
                    //this.ChildControlRecipeData2.InitializeData();
                    break;
                case Define.E_ProcessStatus._3_MoveToLeak:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOn) this.labelProgress3.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._4_MoveToCheck:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOn) this.labelProgress3.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;

                    this.ChildControlRecipeData1.DrawPutDataAllClear();
                    this.ChildControlRecipeData2.DrawPutDataAllClear();
                    break;
                case Define.E_ProcessStatus._5_ChamberMerge:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOn) this.labelProgress4.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._6_VacuumStart:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOn) this.labelProgress5.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._7_VacuumHold:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor !=Define .ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOn) this.labelProgress6.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._8_Judgment:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOn) this.labelProgress7.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._9_VacuumBreak:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOn) this.labelProgress8.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._10_ChamberRelease:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOn) this.labelProgress9.BackGroundColor = Define.ColorProgressOn;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOff) this.labelProgress10.BackGroundColor = Define.ColorProgressOff;
                    break;
                case Define.E_ProcessStatus._11_MoveToReady:
                    if (this.labelProgress1.BackGroundColor != Define.ColorProgressOff) this.labelProgress1.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress2.BackGroundColor != Define.ColorProgressOff) this.labelProgress2.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress3.BackGroundColor != Define.ColorProgressOff) this.labelProgress3.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress4.BackGroundColor != Define.ColorProgressOff) this.labelProgress4.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress5.BackGroundColor != Define.ColorProgressOff) this.labelProgress5.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress6.BackGroundColor != Define.ColorProgressOff) this.labelProgress6.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress7.BackGroundColor != Define.ColorProgressOff) this.labelProgress7.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress8.BackGroundColor != Define.ColorProgressOff) this.labelProgress8.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress9.BackGroundColor != Define.ColorProgressOff) this.labelProgress9.BackGroundColor = Define.ColorProgressOff;
                    if (this.labelProgress10.BackGroundColor != Define.ColorProgressOn) this.labelProgress10.BackGroundColor = Define.ColorProgressOn;
                    break;
                default:
                    break;
            }
        }
        // 차압센서 데이터
        public void UpdateDisplayDiffData1(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData2(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData3(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData4(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData5(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData6(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData7(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData8(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData9(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData10(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData11(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        public void UpdateDisplayDiffData12(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDiff(data.DiffData);
        }
        // 변위센서 데이터
        public void UpdateDisplayDispData1(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData2(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData3(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData4(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData5(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData6(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData7(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData8(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData9(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData10(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData11(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        public void UpdateDisplayDispData12(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataDisp(data.DispData);
        }
        // 압력센서 데이터
        public void UpdateDisplayPresData1(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData2(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData3(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData4(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData5(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData6(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData7(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData8(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData9(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData10(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData11(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        public void UpdateDisplayPresData12(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeakDataPres(data.PresData);
        }
        // 판정결과
        public void UpdateDisplayJudgmentData1(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData2(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData3(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData4(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData5(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData6(LeakData1 data)
        {
            this.ChildControlRecipeData1.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData7(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData8(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData9(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData10(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData11(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeadDataResult(data);
        }
        public void UpdateDisplayJudgmentData12(LeakData1 data)
        {
            this.ChildControlRecipeData2.UpdateDisplayMeasuringLeadDataResult(data);
        }

        public void DisplayRefresh()
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplayMode = Define.E_DisplayModeStore.Recipe;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_EquipmentMode.Normal);
            this.UpdateDisplayControlData(this.ParentForm.ParentForm.CurrentRecipe);

            this.UpdateDisplayUser(this.ParentForm.ParentForm.CurrentSystemStatus.CurrentUser);

            this.ChildControlRecipeData1.InitializeData();
            this.ChildControlRecipeData2.InitializeData();

            this.ChildControlRecipeData1.CalScaleDiff(this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_LIMIT);
            this.ChildControlRecipeData2.CalScaleDiff(this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_LIMIT);
            this.ChildControlRecipeData1.DrawDiffReferenceLine(this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_LIMIT);
            this.ChildControlRecipeData2.DrawDiffReferenceLine(this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_LIMIT);
            this.ChildControlRecipeData1.DrawDispReferenceLine(this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_MIN_HEIGHT);
            this.ChildControlRecipeData2.DrawDispReferenceLine(this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_MIN_HEIGHT);
        }
        #endregion

        #region Event Handler
        private void labelNumber_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.labelNumber.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel17.Text, this.labelNumber.Text, 4, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 1 || myKeypad.IntValue > 1000)
                {
                    this.MessageBoxRange = "1 ~ 1000";
                    this.labelPressureLevel.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelNumber.Text = "**";
                this.ParentForm.ParentForm.TransferRecipeParameter9043(myKeypad.IntValue, Define.E_BoardMode.Master);
                this.ParentForm.ParentForm.TransferRecipeParameter9043(myKeypad.IntValue, Define.E_BoardMode.Slave);
                after = myKeypad.StringValue;

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.RecipeNumber, "", before, after);
            }
        }
        private void labelPressureLevel_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelPressureLevel.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel15.Text, this.labelPressureLevel.Text, 5, 1, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.doubleValue > -50 || myKeypad.doubleValue < -100)
                {
                    this.MessageBoxRange = "-50.0 ~ -100.0";
                    this.labelPressureLevel.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelPressureLevel.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.VACUUM_GUAGE_LEVEL = myKeypad.StringValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits6(myKeypad.StringValue);

                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.
                    MainBoardMaster, CommunicationAddress._5517_VacuumGaugeStdLevel, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.
                    MainBoardSlave, CommunicationAddress._5517_VacuumGaugeStdLevel, value);

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Pressure, "", before, after);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.ChildControlRecipeData1.BringToFront();

            //this.radioButton1.Text = "1";
            //this.radioButton2.Text = "2";
            //this.radioButton3.Text = "3";
            //this.radioButton4.Text = "4";
            //this.radioButton5.Text = "5";
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.ChildControlRecipeData2.BringToFront();
        }

        // 밸브
        private void labelVacuumStart_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelVacuumStart.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel22.Text, this.labelVacuumStart.Text, 4, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 0 || myKeypad.IntValue > 9999)
                {
                    this.MessageBoxRange = "0 ~ 9999";
                    this.labelVacuumStart.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelVacuumStart.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.VACUUM_START_SEC = myKeypad.IntValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits4(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5504_VacuumStart, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5504_VacuumStart, value);

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.P_reliefTime, "", before, after);
            }
        }
        private void labelVacuumHold1_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelVacuumHold1.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel24.Text, this.labelVacuumHold1.Text, 4, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 0 || myKeypad.IntValue > 9999)
                {
                    this.MessageBoxRange = "0 ~ 9999";
                    this.labelVacuumHold1.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelVacuumHold1.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.VACUUM_HOLD1_SEC = myKeypad.IntValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits4(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5505_VacuumHold1, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5505_VacuumHold1, value);

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.P_HlodingTime, "", before, after);
            }
        }
        private void labelVacuumHold2_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelVacuumHold2.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel26.Text, this.labelVacuumHold2.Text, 4, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 0 || myKeypad.IntValue > this.ParentForm.ParentForm.CurrentRecipe.VACUUM_HOLD1_SEC - 1)
                {
                    this.MessageBoxRange = string.Format("0 ~ {0}", this.ParentForm.ParentForm.CurrentRecipe.VACUUM_HOLD1_SEC - 1);
                    this.labelVacuumHold2.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelVacuumHold2.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.VACUUM_HOLD2_SEC = myKeypad.IntValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits4(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5506_VacuumHold2, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5506_VacuumHold2, value);

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.P_HoldingTime2, "", before, after);
            }
        }
        private void labelVacuumBreak_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelVacuumBreak.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel2.Text, this.labelVacuumBreak.Text, 4, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 0 || myKeypad.IntValue > 9999)
                {
                    this.MessageBoxRange = "0 ~ 9999";
                    this.labelVacuumBreak.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelVacuumBreak.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.VACUUM_BREAK_SEC = myKeypad.IntValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits4(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5507_VacuumBreak, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5507_VacuumBreak, value);
               
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.P_BreakTime, "", before, after);
            }
        }

        // 변위센서
        private void labelDispEmptyLevel_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelDispEmptyLevel.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel5.Text, this.labelDispEmptyLevel.Text, 5, 2, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.doubleValue < 0 || myKeypad.doubleValue > 100)
                {
                    this.MessageBoxRange = "0.00 ~ 100.00";
                    this.labelDispEmptyLevel.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelDispEmptyLevel.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_EMPTY_LEVEL = myKeypad.StringValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits6(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.SubBoard1, CommunicationAddress._5511_DispEmptyLevel, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.SubBoard1, CommunicationAddress._5511_DispEmptyLevel, value);

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Disp_EmptyLevel, "", before, after);
            }
        }
        private void labelDispMaxDiff_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelDispMaxDiff.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel7.Text, this.labelDispMaxDiff.Text, 5, 2, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.doubleValue < 0 || myKeypad.doubleValue > 100)
                {
                    this.MessageBoxRange = "0.00 ~ 100.00";
                    this.labelDispMaxDiff.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelDispMaxDiff.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_MAX_DIFF = myKeypad.StringValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits6(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5509_DispMaxDiff, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5509_DispMaxDiff, value);
                
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Disp_MaxDiff, "", before, after);
            }
        }
        private void labelDispMinHight_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelDispMinHeight.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel3.Text, this.labelDispMinHeight.Text, 5, 2, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.doubleValue < 0 || myKeypad.doubleValue > 100)
                {
                    this.MessageBoxRange = "0.00 ~ 100.00";
                    this.labelDispMinHeight.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelDispMinHeight.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_MIN_HEIGHT = myKeypad.StringValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits6(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5510_DispMinHight, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5510_DispMinHight, value);
              
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Disp_MinHight, "", before, after);

                this.ChildControlRecipeData1.DrawDispReferenceLine(myKeypad.StringValue);
                this.ChildControlRecipeData2.DrawDispReferenceLine(myKeypad.StringValue);
            }
        }
        private void buttonDispEnable1_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            if (this.buttonDispEnable.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.buttonDispEnable.ButtonText = "ON";
                before = "false";
                this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_ENABLE = true;
                value = Helper.StringBlankFillDigits4("1");
                after = "true";

            }
            else
            {
                this.buttonDispEnable.ButtonText = "OFF";
                before = "true";
                this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_ENABLE = false;
                value = Helper.StringBlankFillDigits4("0");
                after = "false";
            }

            this.UpdateDisplayDispEnable(this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_ENABLE);
            this.ChildControlRecipeData1.UpdateDisplayDispControl(this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_ENABLE);
            this.ChildControlRecipeData2.UpdateDisplayDispControl(this.ParentForm.ParentForm.CurrentRecipe.DISP_JUDG_ENABLE);

            this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
            this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5518_DispSensorEnable, value);
            this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5518_DispSensorEnable, value);
            
            this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Disp_Enable, "", before, after);
        }

        // 차압센서
        private void labelDiffLrLimit_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelDiffLrLimit.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel13.Text, this.labelDiffLrLimit.Text, 5, 2, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.doubleValue < 0 || myKeypad.doubleValue > 999.99)
                {
                    this.MessageBoxRange = "0.00 ~ 999.99";
                    this.labelDiffLrLimit.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelDiffLrLimit.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_LIMIT = myKeypad.StringValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits6(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5513_DiffLrLimit, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5513_DiffLrLimit, value);
                
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Diff_LrLimit, "", before, after);

                this.ChildControlRecipeData1.CalScaleDiff(myKeypad.StringValue);
                this.ChildControlRecipeData2.CalScaleDiff(myKeypad.StringValue);
                this.ParentForm.Child_System_Equipment10.CalScaleDiff(myKeypad.StringValue);
                this.ChildControlRecipeData1.DrawDiffReferenceLine(myKeypad.StringValue);
                this.ChildControlRecipeData2.DrawDiffReferenceLine(myKeypad.StringValue);
                this.ParentForm.Child_System_Equipment10.DrawDiffReferenceLine(myKeypad.StringValue);
            }
        }
        private void labelDiffLrCycle_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelDiffLrCycle.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel11.Text, this.labelDiffLrCycle.Text, 2, 0, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.IntValue < 1 || myKeypad.IntValue > 10)
                {
                    this.MessageBoxRange = "1 ~ 10";
                    this.labelDiffLrCycle.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelDiffLrCycle.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_CYCLE = myKeypad.IntValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits4(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5519_DiffCycle, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5519_DiffCycle, value);

                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Diff_Cycle, "", before, after);
            }
        }
        private void labelDiffDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            before = this.labelDiffDelayTime.Text;
            DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.smartLabel4.Text, this.labelDiffDelayTime.Text, 4, 1, false);

            if (myKeypad.ShowDialog() == DialogResult.OK)
            {
                if (myKeypad.doubleValue < 0 || myKeypad.doubleValue > 999.9)
                {
                    this.MessageBoxRange = "0 ~ 999.9";
                    this.labelDiffDelayTime.Text = before;
                    this.smartTimerMessageShow.Start();
                    return;
                }

                this.labelDiffDelayTime.Text = myKeypad.StringValue;
                this.ParentForm.ParentForm.CurrentRecipe.DIFF_LR_DELAY_SEC = myKeypad.StringValue;
                this.ParentForm.ParentForm.SaveRecipeFile(this.ParentForm.ParentForm.CurrentRecipe);
                after = myKeypad.StringValue;

                value = Helper.StringBlankFillDigits4(myKeypad.StringValue);
                this.ParentForm.ParentForm.TransferDataStream_Master(CommunicationCommand.Write, CommunicationID.MainBoardMaster, CommunicationAddress._5516_DiffHoldDelay, value);
                this.ParentForm.ParentForm.TransferDataStream_Slave(CommunicationCommand.Write, CommunicationID.MainBoardSlave, CommunicationAddress._5516_DiffHoldDelay, value);
                
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Diff_HoldDelay, "", before, after);
            }
        }

        // Inspection
        private void buttonInspection_Click(object sender, EventArgs e)
        {
            string id = "";

            if (this.radioButton1.Checked == true)
                id = CommunicationID.SubBoard1;
            else if (this.radioButton2.Checked == true)
                id = CommunicationID.SubBoard2;
            else if (this.radioButton3.Checked == true)
                id = CommunicationID.SubBoard3;
            else if (this.radioButton4.Checked == true)
                id = CommunicationID.SubBoard4;
            else if (this.radioButton5.Checked == true)
                id = CommunicationID.SubBoard5;
            else if (this.radioButton6.Checked == true)
                id = CommunicationID.SubBoard6;

            this.ChildControlRecipeData1.InitializeData();
            this.ChildControlRecipeData2.InitializeData();

            this.ParentForm.ParentForm.TransferData_Master(CommunicationCommand.CutInpupt, id);
            this.ParentForm.ParentForm.TransferData_Slave(CommunicationCommand.CutInpupt, id);
        }
        private void radioButton1_Click(object sender, EventArgs e)
        {
            this.radioButton1.RadioBackColor = Define.ColorSelected;
            this.radioButton2.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton3.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton4.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton5.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton6.RadioBackColor = Define.ColorNoneSelected;

            this.radioButton1.TextColor = Define.ColorSelected;
            this.radioButton2.TextColor = Define.ColorNoneSelected;
            this.radioButton3.TextColor = Define.ColorNoneSelected;
            this.radioButton4.TextColor = Define.ColorNoneSelected;
            this.radioButton5.TextColor = Define.ColorNoneSelected;
            this.radioButton6.TextColor = Define.ColorNoneSelected;
        }
        private void radioButton2_Click(object sender, EventArgs e)
        {
            this.radioButton1.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton2.RadioBackColor = Define.ColorSelected;
            this.radioButton3.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton4.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton5.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton6.RadioBackColor = Define.ColorNoneSelected;

            this.radioButton1.TextColor = Define.ColorNoneSelected;
            this.radioButton2.TextColor = Define.ColorSelected;
            this.radioButton3.TextColor = Define.ColorNoneSelected;
            this.radioButton4.TextColor = Define.ColorNoneSelected;
            this.radioButton5.TextColor = Define.ColorNoneSelected;
            this.radioButton6.TextColor = Define.ColorNoneSelected;
        }
        private void radioButton3_Click(object sender, EventArgs e)
        {
            this.radioButton1.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton2.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton3.RadioBackColor = Define.ColorSelected;
            this.radioButton4.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton5.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton6.RadioBackColor = Define.ColorNoneSelected;

            this.radioButton1.TextColor = Define.ColorNoneSelected;
            this.radioButton2.TextColor = Define.ColorNoneSelected;
            this.radioButton3.TextColor = Define.ColorSelected;
            this.radioButton4.TextColor = Define.ColorNoneSelected;
            this.radioButton5.TextColor = Define.ColorNoneSelected;
            this.radioButton6.TextColor = Define.ColorNoneSelected;
        }
        private void radioButton4_Click(object sender, EventArgs e)
        {
            this.radioButton1.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton2.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton3.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton4.RadioBackColor = Define.ColorSelected;
            this.radioButton5.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton6.RadioBackColor = Define.ColorNoneSelected;

            this.radioButton1.TextColor = Define.ColorNoneSelected;
            this.radioButton2.TextColor = Define.ColorNoneSelected;
            this.radioButton3.TextColor = Define.ColorNoneSelected;
            this.radioButton4.TextColor = Define.ColorSelected;
            this.radioButton5.TextColor = Define.ColorNoneSelected;
            this.radioButton6.TextColor = Define.ColorNoneSelected;
        }
        private void radioButton5_Click(object sender, EventArgs e)
        {
            this.radioButton1.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton2.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton3.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton4.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton5.RadioBackColor = Define.ColorSelected;
            this.radioButton6.RadioBackColor = Define.ColorNoneSelected;

            this.radioButton1.TextColor = Define.ColorNoneSelected;
            this.radioButton2.TextColor = Define.ColorNoneSelected;
            this.radioButton3.TextColor = Define.ColorNoneSelected;
            this.radioButton4.TextColor = Define.ColorNoneSelected;
            this.radioButton5.TextColor = Define.ColorSelected;
            this.radioButton6.TextColor = Define.ColorNoneSelected;
        }
        private void radioButton6_Click(object sender, EventArgs e)
        {
            this.radioButton1.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton2.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton3.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton4.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton5.RadioBackColor = Define.ColorNoneSelected;
            this.radioButton6.RadioBackColor = Define.ColorSelected;

            this.radioButton1.TextColor = Define.ColorNoneSelected;
            this.radioButton2.TextColor = Define.ColorNoneSelected;
            this.radioButton3.TextColor = Define.ColorNoneSelected;
            this.radioButton4.TextColor = Define.ColorNoneSelected;
            this.radioButton5.TextColor = Define.ColorNoneSelected;
            this.radioButton6.TextColor = Define.ColorSelected;
        }

        private void smartTimerMessageShow_Tick(object sender, EventArgs e)
        {
            this.smartTimerMessageShow.Stop();

            DialogFormMessage msg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.LANGUAGE, this.MessageBoxRange);
            msg.ShowDialog();
        }
        #endregion
    }
}
