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

using SmartX;
using INT69DC_7C.DialogForms;
using INT69DC_7C.Controls;
using INT69DC_ImageDll;

namespace INT69DC_7C.Forms
{
    public partial class FormSystemSetting : Form
    {
        #region Field
        private FormMain m_ParentForm;

        private bool IsHanyoung;
        public int SelectedProductNo;
        private string BeforeName;
        private string BeforeLot;

        private ProductItem SelectedProductItem;
        public JudgmentSetItem SelectedJudgmentSetItem;
        private JudgmentSetItem CaptureJudgmentSetItem;
        private FeedbackConfiguration SelectedFeedbackItem;

        private ControlChildformSystemSetting ChildControlSystem;
        #endregion

        #region Constructor
        public FormSystemSetting(FormMain parent)
        {
            InitializeComponent();

            this.ParentForm = parent;
        }
        #endregion

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

        #region Method
        private void InitializeDesign()
        {
            ImageDll images = new ImageDll();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
            {

            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                this.labelTitle.Text = "System settings";
                this.smartGroupBox1.Text = "Setting product";
                this.groupBoxJudgment.Text = "Setting judgment";

                this.buttonWeightReference.Text = "Reference";
                this.labelStaticJudgment.Text = "Result";
                this.labelStaticFilter.Text = "Filter";
                this.labelStaticJudgmentDelayTime.Text = "J.Delay";
                this.labelStaticDoubleDelayTime.Text = "Overlap";
                this.labelStaticJudgmentCount.Text = "J.Count";
                this.labelStaticDynamic.Text = "Dynamic";
                this.labelStaticFeedSpeed.Text = "Feed Speed";

                this.labelStaticSorterDelayTime.Text = "Sorter Delay";
                this.labelStaticSorterRunTime.Text = "Sorter Run";

                this.groupBoxConveyor.Text = "Conveyor settings";
                this.labelStaticRejectConveyor.Text = "Reject conveyor";
                this.labelStaticRejectConveyorDelayTime.Text = "Delay";
                this.labelStaticRejectConveyorRunTime.Text = "Run";
                this.labelStaticFeedingConveyor.Text = "Feeding conveyor";
                this.labelStaticFeedingDelayTime.Text = "Delay";
                this.labelStaticFeedingRunTime.Text = "Run";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                this.labelTitle.Text = "系统设定";
                this.smartGroupBox1.Text = "项目设置";
                this.groupBoxJudgment.Text = "判断设置";

                this.buttonWeightReference.Text = "参考价值";
                this.labelStaticJudgment.Text = "结果";
                this.labelStaticFilter.Text = "滤波器";
                this.labelStaticJudgmentDelayTime.Text = "判断延迟";
                this.labelStaticDoubleDelayTime.Text = "重复";
                this.labelStaticJudgmentCount.Text = "重复延迟";
                this.labelStaticDynamic.Text = "动态校正";
                this.labelStaticFeedSpeed.Text = "输送带速度";

                this.labelStaticSorterDelayTime.Text = "检测仪延误";
                this.labelStaticSorterRunTime.Text = "检测仪运行";

                this.groupBoxConveyor.Text = "输送带设置";
                this.labelStaticRejectConveyor.Text = "选别输送带";
                this.labelStaticRejectConveyorDelayTime.Text = "延迟时间";
                this.labelStaticRejectConveyorRunTime.Text = "运行时间";
                this.labelStaticFeedingConveyor.Text = "进料输送带";
                this.labelStaticFeedingDelayTime.Text = "延迟时间";
                this.labelStaticFeedingRunTime.Text = "运行时间";

                this.labelTitleNo.Text = "编号";
                this.labelTitleName.Text = "名称";
                this.labelTitleLOT.Text = "批号";

                this.buttonNameEdit.Text = this.buttonLotEdit.Text = "编辑";

                this.labelTitleWeight.Text = "重量";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
                this.labelTitle.Text = "Nastavení systému";
                this.smartGroupBox1.Text = "Nastavení produktu";
                this.groupBoxJudgment.Text = "Nastavení rozhodnutí";

                this.buttonWeightReference.Text = "Reference";
                this.labelStaticJudgment.Text = "Výsledek";
                this.labelStaticFilter.Text = "Filtrovat";
                this.labelStaticJudgmentDelayTime.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.labelStaticJudgmentDelayTime.Text = "Zpoždění rozhodnutí";
                this.labelStaticDoubleDelayTime.Text = "Přesah";
                this.labelStaticJudgmentCount.Text = "Počet rozhodnutí";
                this.labelStaticDynamic.Text = "Dynamická";
                this.labelStaticFeedSpeed.Text = "Conveyor Speed";

                this.labelStaticSorterDelayTime.Text = "třídění zpoždění";
                this.labelStaticSorterRunTime.Text = "třídič běh";

                this.groupBoxConveyor.Text = "Nastavení dopravníku";
                this.labelStaticRejectConveyor.Text = "Vyřazení dopravníku";
                this.labelStaticRejectConveyorDelayTime.Text = "Doba zpoždění";
                this.labelStaticRejectConveyorRunTime.Text = "Doba chodu";
                this.labelStaticFeedingConveyor.Text = "Podávací dopravník";
                this.labelStaticFeedingDelayTime.Text = "Doba zpoždění";
                this.labelStaticFeedingRunTime.Text = "Doba chodu";

                this.buttonNameEdit.Text = this.buttonLotEdit.Text = "Editovat";
                this.labelTitleNo.Text = "Počet";
                this.labelTitleName.Text = "Jméno";
                this.labelTitleWeight.Text = "Hmotnost";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormSystemUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                this.labelTitle.Text = "Systemeinstellung";
                this.smartGroupBox1.Text = "Produkteinstellung";
                this.groupBoxJudgment.Text = "Tascheneinstellung";

                this.buttonWeightReference.Text = "Referenz";
                this.labelStaticJudgment.Text = "Ergebnis";
                this.labelStaticFilter.Text = "Filter";
                this.labelStaticJudgmentDelayTime.Text = "Taschenverzögerung";
                this.labelStaticDoubleDelayTime.Text = "Überlappung";
                this.labelStaticJudgmentCount.Text = "Taschennummer";
                this.labelStaticDynamic.Text = "Dynamische Konstante";
                this.labelStaticFeedSpeed.Text = "Geschwindigkeit";

                this.labelStaticSorterDelayTime.Text = "Sortierverzögerung";
                this.labelStaticSorterRunTime.Text = "Sorter ausführen";

                this.groupBoxConveyor.Text = "Förderereinstellung";
                this.labelStaticRejectConveyor.Text = "Aussortierförderer";
                this.labelStaticRejectConveyorDelayTime.Text = "Vezögerung";
                this.labelStaticRejectConveyorRunTime.Text = "Laufzeit";
                this.labelStaticFeedingConveyor.Text = "Zuführförderer";
                this.labelStaticFeedingDelayTime.Text = "Vezögerung";
                this.labelStaticFeedingRunTime.Text = "Laufzeit";

                this.buttonNameEdit.Text = this.buttonLotEdit.Text = "Bearbeiten";
                this.labelTitleNo.Text = "Nummer";
                this.labelTitleName.Text = "Name";
                this.labelTitleWeight.Text = "Gewicht";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormSystemUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Japanese)
            {
                this.labelTitle.Text = "システム設定";
                this.smartGroupBox1.Text = "製品設定";
                this.groupBoxJudgment.Text = "判定設定";

                this.labelTitleNo.Text = "番号";
                this.labelTitleName.Text = "名称";
                this.labelTitleLOT.Text = "ロット";
                this.buttonNameEdit.Text = "編集";
                this.buttonLotEdit.Text = "編集";

                this.buttonWeightReference.Text = "基準";
                this.labelStaticJudgment.Text = "結果";
                this.labelStaticFilter.Text = "フィルタㅡ";
                this.labelStaticJudgmentDelayTime.Text = "判定遅延";
                this.labelStaticDoubleDelayTime.Text = "二重遅延";
                this.labelStaticJudgmentCount.Text = "判定数";
                this.labelStaticDynamic.Text = "動的定数";
                this.labelStaticFeedSpeed.Text = "速度";

                this.labelStaticSorterDelayTime.Text = "ソㅡタㅡ遅延";
                this.labelStaticSorterRunTime.Text = "ソㅡタㅡ運転";

                this.groupBoxConveyor.Text = "コンベアの設定";
                this.labelStaticRejectConveyor.Text = "排出コンベア";
                this.labelStaticRejectConveyorDelayTime.Text = "遅延時間";
                this.labelStaticRejectConveyorRunTime.Text = "運転時間";
                this.labelStaticFeedingConveyor.Text = "供給コンベア";
                this.labelStaticFeedingDelayTime.Text = "遅延時間";
                this.labelStaticFeedingRunTime.Text = "運転時間";

                this.labelTitleWeight.Text = "重量";

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemUnderUp));
            }
            else
            {

            }
        }
        private void InitializeControl()
        {
            this.ChildControlSystem = new ControlChildformSystemSetting(this);

            this.Controls.Add(this.ChildControlSystem);

            this.ChildControlSystem.Location = new Point(0, 73);
            this.ChildControlSystem.Visible = false;
            this.ChildControlSystem.BringToFront();

        }
        private void DefaultSetting()
        {
            this.IsHanyoung = false;
            this.BeforeName = "";
            this.BeforeLot = "";

            this.comboBoxLine.Items.Clear();
            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                this.comboBoxLine.Items.Add(i + 1);

            // V1.0.7 임시 추가
            // 다음 버전에서 업데이트 할것
            if (this.ParentForm.SystemConfig.EquipmentMode == 2)
            {
                this.labelImpellerDelayTime.Visible = false;
                this.labelTitleImpellerDelayTime.Visible = false;
            }
            else
            {
                this.labelImpellerDelayTime.Visible = false;
                this.labelTitleImpellerDelayTime.Visible = false;
            }

            this.labelFilter.Text = "-";
            this.labelJudgmentDelayTime.Text = "-";
            this.labelDoubleDelayTime.Text = "-";
            this.labelJudgmentCount.Text = "-";
            this.labelDynamicCorrection.Text = "-";
            this.labelSorterDelayTime.Text = "-";
            this.labelSorterRunTime.Text = "-";
            this.labelRejectConveyorDelayTime.Text = "-";
            this.labelRejectConveyorRunTime.Text = "-";
            this.labelFeedingConveyorDelayTime.Text = "-";
            this.labelFeedingConveyorRunTime.Text = "-";
            this.labelWeightReference.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelWeightJudgment.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelADCValue.Text = "-";
            this.labelWeightValue.Text = "-";

            this.comboBoxLine.SelectedIndex = 0;
            this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);

            this.SelectedProductItem = new ProductItem();
            this.SelectedJudgmentSetItem = new JudgmentSetItem();
            this.CaptureJudgmentSetItem = new JudgmentSetItem();
            this.SelectedFeedbackItem = new FeedbackConfiguration();

            this.textBoxProductName.MaxLength = 20;
            this.textBoxLotNo.MaxLength = 10;

            this.labelItemNo.Text = this.ParentForm.SystemConfig.ProductNumber.ToString();
            this.SelectedProductNo = this.ParentForm.SystemConfig.ProductNumber;

            this.listBoxProductList.SelectedIndexChanged -= new EventHandler(this.listBoxProductList_SelectedIndexChanged);
            this.AddProductList();
            this.listBoxProductList.SelectedIndexChanged += new EventHandler(this.listBoxProductList_SelectedIndexChanged);
            this.listBoxProductList.SelectedIndex = this.SelectedProductNo - 1;

            this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.SelectedProductNo - 1);
            this.DisplayControls(this.SelectedProductItem);

            this.ParentForm.LoadJudgmentSetFile(ref this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);
            this.DisplayControls(this.SelectedJudgmentSetItem);

            this.ParentForm.LoadFeedbackItemFile(ref this.SelectedFeedbackItem, this.SelectedProductNo - 1);

            if (this.ParentForm.EquipmentStatus == DataStore.EquipmentStatus.Stop)
            {
                this.pictureBoxStop.Visible = true;
                this.pictureBoxStart.Visible = false;
            }
            else
            {
                this.pictureBoxStop.Visible = false;
                this.pictureBoxStart.Visible = true;
            }
        }

        public void DisplayRefresh()
        {
            this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormSystemSetting;

            if (this.comboBoxLine.Items == null || this.comboBoxLine.Items.Count == 0)
                return;

            this.smartDraw.PutDataAllClear();

            this.labelWeightReference.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelWeightJudgment.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.SystemConfig.DecimalPlaces);

            this.comboBoxLine.SelectedIndex = 0;
            this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);

            this.labelItemNo.Text = this.ParentForm.SystemConfig.ProductNumber.ToString();
            this.SelectedProductNo = this.ParentForm.SystemConfig.ProductNumber;

            this.listBoxProductList.SelectedIndex = this.SelectedProductNo - 1;

            this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.SelectedProductNo - 1);
            this.DisplayControls(this.SelectedProductItem);

            this.ParentForm.LoadJudgmentSetFile(ref this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);
            this.DisplayControls(this.SelectedJudgmentSetItem);

            this.buttonCopy.Text = "00";
            this.CaptureJudgmentSetItem = new JudgmentSetItem();
            
            // 전체 NG 지연시간 읽기
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._5013_ImpellerDelayTime, "");
        }

        public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
        {
            if (status == DataStore.EquipmentStatus.Start)
            {
                this.pictureBoxStart.Visible = true;
                this.pictureBoxStop.Visible = false;
                this.buttonBack.Enabled = false;
                this.labelItemNo.Enabled = false;
                this.comboBoxLine.Enabled = false;
            }
            else
            {
                this.smartDraw.PutDataAllClear();
                this.pictureBoxStart.Visible = false;
                this.pictureBoxStop.Visible = true;
                this.buttonBack.Enabled = true;
                this.labelItemNo.Enabled = true;
                this.comboBoxLine.Enabled = true;
            }
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";

            switch (this.comboBoxLine.SelectedIndex)
            {
                case 0:
                    value = Helper.DoubleToString(weightDatas[0].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[0].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 1:
                    value = Helper.DoubleToString(weightDatas[1].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[1].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 2:
                    value = Helper.DoubleToString(weightDatas[2].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[2].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 3:
                    value = Helper.DoubleToString(weightDatas[3].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[3].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 4:
                    value = Helper.DoubleToString(weightDatas[4].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[4].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 5:
                    value = Helper.DoubleToString(weightDatas[5].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[5].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 6:
                    value = Helper.DoubleToString(weightDatas[6].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[6].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 7:
                    value = Helper.DoubleToString(weightDatas[7].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[7].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 8:
                    value = Helper.DoubleToString(weightDatas[8].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[8].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 9:
                    value = Helper.DoubleToString(weightDatas[9].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[9].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 10:
                    value = Helper.DoubleToString(weightDatas[10].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[10].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                case 11:
                    value = Helper.DoubleToString(weightDatas[11].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                    if (this.labelWeightValue.Text != value)
                        this.labelWeightValue.Text = value;

                    value = weightDatas[11].ADCValue;
                    if (this.labelADCValue.Text != value)
                        this.labelADCValue.Text = value;
                    break;
                default:
                    break;
            }
        }
        public void UpdateGraphDataDisplay(DataStore.EquipmentStatus status, WeightData weightData, Collection<int> values)
        {
            int iValue = 0, temp = 0, inputValue = 0;
            string sValue = "";

            sValue = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeightJudgment.Text != sValue)
                this.labelWeightJudgment.Text = sValue;

            this.smartDraw.PutDataAllClear();

            sValue = this.labelWeightReference.Text.Replace(".", "");
            iValue = int.Parse(sValue);
            temp = 120 - iValue;

            for (int i = 0; i < values.Count; i++)
            {
                inputValue = values[i] + temp;

                if (inputValue > 240)
                    inputValue = 240;
                else if (inputValue < 0)
                    inputValue = 1;

                this.smartDraw.PutData(inputValue);
            }
        }
        public void UpdateItemNoDisplay(DataStore.EquipmentStatus status, ProductItem pItem, JudgmentSetItem jItem)
        {
            if (this.SelectedJudgmentSetItem == null && this.SelectedJudgmentSetItem == null)
                return;

            #region Judgment Item
            this.SelectedJudgmentSetItem.Filter = jItem.Filter;
            this.SelectedJudgmentSetItem.JudgmentDelayTime = jItem.JudgmentDelayTime;
            this.SelectedJudgmentSetItem.DoubleDelayTime = jItem.DoubleDelayTime;
            this.SelectedJudgmentSetItem.JudgmentCount = jItem.JudgmentCount;
            this.SelectedJudgmentSetItem.FeedSpeed = jItem.FeedSpeed;
            this.SelectedJudgmentSetItem.DynamicCorrection = jItem.DynamicCorrection;
            this.SelectedJudgmentSetItem.ForcedZeroDelayTime = jItem.ForcedZeroDelayTime;

            this.SelectedJudgmentSetItem.RejectConveyorDelayTime = jItem.RejectConveyorDelayTime;
            this.SelectedJudgmentSetItem.RejectConveyorRunTime = jItem.RejectConveyorRunTime;
            this.SelectedJudgmentSetItem.FeedingConveyorDelayTime = jItem.FeedingConveyorDelayTime;
            this.SelectedJudgmentSetItem.FeedingConveyorRunTime = jItem.FeedingConveyorRunTime;

            this.SelectedJudgmentSetItem.Sorter1Mode = jItem.Sorter1Mode;
            this.SelectedJudgmentSetItem.Sorter1DelayTime = jItem.Sorter1DelayTime;
            this.SelectedJudgmentSetItem.Sorter1RunTime = jItem.Sorter1RunTime;
            this.SelectedJudgmentSetItem.Sorter2Mode = jItem.Sorter2Mode;
            this.SelectedJudgmentSetItem.Sorter2DelayTime = jItem.Sorter2DelayTime;
            this.SelectedJudgmentSetItem.Sorter2RunTime = jItem.Sorter2RunTime;
            this.SelectedJudgmentSetItem.Sorter3Mode = jItem.Sorter3Mode;
            this.SelectedJudgmentSetItem.Sorter3DelayTime = jItem.Sorter3DelayTime;
            this.SelectedJudgmentSetItem.Sorter3RunTime = jItem.Sorter3RunTime;
            this.SelectedJudgmentSetItem.Sorter4Mode = jItem.Sorter4Mode;
            this.SelectedJudgmentSetItem.Sorter4DelayTime = jItem.Sorter4DelayTime;
            this.SelectedJudgmentSetItem.Sorter4RunTime = jItem.Sorter4RunTime;
            #endregion

            #region Product Item
            this.SelectedProductItem.LotNo = pItem.LotNo;
            this.SelectedProductItem.Name = pItem.Name;
            this.SelectedProductItem.Number = pItem.Number;
            this.SelectedProductItem.OverRange = pItem.OverRange;
            this.SelectedProductItem.PassRange = pItem.PassRange;
            this.SelectedProductItem.UnderRange = pItem.UnderRange;
            this.SelectedProductItem.TareRange = pItem.TareRange;
            #endregion

            this.DisplayControls(this.SelectedJudgmentSetItem);
            this.DisplayControls(this.SelectedProductItem);
        }
        public void UpdateP5013Display(DataStore.EquipmentStatus status, string value)
        {
            if (this.labelImpellerDelayTime.Text != value)
                this.labelImpellerDelayTime.Text = value;
        }

        #region 품목설정
        private void AddProductList()
        {
            this.listBoxProductList.Items.Clear();

            for (int i = 0; i < this.ParentForm.CollectionProductName.Count; i++)
                this.listBoxProductList.Items.Add(this.ParentForm.CollectionProductName[i]);
        }
        private void DisplayControls(ProductItem item)
        {
            if (this.SelectedProductItem == null && item == null)
                return;

            this.labelItemNo.Text = item.Number.ToString();
            this.textBoxProductName.Text = item.Name;
            this.textBoxLotNo.Text = item.LotNo;
            this.buttonOver.Text = Helper.StringToDecimalPlaces(item.OverRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonPass.Text = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonUnder.Text = Helper.StringToDecimalPlaces(item.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonTare.Text = Helper.StringToDecimalPlaces(item.TareRange, this.ParentForm.SystemConfig.DecimalPlaces);
        }
        #endregion

        #region 판정설정
        public void DrawInitialize()
        {
            SmartX.SmartDraw.CHARTREFRESH charRefreshType = SmartX.SmartDraw.CHARTREFRESH.NORMAL;
            SmartX.SmartDraw.CHARTPENSTYLE[] charPenStyle;
            charPenStyle = new SmartX.SmartDraw.CHARTPENSTYLE[1];
            charPenStyle[0].m_chColor = Color.Yellow;
            charPenStyle[0].m_iPenWidth = 2;

            this.smartDraw.SetChartCfg(33, 260, 400, 240, 4, charRefreshType, 1);
            this.smartDraw.ChartChannelPenStyle = charPenStyle;
            this.smartDraw.ChartDrawStep = 1;
        }
        public void GraphBackRedraw()
        {
            int xx, yy;

            this.smartDraw.PutDataAllClear();

            this.DrawInitialize();

            this.smartDraw.BackDraw.BackErase(Color.Black);

            // 가로선
            this.smartDraw.BackDraw.SetPenStyle(Color.Gray, 1);
            this.smartDraw.BackDraw.Line(30, 100, 427, 100);
            this.smartDraw.BackDraw.Line(30, 180, 427, 180);

            // 세로선 
            this.smartDraw.BackDraw.SetPenStyle(Color.Blue, 3);
            this.smartDraw.BackDraw.Line(30, 20, 30, 260);
            this.smartDraw.BackDraw.Line(427, 20, 427, 260);

            // 가로중심선
            this.smartDraw.BackDraw.SetPenStyle(Color.Blue, 1);
            this.smartDraw.BackDraw.Line(30, 140, 427, 140);

            // 판정개수 표시선
            xx = int.Parse(this.labelJudgmentCount.Text);
            yy = 430 - (xx * 4);
            this.smartDraw.BackDraw.SetPenStyle(Color.Red, 1);
            this.smartDraw.BackDraw.Line(yy, 40, yy, 240);
        }

        private void DisplayControls(JudgmentSetItem item)
        {
            string sValue = "";

            if (item == null)
                return;

            sValue = item.Filter.ToString();
            if (this.labelFilter.Text != sValue)
                this.labelFilter.Text = sValue;

            sValue = item.JudgmentDelayTime.ToString();
            if (this.labelJudgmentDelayTime.Text != sValue)
                this.labelJudgmentDelayTime.Text = sValue;

            sValue = item.DoubleDelayTime.ToString();
            if (this.labelDoubleDelayTime.Text != sValue)
                this.labelDoubleDelayTime.Text = sValue;

            sValue = item.JudgmentCount.ToString();
            if (this.labelJudgmentCount.Text != sValue)
                this.labelJudgmentCount.Text = sValue;

            sValue = item.FeedSpeed.ToString();
            if (this.labelFeedSpeed.Text != sValue)
                this.labelFeedSpeed.Text = sValue;

            sValue = string.Format("{0:f6}", item.DynamicCorrection);
            if (this.labelDynamicCorrection.Text != sValue)
                this.labelDynamicCorrection.Text = sValue;

            sValue = item.Sorter1DelayTime.ToString();
            if (this.labelSorterDelayTime.Text != sValue)
                this.labelSorterDelayTime.Text = sValue;

            sValue = item.Sorter1RunTime.ToString();
            if (this.labelSorterRunTime.Text != sValue)
                this.labelSorterRunTime.Text = sValue;

            sValue = item.RejectConveyorDelayTime.ToString();
            if (this.labelRejectConveyorDelayTime.Text != sValue)
                this.labelRejectConveyorDelayTime.Text = sValue;

            sValue = item.RejectConveyorRunTime.ToString();
            if (this.labelRejectConveyorRunTime.Text != sValue)
                this.labelRejectConveyorRunTime.Text = sValue;

            sValue = item.FeedingConveyorDelayTime.ToString();
            if (this.labelFeedingConveyorDelayTime.Text != sValue)
                this.labelFeedingConveyorDelayTime.Text = sValue;

            sValue = item.FeedingConveyorRunTime.ToString();
            if (this.labelFeedingConveyorRunTime.Text != sValue)
                this.labelFeedingConveyorRunTime.Text = sValue;

            this.GraphBackRedraw();
        }
        #endregion
        #endregion

        #region Override Member
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.InitializeDesign();
            this.InitializeControl();
            this.DefaultSetting();
        }
        #endregion

        #region Event Handler
        private void buttonBack_Click(object sender, EventArgs e)
        {
            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
        }

        private void labelItemNo_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.labelItemNo.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelItemNo.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 1000)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelItemNo.Text = this.labelItemNo.Text = myKeyPad.StringValue;
                    this.SelectedProductNo = myKeyPad.IntValue;
                    after = this.labelItemNo.Text;

                    this.listBoxProductList.SelectedIndexChanged -= new EventHandler(this.listBoxProductList_SelectedIndexChanged);
                    this.listBoxProductList.SelectedIndex = this.SelectedProductNo - 1;
                    this.listBoxProductList.SelectedIndexChanged += new EventHandler(this.listBoxProductList_SelectedIndexChanged);

                    this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.SelectedProductNo - 1);
                    this.ParentForm.LoadJudgmentSetFile(ref this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);
                    this.ParentForm.LoadFeedbackItemFile(ref this.SelectedFeedbackItem, this.SelectedProductNo - 1);

                    this.labelItemNo.Text = "**";
                    this.ParentForm.TransferProductParameter(this.SelectedProductNo);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ProductNumber, "", before, after);
                }
            }
        }

        #region 품목설정
        private void listBoxProductList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string before = "", after = "";

            if (this.listBoxProductList.SelectedItem == null)
                return;

            before = this.SelectedProductNo.ToString();

            this.SelectedProductNo = this.listBoxProductList.SelectedIndex + 1;
            this.labelItemNo.Text = this.SelectedProductNo.ToString();
            after = this.SelectedProductNo.ToString();

            this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.SelectedProductNo - 1);
            this.ParentForm.LoadJudgmentSetFile(ref this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);
            this.ParentForm.LoadFeedbackItemFile(ref this.SelectedFeedbackItem, this.SelectedProductNo - 1);

            this.labelItemNo.Text = "**";
            this.ParentForm.TransferProductParameter(this.SelectedProductNo);

            // Part 11
            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ProductNumber, "", before, after);
        }

        private void smartKeyboard_OnXKeyClick(object sender, EventArgs e)
        {
            this.smartKeyboard.Hide();
            this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.listBoxProductList.SelectedIndex);
            this.DisplayControls(this.SelectedProductItem);
            this.buttonNameEdit.Enabled = true;
            this.buttonLotEdit.Enabled = true;
            this.textBoxProductName.Enabled = true;
            this.textBoxLotNo.Enabled = true;
        }
        private void smartKeyboard_OnHanYoungKeyChange(object sender, EventArgs e)
        {
            if (this.IsHanyoung == false)
                this.IsHanyoung = true;
            else
                this.IsHanyoung = false;
        }

        private void textBoxProductName_KeyPress(object sender, KeyPressEventArgs e)
        {
            string after = "", number = "";

            if (e.KeyChar == '\r')
            {
                this.SelectedProductItem.Name = this.textBoxProductName.Text;
                this.ParentForm.CollectionProductName[this.SelectedProductItem.Number - 1] = this.textBoxProductName.Text;

                this.listBoxProductList.SelectedIndexChanged -= new EventHandler(this.listBoxProductList_SelectedIndexChanged);
                this.listBoxProductList.Items.Insert(this.SelectedProductItem.Number - 1, this.textBoxProductName.Text);
                this.listBoxProductList.Items.RemoveAt(this.SelectedProductItem.Number);
                this.listBoxProductList.SelectedIndex = this.SelectedProductItem.Number - 1;
                this.listBoxProductList.SelectedIndexChanged += new EventHandler(this.listBoxProductList_SelectedIndexChanged);

                e.Handled = true;
                this.smartKeyboard.Hide();

                this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                this.buttonNameEdit.Enabled = true;
                this.buttonLotEdit.Enabled = true;
                this.textBoxLotNo.Enabled = true;

                if (this.IsHanyoung == true)
                {
                    this.smartKeyboard.HanYoungKeyToggle();
                    this.IsHanyoung = false;
                }

                // Part11
                if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                {
                    after = this.textBoxProductName.Text;
                    number = this.SelectedProductItem.Number.ToString();

                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ChangeName, number, this.BeforeName, after);
                }
            }
            else if (e.KeyChar == 27)
            {
                e.Handled = true;
                this.smartKeyboard.Hide();
                this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.listBoxProductList.SelectedIndex);
                this.DisplayControls(this.SelectedProductItem);

                this.buttonNameEdit.Enabled = true;
                this.buttonLotEdit.Enabled = true;
                this.textBoxLotNo.Enabled = true;
            }
            else if (e.KeyChar == '<' || e.KeyChar == '>' || e.KeyChar == '|' || e.KeyChar == '"' || e.KeyChar == '?'
                || e.KeyChar == '*' || e.KeyChar == ':' || e.KeyChar == '/' || e.KeyChar == '\\')
            {
                e.Handled = true;
            }
        }
        private void textBoxLotNo_KeyPress(object sender, KeyPressEventArgs e)
        {
            string after = "", number = "";

            if (e.KeyChar == '\r')
            {
                this.SelectedProductItem.LotNo = this.textBoxLotNo.Text;

                e.Handled = true;
                this.smartKeyboard.Hide();

                this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                this.buttonNameEdit.Enabled = true;
                this.buttonLotEdit.Enabled = true;
                this.textBoxProductName.Enabled = true;

                if (this.IsHanyoung == true)
                {
                    this.smartKeyboard.HanYoungKeyToggle();
                    this.IsHanyoung = false;
                }

                // Part11
                if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                {
                    after = this.textBoxLotNo.Text;
                    number = this.SelectedProductItem.Number.ToString();

                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ChangeLOT, number, this.BeforeLot, after);
                }
            }
            else if (e.KeyChar == 27)
            {
                e.Handled = true;
                this.smartKeyboard.Hide();
                this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.listBoxProductList.SelectedIndex);
                this.DisplayControls(this.SelectedProductItem);

                this.buttonNameEdit.Enabled = true;
                this.buttonLotEdit.Enabled = true;
                this.textBoxProductName.Enabled = true;
            }
            else if (e.KeyChar == '<' || e.KeyChar == '>' || e.KeyChar == '|' || e.KeyChar == '"' || e.KeyChar == '?'
                || e.KeyChar == '*' || e.KeyChar == ':' || e.KeyChar == '/' || e.KeyChar == '\\')
            {
                e.Handled = true;
            }
        }

        private void buttonNameEdit_Click(object sender, EventArgs e)
        {
            this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
            this.smartKeyboard.Location = new Point(8, 237);
            this.smartKeyboard.Size = new Size(1000, 530);
            this.smartKeyboard.Hide();

            this.smartKeyboard.TargetInputObject = this.textBoxProductName;
            this.smartKeyboard.Show();

            this.textBoxProductName.Select(this.textBoxProductName.Text.Length, 0);

            this.buttonNameEdit.Enabled = false;
            this.buttonLotEdit.Enabled = false;
            this.textBoxLotNo.Enabled = false;

            this.BeforeName = this.textBoxProductName.Text;
        }
        private void buttonLotEdit_Click(object sender, EventArgs e)
        {
            this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
            this.smartKeyboard.Location = new Point(8, 237);
            this.smartKeyboard.Size = new Size(1000, 530);
            this.smartKeyboard.Hide();

            this.smartKeyboard.TargetInputObject = this.textBoxLotNo;
            this.smartKeyboard.Show();

            this.textBoxLotNo.Select(this.textBoxLotNo.Text.Length, 0);

            this.buttonNameEdit.Enabled = false;
            this.buttonLotEdit.Enabled = false;
            this.textBoxProductName.Enabled = false;

            this.BeforeLot = this.textBoxLotNo.Text;
        }
        private void buttonUnder_Click(object sender, EventArgs e)
        {
            int underRange = 0, passRange = 0, lowLimit = 0, deadZone = 0, deadZoneLow = 0;
            string before = "", after = "", number = "";

            before = this.buttonUnder.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonUnder.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue > Helper.StringToWeight(this.SelectedProductItem.PassRange.ToString(), this.ParentForm.SystemConfig.DecimalPlaces))
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.buttonUnder.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.UnderRange = myKeyPad.StringValue.Replace(".", "");
                    after = this.buttonUnder.Text;

                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRange, number, before, after);

                    // Feedback Setting
                    underRange = int.Parse(this.SelectedProductItem.UnderRange);
                    passRange = int.Parse(this.SelectedProductItem.PassRange);
                    lowLimit = int.Parse(this.SelectedFeedbackItem.LowLimit);
                    deadZone = int.Parse(this.SelectedFeedbackItem.DeadZone);
                    deadZoneLow = passRange - deadZone;

                    if (underRange > lowLimit)
                    {
                        //this.ParentForm.CurrentFeedbackItem.LowLimit = this.ParentForm.CurrentProductItem.UnderRange;

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // 피드백 설정 확인하세요!
                            // Low Limit Range
                            DialogFormMessage myMsg = new DialogFormMessage(15, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }

                    if (underRange > deadZoneLow)
                    {
                        before = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        this.SelectedFeedbackItem.DeadZone = "0";
                        this.ParentForm.SaveFeedbackItemFile(this.SelectedFeedbackItem, this.SelectedProductItem.Number - 1);

                        after = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // Part 11
                            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FB_DeadZone, number, before, after);

                            // 피드백 설정 확인하세요!
                            // DeadZone Range
                            DialogFormMessage myMsg = new DialogFormMessage(12, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }
                }
            }
        }
        private void buttonPass_Click(object sender, EventArgs e)
        {
            int passRange = 0, lowLimit = 0, highLimit = 0, deadZone = 0, deadZoneLow = 0, deadZoneHigh = 0;
            string before = "", after = "", number = "";

            before = this.buttonPass.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonPass.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if ((myKeyPad.doubleValue > Helper.StringToWeight(this.SelectedProductItem.OverRange, this.ParentForm.SystemConfig.DecimalPlaces)) ||
                    (myKeyPad.doubleValue < Helper.StringToWeight(this.SelectedProductItem.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces)))
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.buttonPass.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.PassRange = myKeyPad.StringValue.Replace(".", "");
                    after = this.buttonPass.Text;

                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightPassRange, number, before, after);

                    // Feedback Setting
                    passRange = int.Parse(this.SelectedProductItem.PassRange);
                    lowLimit = int.Parse(this.SelectedFeedbackItem.LowLimit);
                    highLimit = int.Parse(this.SelectedFeedbackItem.HighLimit);
                    deadZone = int.Parse(this.SelectedFeedbackItem.DeadZone);
                    deadZoneLow = passRange - deadZone;
                    deadZoneHigh = passRange + deadZone;

                    if (deadZoneLow < lowLimit)
                    {
                        before = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        this.SelectedFeedbackItem.DeadZone = "0";
                        this.ParentForm.SaveFeedbackItemFile(this.SelectedFeedbackItem, this.SelectedProductItem.Number - 1);

                        after = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // Part 11
                            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FB_DeadZone, number, before, after);

                            // 피드백 설정 확인하세요!
                            // DeadZone Range
                            DialogFormMessage myMsg = new DialogFormMessage(12, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }

                    if (passRange < lowLimit)
                    {
                        before = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.LowLimit, this.ParentForm.SystemConfig.DecimalPlaces);

                        this.SelectedFeedbackItem.LowLimit = this.SelectedProductItem.UnderRange;
                        this.ParentForm.SaveFeedbackItemFile(this.SelectedFeedbackItem, this.SelectedProductItem.Number - 1);
                        
                        after = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.LowLimit, this.ParentForm.SystemConfig.DecimalPlaces);

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // Part 11
                            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FB_LowLimit, number, before, after);

                            // 피드백 설정 확인하세요!
                            // Low Limit Range
                            DialogFormMessage myMsg = new DialogFormMessage(15, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }

                    if (deadZoneHigh > highLimit)
                    {
                        before = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        this.SelectedFeedbackItem.DeadZone = "0";
                        this.ParentForm.SaveFeedbackItemFile(this.SelectedFeedbackItem, this.SelectedProductItem.Number - 1);

                        after = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // Part 11
                            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FB_DeadZone, number, before, after);

                            // 피드백 설정 확인하세요!
                            // DeadZone Range
                            DialogFormMessage myMsg = new DialogFormMessage(12, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }

                    if (passRange > highLimit)
                    {
                        before = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.HighLimit, this.ParentForm.SystemConfig.DecimalPlaces);

                        this.SelectedFeedbackItem.HighLimit = this.SelectedProductItem.OverRange;
                        this.ParentForm.SaveFeedbackItemFile(this.SelectedFeedbackItem, this.SelectedProductItem.Number - 1);

                        after = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.HighLimit, this.ParentForm.SystemConfig.DecimalPlaces);

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // Part 11
                            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FB_HightLimit, number, before, after);

                            // 피드백 설정 확인하세요!
                            // High Limit Range
                            DialogFormMessage myMsg = new DialogFormMessage(14, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }
                }
            }
        }
        private void buttonOver_Click(object sender, EventArgs e)
        {
            int overRange = 0, passRange = 0, highLimit = 0, deadZone = 0, deadZoneHigh = 0;
            string before = "", after = "", number = "";

            before = this.buttonOver.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonOver.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < Helper.StringToWeight(this.SelectedProductItem.PassRange.ToString(), this.ParentForm.SystemConfig.DecimalPlaces))
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.buttonOver.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.OverRange = myKeyPad.StringValue.Replace(".", "");
                    after = this.buttonOver.Text;

                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRange, number, before, after);

                    // Feedback Setting
                    overRange = int.Parse(this.SelectedProductItem.OverRange);
                    passRange = int.Parse(this.SelectedProductItem.PassRange);
                    highLimit = int.Parse(this.SelectedFeedbackItem.HighLimit);
                    deadZone = int.Parse(this.SelectedFeedbackItem.DeadZone);
                    deadZoneHigh = passRange + deadZone;

                    if (overRange < highLimit)
                    {
                        //this.ParentForm.CurrentFeedbackItem.HighLimit = this.ParentForm.CurrentProductItem.OverRange;

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // 피드백 설정 확인하세요!
                            // High Limit Range
                            DialogFormMessage myMsg = new DialogFormMessage(14, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }

                    if (overRange < deadZoneHigh)
                    {
                        before = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        this.SelectedFeedbackItem.DeadZone = "0";
                        this.ParentForm.SaveFeedbackItemFile(this.SelectedFeedbackItem, this.SelectedProductItem.Number - 1);
                      
                        after = Helper.StringToDecimalPlaces(this.SelectedFeedbackItem.DeadZone, this.ParentForm.SystemConfig.DecimalPlaces);

                        if (this.ParentForm.SystemConfig.Serial3Mode == 4)
                        {
                            // Part 11
                            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FB_DeadZone, number, before, after);

                            // 피드백 설정 확인하세요!
                            // DeadZone Range
                            DialogFormMessage myMsg = new DialogFormMessage(12, this.ParentForm.SystemConfig.Language);
                            myMsg.ShowDialog();
                        }
                    }
                }
            }
        }
        private void buttonTare_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

            before = this.buttonTare.Text;
            number = this.SelectedProductNo.ToString();
            
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonTare.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 99999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.buttonTare.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.TareRange = myKeyPad.StringValue.Replace(".", "");
                    after = this.buttonTare.Text;

                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightTareRange, number, before, after);
                }
            }
        }
        #endregion

        #region 판정설정
        private void labelFilter_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelFilter.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFilter.Text, 2, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 16)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelFilter.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Filter = myKeyPad.IntValue;
                    after = this.labelFilter.Text;

                    value = Helper.StringZeroFillDigits4(this.labelFilter.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5001_Filter, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentFilter, number, before, after);
                }
            }
        }
        private void labelJudgmentDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelJudgmentDelayTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelJudgmentDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelJudgmentDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.JudgmentDelayTime = myKeyPad.IntValue;
                    after = this.labelJudgmentDelayTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelJudgmentDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5002_JudgmentDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentDelayTime, number, before, after);
                }
            }
        }
        private void labelDoubleDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelDoubleDelayTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDoubleDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelDoubleDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.DoubleDelayTime = myKeyPad.IntValue;
                    after = this.labelDoubleDelayTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelDoubleDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5003_DoubleDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentDoubleDelayTime, number, before, after);
                }
            }
        }
        private void labelJudgmentCount_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelJudgmentCount.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelJudgmentCount.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 50)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelJudgmentCount.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.JudgmentCount = myKeyPad.IntValue;
                    after = this.labelJudgmentCount.Text;

                    this.GraphBackRedraw();

                    value = Helper.StringZeroFillDigits4(this.labelJudgmentCount.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5004_JudgmentCount, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentCount, number, before, after);
                }
            }
        }
        private void labelDynamicCorrection_Click(object sender, EventArgs e)
        {
            string value = "";

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDynamicCorrection.Text, 7, 6, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0.500000 || myKeyPad.doubleValue > 2.000000)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelDynamicCorrection.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.DynamicCorrection = myKeyPad.doubleValue;

                    value = string.Format("{0:f6}", this.labelDynamicCorrection.Text);
                    value = value.Remove(1, 1);
                    value = Helper.StringZeroFillDigits7(value);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5006_DynamicCorrection, value);

                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);
                }
            }
        }
        private void labelFeedSpeed_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelFeedSpeed.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFeedSpeed.Text, 1, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelFeedSpeed.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.FeedSpeed = myKeyPad.IntValue;
                    after = this.labelFeedSpeed.Text;

                    value = Helper.StringZeroFillDigits4(this.labelFeedSpeed.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5005_FeedSpeed, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentCVSpeed, number, before, after);
                }
            }
        }
        private void labelSorterDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelSorterDelayTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorterDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelSorterDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter1DelayTime = myKeyPad.IntValue;
                    after = this.labelSorterDelayTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelSorterDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5102_Sorter1DelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.SorterDelayTime, number, before, after);
                }
            }
        }
        private void labelSorterRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelSorterRunTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorterRunTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelSorterRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter1RunTime = myKeyPad.IntValue;
                    after = this.labelSorterRunTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelSorterRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5103_Sorter1RunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.SorterRunTime, number, before, after);
                }
            }
        }
        private void labelRejectConveyorDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelRejectConveyorDelayTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRejectConveyorDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelRejectConveyorDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.RejectConveyorDelayTime = myKeyPad.IntValue;
                    after = this.labelRejectConveyorDelayTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelRejectConveyorDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5009_DischargeConveyorDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.RejectCVDelayTime, number, before, after);
                }
            }
        }
        private void labelRejectConveyorRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelRejectConveyorRunTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRejectConveyorRunTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelRejectConveyorRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.RejectConveyorRunTime = myKeyPad.IntValue;
                    after = this.labelRejectConveyorRunTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelRejectConveyorRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5010_DischargeConveyorRunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.RejectCVRunTime, number, before, after);
                }
            }
        }
        private void labelFeedingConveyorDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelFeedingConveyorDelayTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFeedingConveyorDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelFeedingConveyorDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.FeedingConveyorDelayTime = myKeyPad.IntValue;
                    after = this.labelFeedingConveyorDelayTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelFeedingConveyorDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5007_FeedingConveyorDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FeedingCVDelayTime, number, before, after);
                }
            }
        }
        private void labelFeedingConveyorRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            before = this.labelFeedingConveyorRunTime.Text;
            number = this.SelectedProductNo.ToString();

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFeedingConveyorRunTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelFeedingConveyorRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.FeedingConveyorRunTime = myKeyPad.IntValue;
                    after = this.labelFeedingConveyorRunTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelFeedingConveyorRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._5008_FeedingConveyorRunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FeedingCVRunTime, number, before, after);
                }
            }
        }
        private void labelImpellerDelayTime_Click(object sender, EventArgs e)
        {
            string value = "";

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelImpellerDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelImpellerDelayTime.Text = myKeyPad.StringValue;


                    value = Helper.StringZeroFillDigits4(this.labelImpellerDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5013_ImpellerDelayTime, value);
                }
            }
        }

        private void buttonWeightReference_Click(object sender, EventArgs e)
        {
            if (this.labelWeightReference.Text != this.labelWeightValue.Text)
                this.labelWeightReference.Text = this.labelWeightValue.Text;
        }
        private void buttonCopy_Click(object sender, EventArgs e)
        {
            this.buttonCopy.Text = this.labelItemNo.Text;

            this.CaptureJudgmentSetItem.Filter = this.SelectedJudgmentSetItem.Filter;
            this.CaptureJudgmentSetItem.JudgmentDelayTime = this.SelectedJudgmentSetItem.JudgmentDelayTime;
            this.CaptureJudgmentSetItem.DoubleDelayTime = this.SelectedJudgmentSetItem.DoubleDelayTime;
            this.CaptureJudgmentSetItem.JudgmentCount = this.SelectedJudgmentSetItem.JudgmentCount;
            this.CaptureJudgmentSetItem.FeedSpeed = this.SelectedJudgmentSetItem.FeedSpeed;
            this.CaptureJudgmentSetItem.DynamicCorrection = this.SelectedJudgmentSetItem.DynamicCorrection;
            this.CaptureJudgmentSetItem.ForcedZeroDelayTime = this.SelectedJudgmentSetItem.ForcedZeroDelayTime;

            this.CaptureJudgmentSetItem.RejectConveyorDelayTime = this.SelectedJudgmentSetItem.RejectConveyorDelayTime;
            this.CaptureJudgmentSetItem.RejectConveyorRunTime = this.SelectedJudgmentSetItem.RejectConveyorRunTime;
            this.CaptureJudgmentSetItem.FeedingConveyorDelayTime = this.SelectedJudgmentSetItem.FeedingConveyorDelayTime;
            this.CaptureJudgmentSetItem.FeedingConveyorRunTime = this.SelectedJudgmentSetItem.FeedingConveyorRunTime;

            this.CaptureJudgmentSetItem.Sorter1Mode = this.SelectedJudgmentSetItem.Sorter1Mode;
            this.CaptureJudgmentSetItem.Sorter1DelayTime = this.SelectedJudgmentSetItem.Sorter1DelayTime;
            this.CaptureJudgmentSetItem.Sorter1RunTime = this.SelectedJudgmentSetItem.Sorter1RunTime;
            this.CaptureJudgmentSetItem.Sorter2Mode = this.SelectedJudgmentSetItem.Sorter2Mode;
            this.CaptureJudgmentSetItem.Sorter2DelayTime = this.SelectedJudgmentSetItem.Sorter2DelayTime;
            this.CaptureJudgmentSetItem.Sorter2RunTime = this.SelectedJudgmentSetItem.Sorter2RunTime;
            this.CaptureJudgmentSetItem.Sorter3Mode = this.SelectedJudgmentSetItem.Sorter3Mode;
            this.CaptureJudgmentSetItem.Sorter3DelayTime = this.SelectedJudgmentSetItem.Sorter3DelayTime;
            this.CaptureJudgmentSetItem.Sorter3RunTime = this.SelectedJudgmentSetItem.Sorter3RunTime;
            this.CaptureJudgmentSetItem.Sorter4Mode = this.SelectedJudgmentSetItem.Sorter4Mode;
            this.CaptureJudgmentSetItem.Sorter4DelayTime = this.SelectedJudgmentSetItem.Sorter4DelayTime;
            this.CaptureJudgmentSetItem.Sorter4RunTime = this.SelectedJudgmentSetItem.Sorter4RunTime;

            // Part11
            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.ProductCopy, this.buttonCopy.Text);
        }
        private void buttonPaste_Click(object sender, EventArgs e)
        {
            if (this.buttonCopy.Text == "00")
                return;

            this.SelectedJudgmentSetItem.Filter = this.CaptureJudgmentSetItem.Filter;
            this.SelectedJudgmentSetItem.JudgmentDelayTime = this.CaptureJudgmentSetItem.JudgmentDelayTime;
            this.SelectedJudgmentSetItem.DoubleDelayTime = this.CaptureJudgmentSetItem.DoubleDelayTime;
            this.SelectedJudgmentSetItem.JudgmentCount = this.CaptureJudgmentSetItem.JudgmentCount;
            this.SelectedJudgmentSetItem.FeedSpeed = this.CaptureJudgmentSetItem.FeedSpeed;
            this.SelectedJudgmentSetItem.DynamicCorrection = this.CaptureJudgmentSetItem.DynamicCorrection;
            this.SelectedJudgmentSetItem.ForcedZeroDelayTime = this.CaptureJudgmentSetItem.ForcedZeroDelayTime;

            this.SelectedJudgmentSetItem.RejectConveyorDelayTime = this.CaptureJudgmentSetItem.RejectConveyorDelayTime;
            this.SelectedJudgmentSetItem.RejectConveyorRunTime = this.CaptureJudgmentSetItem.RejectConveyorRunTime;
            this.SelectedJudgmentSetItem.FeedingConveyorDelayTime = this.CaptureJudgmentSetItem.FeedingConveyorDelayTime;
            this.SelectedJudgmentSetItem.FeedingConveyorRunTime = this.CaptureJudgmentSetItem.FeedingConveyorRunTime;

            this.SelectedJudgmentSetItem.Sorter1Mode = this.CaptureJudgmentSetItem.Sorter1Mode;
            this.SelectedJudgmentSetItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
            this.SelectedJudgmentSetItem.Sorter1RunTime = this.CaptureJudgmentSetItem.Sorter1RunTime;
            this.SelectedJudgmentSetItem.Sorter2Mode = this.CaptureJudgmentSetItem.Sorter2Mode;
            this.SelectedJudgmentSetItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
            this.SelectedJudgmentSetItem.Sorter2RunTime = this.CaptureJudgmentSetItem.Sorter2RunTime;
            this.SelectedJudgmentSetItem.Sorter3Mode = this.CaptureJudgmentSetItem.Sorter3Mode;
            this.SelectedJudgmentSetItem.Sorter3DelayTime = this.CaptureJudgmentSetItem.Sorter3DelayTime;
            this.SelectedJudgmentSetItem.Sorter3RunTime = this.CaptureJudgmentSetItem.Sorter3RunTime;
            this.SelectedJudgmentSetItem.Sorter4Mode = this.CaptureJudgmentSetItem.Sorter4Mode;
            this.SelectedJudgmentSetItem.Sorter4DelayTime = this.CaptureJudgmentSetItem.Sorter4DelayTime;
            this.SelectedJudgmentSetItem.Sorter4RunTime = this.CaptureJudgmentSetItem.Sorter4RunTime;

            this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

            this.labelItemNo.Text = "**";
            this.ParentForm.TransferProductParameter(this.SelectedProductNo);

            // Part11
            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.ProductPaste, this.SelectedProductNo.ToString());
        }
        private void buttonPasteAll_Click(object sender, EventArgs e)
        {
            string fullFilePath = "";
            StructJudgmentSetItem structItem;

            if (this.buttonCopy.Text == "00")
                return;

            SmartSplash splash = new SmartSplash();
            splash.CenterPosition = true;
            splash.AnimationInterval = 200;
            splash.LoadingImagePathname = "SmartLoading4";
            splash.Start();

            this.buttonBack.Enabled = false;
            this.buttonCopy.Enabled = false;
            this.buttonPaste.Enabled = false;
            this.buttonPasteAll.Enabled = false;

            this.SelectedJudgmentSetItem.Filter = this.CaptureJudgmentSetItem.Filter;
            this.SelectedJudgmentSetItem.JudgmentDelayTime = this.CaptureJudgmentSetItem.JudgmentDelayTime;
            this.SelectedJudgmentSetItem.DoubleDelayTime = this.CaptureJudgmentSetItem.DoubleDelayTime;
            this.SelectedJudgmentSetItem.JudgmentCount = this.CaptureJudgmentSetItem.JudgmentCount;
            this.SelectedJudgmentSetItem.FeedSpeed = this.CaptureJudgmentSetItem.FeedSpeed;
            this.SelectedJudgmentSetItem.DynamicCorrection = this.CaptureJudgmentSetItem.DynamicCorrection;
            this.SelectedJudgmentSetItem.ForcedZeroDelayTime = this.CaptureJudgmentSetItem.ForcedZeroDelayTime;

            this.SelectedJudgmentSetItem.RejectConveyorDelayTime = this.CaptureJudgmentSetItem.RejectConveyorDelayTime;
            this.SelectedJudgmentSetItem.RejectConveyorRunTime = this.CaptureJudgmentSetItem.RejectConveyorRunTime;
            this.SelectedJudgmentSetItem.FeedingConveyorDelayTime = this.CaptureJudgmentSetItem.FeedingConveyorDelayTime;
            this.SelectedJudgmentSetItem.FeedingConveyorRunTime = this.CaptureJudgmentSetItem.FeedingConveyorRunTime;

            this.SelectedJudgmentSetItem.Sorter1Mode = this.CaptureJudgmentSetItem.Sorter1Mode;
            this.SelectedJudgmentSetItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
            this.SelectedJudgmentSetItem.Sorter1RunTime = this.CaptureJudgmentSetItem.Sorter1RunTime;
            this.SelectedJudgmentSetItem.Sorter2Mode = this.CaptureJudgmentSetItem.Sorter2Mode;
            this.SelectedJudgmentSetItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
            this.SelectedJudgmentSetItem.Sorter2RunTime = this.CaptureJudgmentSetItem.Sorter2RunTime;
            this.SelectedJudgmentSetItem.Sorter3Mode = this.CaptureJudgmentSetItem.Sorter3Mode;
            this.SelectedJudgmentSetItem.Sorter3DelayTime = this.CaptureJudgmentSetItem.Sorter3DelayTime;
            this.SelectedJudgmentSetItem.Sorter3RunTime = this.CaptureJudgmentSetItem.Sorter3RunTime;
            this.SelectedJudgmentSetItem.Sorter4Mode = this.CaptureJudgmentSetItem.Sorter4Mode;
            this.SelectedJudgmentSetItem.Sorter4DelayTime = this.CaptureJudgmentSetItem.Sorter4DelayTime;
            this.SelectedJudgmentSetItem.Sorter4RunTime = this.CaptureJudgmentSetItem.Sorter4RunTime;

            fullFilePath = this.ParentForm.PathSystemFileFolder + "JudgmentSetItem.int";
            this.ParentForm.smartFileIO.FilePathName = fullFilePath;

            this.ParentForm.smartFileIO.Open(this.ParentForm.BufferSmartUart);

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.CaptureJudgmentSetItem.Filter;
                structItem.JudgmentDelayTime = this.CaptureJudgmentSetItem.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.CaptureJudgmentSetItem.DoubleDelayTime;
                structItem.JudgmentCount = this.CaptureJudgmentSetItem.JudgmentCount;
                structItem.FeedSpeed = this.CaptureJudgmentSetItem.FeedSpeed;
                structItem.DynamicCorrection = this.CaptureJudgmentSetItem.DynamicCorrection;

                structItem.DischargeConveyorDelayTime = this.CaptureJudgmentSetItem.RejectConveyorDelayTime;
                structItem.DischargeConveyorOperatingTime = this.CaptureJudgmentSetItem.RejectConveyorRunTime;
                structItem.FeedingConveyorDelayTime = this.CaptureJudgmentSetItem.FeedingConveyorDelayTime;
                structItem.FeedingConveyorOperatingTime = this.CaptureJudgmentSetItem.FeedingConveyorRunTime;

                structItem.Sorter1Mode = this.CaptureJudgmentSetItem.Sorter1Mode;
                structItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
                structItem.Sorter1OperatingTime = this.CaptureJudgmentSetItem.Sorter1RunTime;
                structItem.Sorter2Mode = this.CaptureJudgmentSetItem.Sorter2Mode;
                structItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
                structItem.Sorter2OperatingTime = this.CaptureJudgmentSetItem.Sorter2RunTime;
                structItem.Sorter3Mode = this.CaptureJudgmentSetItem.Sorter3Mode;
                structItem.Sorter3DelayTime = this.CaptureJudgmentSetItem.Sorter3DelayTime;
                structItem.Sorter3OperatingTime = this.CaptureJudgmentSetItem.Sorter3RunTime;
                structItem.Sorter4Mode = this.CaptureJudgmentSetItem.Sorter4Mode;
                structItem.Sorter4DelayTime = this.CaptureJudgmentSetItem.Sorter4DelayTime;
                structItem.Sorter4OperatingTime = this.CaptureJudgmentSetItem.Sorter4RunTime;

                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.ForcedZeroDelayTime = this.CaptureJudgmentSetItem.ForcedZeroDelayTime;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";

                this.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);
            }
            this.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.smartFileIO.Close();

            this.labelItemNo.Text = "**";
            this.ParentForm.TransferProductParameter(this.SelectedProductNo);

            this.buttonBack.Enabled = true;
            this.buttonCopy.Enabled = true;
            this.buttonPaste.Enabled = true;
            this.buttonPasteAll.Enabled = true;

            splash.Finish();

            // Part11
            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.ProductAllPaste, "");
        }

        private void comboBoxLine_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.comboBoxLine.Items.Count != this.ParentForm.SystemConfig.EquipmentColumns)
                return;

            switch (this.comboBoxLine.SelectedIndex)
            {
                case 0:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);
                    break;
                case 1:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard2);
                    break;
                case 2:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard3);
                    break;
                case 3:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard4);
                    break;
                case 4:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard5);
                    break;
                case 5:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard6);
                    break;
                case 6:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard7);
                    break;
                case 7:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard8);
                    break;
                case 8:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard9);
                    break;
                case 9:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard10);
                    break;
                case 10:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard11);
                    break;
                case 11:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard12);
                    break;
                default:
                    break;
            }

        }
        #endregion

        private void buttonSetting_Click(object sender, EventArgs e)
        {
            if (this.buttonSetting.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ChildControlSystem.DisplayRefresh(this.SelectedJudgmentSetItem);
                this.ChildControlSystem.Visible = true;
            }
            else
                this.ChildControlSystem.Visible = false;
        }
        #endregion
    }
}