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.Threading;
using System.Windows.Forms;

using SmartX;
using INT63DC_6CH.DialogForms;
using INT63DC_6CH.Controls;
using INT63DC_ImageDll;

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

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

        private ProductItem SelectedProductItem;
        public JudgmentSetItem SelectedJudgmentSetItem;
        private JudgmentSetItem CaptureJudgmentSetItem;
        #endregion

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

            this.ParentForm = parent;

            this.InitializeDesign();
            this.InitializeControl();
            this.DefaultSetting();
        }
        #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();
            Font font = new Font("New Gulim", 8F, FontStyle.Regular);

            switch (this.ParentForm.SystemConfig.Language)
            {
                case DataStore.E_LanguageID.Korean:
                    this.smartKeyboard.HanYoungKeyDisable = false;
                    break;
                case DataStore.E_LanguageID.English:
                    #region English
                    this.labelTitle.Text = "System settings";
                    this.groupBoxProduct.Text = "Setting product";
                    this.groupBoxJudgment.Text = "Setting Judgment";

                    this.labelStaticOverRange.Text = "Over";
                    this.labelStaticPassRange.Text = "Pass";
                    this.labelStaticUnderRange.Text = "Under";
                    this.labelStaticTareRange.Text = "Tare";
                    this.labelStaticOverRangeLimit.Text = "Over Limit";
                    this.labelStaticUnderRangeLimit.Text = "Under Limit";

                    this.buttonWeightReference.Text = "Reference";
                    this.labelStaticJudgment.Text = "Result";
                    this.labelStaticJudgmentDelayTime.Text = "J.Delay";
                    this.labelStaticTurnDelayTime.Text = "Turn Delay";
                    this.labelStaticJudgmentCount.Text = "J.count";
                    this.labelTitleFeedSpeed.Text = "Speed";
                    this.labelStaticSorter1DelayTime.Text = "Sorter1 Delay";
                    this.labelStaticSorter1RunTime.Text = "Sorter1 Run";
                    this.labelStaticSorter2DelayTime.Text = "Sorter2 Delay";
                    this.labelStaticSorter2RunTime.Text = "Sorter2 Run";
                    this.labelTitleEntryGate.Text = "Entry gate";
                    this.labelTitleEntryGateDelayTime.Text = "Delay time";
                    this.labelTitleEntryGateRunTime.Text = "Operating time";
                    this.labelTitleDischargeStopper.Text = "Discharge stopper";
                    this.labelTitleDischargeStopperDelayTime.Text = "Delay time";
                    this.labelTitleDischargeStopperRunTime.Text = "Operating time";

                    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)); 
                    #endregion
                    break;
                case DataStore.E_LanguageID.Chinese:
                    #region Chinese
                    this.labelTitle.Text = "系统设定";
                    this.groupBoxProduct.Text = "项目设置";
                    this.groupBoxJudgment.Text = "判断设置";

                    this.labelStaticOverRange.Text = "上限";
                    this.labelStaticPassRange.Text = "标准";
                    this.labelStaticUnderRange.Text = "下限";
                    this.labelStaticTareRange.Text = "皮重";
                    this.labelStaticOverRangeLimit.Text = "上极限报警";
                    this.labelStaticUnderRangeLimit.Text = "下极限报警";

                    this.buttonWeightReference.Text = "参考价值";
                    this.labelStaticJudgment.Text = "结果";
                    this.labelStaticJudgmentDelayTime.Text = "判断延迟";
                    this.labelStaticTurnDelayTime.Text = "旋转延迟";
                    this.labelStaticJudgmentCount.Text = "重复延迟";
                    this.labelTitleFeedSpeed.Text = "速度";
                    this.labelStaticSorter1DelayTime.Text = "分类机1 延迟时间";
                    this.labelStaticSorter1RunTime.Text = "分类机1 运行时间";
                    this.labelStaticSorter2DelayTime.Text = "分类机2 延迟时间";
                    this.labelStaticSorter2RunTime.Text = "分类机2 运行时间";

                    this.labelStaticNo.Text = "编号";
                    this.labelStaticName.Text = "名称";
                    this.labelStaticLOT.Text = "批号";

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

                    this.labelStaticWeight.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)); 
                    #endregion
                    break;
                case DataStore.E_LanguageID.Czech:
                    #region Czech
                    this.labelTitle.Text = "Nastavení systému";
                    this.groupBoxProduct.Text = "Nastavení produktu";
                    this.groupBoxJudgment.Text = "Nastavení rozhodnutí";

                    this.labelStaticOverRange.Text = "Max.";
                    this.labelStaticPassRange.Text = "Váha";
                    this.labelStaticUnderRange.Text = "Min.";
                    this.labelStaticTareRange.Text = "Tára";
                    this.labelStaticOverRangeLimit.Text = "Max. omezit";
                    this.labelStaticUnderRangeLimit.Text = "Min. omezit";

                    this.buttonWeightReference.Text = "Reference";
                    this.labelStaticJudgment.Text = "Výsledek";
                    this.labelStaticJudgmentDelayTime.Text = "Zpoždění kapsy";
                    this.labelStaticTurnDelayTime.Text = "Zpoždění rotace";
                    this.labelStaticJudgmentCount.Text = "Číslo kapsy";
                    this.labelTitleFeedSpeed.Text = "Rychlost";
                    this.labelStaticSorter1DelayTime.Font = font;
                    this.labelStaticSorter1DelayTime.Text = "Vyřazovač1 Zpoždění";
                    this.labelStaticSorter1RunTime.Font = font;
                    this.labelStaticSorter1RunTime.Text = "Vyřazovač1 Čas chodu";
                    this.labelStaticSorter2DelayTime.Font = font;
                    this.labelStaticSorter2DelayTime.Text = "Vyřazovač2 Zpoždění";
                    this.labelStaticSorter2RunTime.Font = font;
                    this.labelStaticSorter2RunTime.Text = "Vyřazovač2 Čas chodu";

                    this.buttonNameEdit.Text = this.buttonLotEdit.Text = "Editovat";
                    this.labelStaticNo.Text = "Počet";
                    this.labelStaticName.Text = "Jméno";
                    this.labelStaticWeight.Text = "Hmotnost";

                    this.pictureBoxStart.Image = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainStart));

                    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)); 
                    #endregion
                    break;
                case DataStore.E_LanguageID.German:
                    #region German
                    this.labelTitle.Text = "Systemeinstellung";
                    this.groupBoxProduct.Text = "Produkteinstellung";
                    this.groupBoxJudgment.Text = "Tascheneinstellung";

                    this.labelStaticOverRange.Text = "Max.";
                    this.labelStaticPassRange.Text = "Bestehen";
                    this.labelStaticUnderRange.Text = "Min.";
                    this.labelStaticTareRange.Text = "Tara";
                    this.labelStaticOverRangeLimit.Text = "Max. Grenze";
                    this.labelStaticUnderRangeLimit.Text = "Min. Grenze";

                    this.buttonWeightReference.Text = "Referenz";
                    this.labelStaticJudgment.Text = "Ergebnis";
                    this.labelStaticJudgmentDelayTime.Text = "Taschenverzögerung";
                    this.labelStaticTurnDelayTime.Text = "Rotationsverzögerung";
                    this.labelStaticJudgmentCount.Text = "Taschennummer";
                    this.labelTitleFeedSpeed.Text = "Geschw.";
                    this.labelStaticSorter1DelayTime.Font = font;
                    this.labelStaticSorter1DelayTime.Text = "Sortierer1 Vezögerung";
                    this.labelStaticSorter1RunTime.Font = font;
                    this.labelStaticSorter1RunTime.Text = "Sortierer1 Laufzeit";
                    this.labelStaticSorter2DelayTime.Font = font;
                    this.labelStaticSorter2DelayTime.Text = "Sortierer2 Vezögerung";
                    this.labelStaticSorter2RunTime.Font = font;
                    this.labelStaticSorter2RunTime.Text = "Sortierer2 Laufzeit";
                    this.labelTitleEntryGate.Text = "Eingangstors";
                    this.labelTitleEntryGateDelayTime.Text = "Verzögerungszeit";
                    this.labelTitleEntryGateRunTime.Text = "Betriebszeit";
                    this.labelTitleDischargeStopper.Text = "Entladestoppers";
                    this.labelTitleDischargeStopperDelayTime.Text = "Verzögerungszeit";
                    this.labelTitleDischargeStopperRunTime.Text = "Betriebszeit";

                    this.buttonNameEdit.Text = this.buttonLotEdit.Text = "Bearbeiten";
                    this.labelStaticNo.Text = "Nummer";
                    this.labelStaticName.Text = "Name";
                    this.labelStaticWeight.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)); 
                    #endregion
                    break;
                case DataStore.E_LanguageID.Japanese:
                    #region Japanese
                    this.labelTitle.Text = "システム設定";

                    this.groupBoxProduct.Text = "製品設定";
                    this.buttonNameEdit.Text = this.buttonLotEdit.Text = "編集者";
                    this.labelStaticNo.Text = "番号";
                    this.labelStaticName.Text = "名称";
                    this.labelStaticLOT.Text = "ロット";
                    this.labelStaticOverRange.Text = "上限";
                    this.labelStaticPassRange.Text = "合格";
                    this.labelStaticUnderRange.Text = "下限";
                    this.labelStaticTareRange.Text = "風袋";
                    //this.labelStaticOverRangeLimit.Font = font;
                    this.labelStaticOverRangeLimit.Text = "上限リミット";
                    //this.labelStaticUnderRangeLimit.Font = font;
                    this.labelStaticUnderRangeLimit.Text = "下限リミット";

                    this.groupBoxJudgment.Text = "判定設定";
                    this.buttonWeightReference.Text = "基準";
                    this.labelStaticWeight.Text = "重量";
                    this.labelStaticJudgment.Text = "結果";
                    this.labelStaticJudgmentDelayTime.Text = "判定の遅れ";
                    this.labelStaticTurnDelayTime.Text = "タㅡン遅延";
                    this.labelStaticJudgmentCount.Text = "判定番号";
                    this.labelTitleFeedSpeed.Text = "速度";
                    this.labelStaticSorter1DelayTime.Text = "ソㅡタㅡ1 遅延時間";
                    this.labelStaticSorter1RunTime.Text = "ソㅡタㅡ1 運転時間";
                    this.labelStaticSorter2DelayTime.Text = "ソㅡタㅡ2 遅延時間";
                    this.labelStaticSorter2RunTime.Text = "ソㅡタㅡ2 運転時間";

                    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));
                    #endregion
                    break;
                default:
                    break;
            }
        }
        private void InitializeControl()
        {
          
        }
        private void DefaultSetting()
        {
            this.BeforeName = "";
            this.BeforeLot = "";

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

            this.labelTurnDelayTime.Text = "-";
            this.labelJudgmentDelayTime.Text = "-";
            this.labelFeedSpeed.Text = "-";
            this.labelJudgmentCount.Text = "-";
            this.labelSorter1DelayTime.Text = "-";
            this.labelSorter1RunTime.Text = "-";
            this.labelSorter2DelayTime.Text = "-";
            this.labelSorter2RunTime.Text = "-";
            this.labelEntryGateDelayTime.Text = "-";
            this.labelEntryGateRunTime.Text = "-";
            this.labelDischargeStopperDelayTime.Text = "-";
            this.labelDischargeStopperRunTime.Text = "-";

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

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

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

            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.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.DisplayControls(this.SelectedProductItem);
            this.DisplayControls(this.SelectedJudgmentSetItem);

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

        private void ProductChange(int productNumber)
        {
            this.labelItemNo.Enabled = false;
            this.buttonBack.Enabled = false;
            this.listBoxProductList.Enabled = false;

            this.labelItemNo.Text = "**";
            this.ParentForm.ProductChange(productNumber);
        }

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

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

            // 서보모터 타입이면 Modbus Open
            this.ParentForm.ModbusOpen();

            this.smartDraw.PutDataAllClear();

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

            this.comboBoxLane.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();
        }

        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.comboBoxLane.Enabled = false;
            }
            else
            {
                this.smartDraw.PutDataAllClear();
                this.pictureBoxStart.Visible = false;
                this.pictureBoxStop.Visible = true;
                this.buttonBack.Enabled = true;
                this.labelItemNo.Enabled = true;
                this.comboBoxLane.Enabled = true;
            }
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";
            int index = 0;

            index = this.comboBoxLane.SelectedIndex;

            value = Helper.StringToDecimalPlaces(weightDatas[index].WeightString, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeightValue.Text != value)
                this.labelWeightValue.Text = value;
        }
        public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";
            int index = 0;

            index = this.comboBoxLane.SelectedIndex;

            value = Helper.StringToDecimalPlaces(weightDatas[index].WeightString, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeightJudgment.Text != value)
                this.labelWeightJudgment.Text = value;
        }
        public void UpdateGraphDataDisplay(DataStore.EquipmentStatus status, WeightData weightData, Collection<int> values)
        {
            int iValue = 0, temp = 0, inputValue = 0;
            string sValue = "";

            sValue = Helper.StringToDecimalPlaces(weightData.WeightString, 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;

            this.labelTimeroutCount.Visible = false;

            #region Judgment Item
            this.SelectedJudgmentSetItem.JudgmentDelayTime = jItem.JudgmentDelayTime;
            this.SelectedJudgmentSetItem.TurnDelayTime = jItem.TurnDelayTime;
            this.SelectedJudgmentSetItem.FeedSpeed = jItem.FeedSpeed;
            this.SelectedJudgmentSetItem.JudgmentCount = jItem.JudgmentCount;

            this.SelectedJudgmentSetItem.Sorter1DelayTime = jItem.Sorter1DelayTime;
            this.SelectedJudgmentSetItem.Sorter1RunTime = jItem.Sorter1RunTime;
            this.SelectedJudgmentSetItem.Sorter2DelayTime = jItem.Sorter2DelayTime;
            this.SelectedJudgmentSetItem.Sorter2RunTime = jItem.Sorter2RunTime;

            this.SelectedJudgmentSetItem.EntryGateDelayTime = jItem.EntryGateDelayTime;
            this.SelectedJudgmentSetItem.EntryGateRunTime = jItem.EntryGateRunTime;
            this.SelectedJudgmentSetItem.DischargeStopperDelayTime = jItem.DischargeStopperDelayTime;
            this.SelectedJudgmentSetItem.DischargeStopperRunTime = jItem.DischargeStopperRunTime;
            #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;
            this.SelectedProductItem.OverRangeLimit = pItem.OverRangeLimit;
            this.SelectedProductItem.UnderRangeLimit = pItem.UnderRangeLimit;
            #endregion

            #region 서보모터 속도 변경
            this.labelFeedSpeed.Text = "-";
            //this.smartLabel1.Text = "진행중";
            this.ParentForm.ServoMotorWrite1(1, ServoMotorParameterAddress.Speed1, this.SelectedJudgmentSetItem.FeedSpeed, this.labelFeedSpeed);
            Thread.Sleep(50);
            this.ParentForm.ServoMotorWrite(1, ServoMotorParameterAddress.SaveAllParameters, ServoMotorParameterAddress.EEPROM);

            this.labelItemNo.Enabled = true;
            this.buttonBack.Enabled = true;
            this.listBoxProductList.Enabled = true;
            #endregion

            this.DisplayControls(this.SelectedJudgmentSetItem);
            this.DisplayControls(this.SelectedProductItem);
        }
        public void UpdateDisplayProductChangeInfo(int cnt)
        {
            this.labelTimeroutCount.Visible = true;
            this.labelTimeroutCount.Text = cnt.ToString();
        }

        #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.labelOverRange.Text = Helper.StringToDecimalPlaces(item.OverRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelPassRange.Text = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelUnderRange.Text = Helper.StringToDecimalPlaces(item.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelTareRange.Text = Helper.StringToDecimalPlaces(item.TareRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelOverRangeLimit.Text = Helper.StringToDecimalPlaces(item.OverRangeLimit, this.ParentForm.SystemConfig.DecimalPlaces);
            this.labelUnderRangeLimit.Text = Helper.StringToDecimalPlaces(item.UnderRangeLimit, 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.JudgmentDelayTime.ToString();
            if (this.labelJudgmentDelayTime.Text != sValue)
                this.labelJudgmentDelayTime.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 = item.TurnDelayTime.ToString();
            if (this.labelTurnDelayTime.Text != sValue)
                this.labelTurnDelayTime.Text = sValue;

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

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

            sValue = item.Sorter2DelayTime.ToString();
            if (this.labelSorter2DelayTime.Text != sValue)
                this.labelSorter2DelayTime.Text = sValue;

            sValue = item.Sorter2RunTime.ToString();
            if (this.labelSorter2RunTime.Text != sValue)
                this.labelSorter2RunTime.Text = sValue;

            sValue = item.EntryGateDelayTime.ToString();
            if (this.labelEntryGateDelayTime.Text != sValue)
                this.labelEntryGateDelayTime.Text = sValue;

            sValue = item.EntryGateRunTime.ToString();
            if (this.labelEntryGateRunTime.Text != sValue)
                this.labelEntryGateRunTime.Text = sValue;

            sValue = item.DischargeStopperDelayTime.ToString();
            if (this.labelDischargeStopperDelayTime.Text != sValue)
                this.labelDischargeStopperDelayTime.Text = sValue;

            sValue = item.DischargeStopperRunTime.ToString();
            if (this.labelDischargeStopperRunTime.Text != sValue)
                this.labelDischargeStopperRunTime.Text = sValue;

            this.GraphBackRedraw();
        }
        #endregion
        #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 buttonCutSignal_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.CutInpupt, CommunicationID.MainBoard);
        }

        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.SelectedProductNo = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

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

                    this.ProductChange(this.SelectedProductNo);

                    // SetTrackingHistoryData
                    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.ProductChange(this.SelectedProductNo);

            // SetTrackingHistoryData
            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ProductNumber, "", before, after);
        }

        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.ParentForm.SystemConfig.IsPart11 == true)
                {
                    after = this.textBoxProductName.Text;
                    number = this.SelectedProductItem.Number.ToString();

                    // SetTrackingHistoryData
                    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.ParentForm.SystemConfig.IsPart11 == true)
                {
                    after = this.textBoxLotNo.Text;
                    number = this.SelectedProductItem.Number.ToString();

                    // SetTrackingHistoryData
                    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, 207);
            this.smartKeyboard.Size = new Size(1000, 560);
            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, 207);
            this.smartKeyboard.Size = new Size(1000, 560);
            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 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 labelUnderRange_Click(object sender, EventArgs e)
        {
            int underRangeLimit = 0, underRange = 0;
            string before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelUnderRange.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.labelUnderRange.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.UnderRange = myKeyPad.StringValue.Replace(".", "");
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRange, number, before, after);

                    underRangeLimit = int.Parse(this.SelectedProductItem.UnderRangeLimit);
                    underRange = int.Parse(this.SelectedProductItem.UnderRange);

                    if (underRange < underRangeLimit)
                    {
                        before = this.labelUnderRangeLimit.Text;

                        this.SelectedProductItem.UnderRangeLimit = "0";
                        this.labelUnderRangeLimit.Text = Helper.StringToDecimalPlaces(this.SelectedProductItem.UnderRangeLimit, this.ParentForm.SystemConfig.DecimalPlaces);
                        this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);
                        
                        after = this.labelUnderRangeLimit.Text;

                        // SetTrackingHistoryData
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRangeLimit, number, before, after);

                        // 입력범위를 확인하세요
                        DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                        myMsg.ShowDialog();
                    }
                }
            }
        }
        private void labelPassRange_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelPassRange.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.labelPassRange.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.PassRange = myKeyPad.StringValue.Replace(".", "");
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightPassRange, number, before, after);
                }
            }
        }
        private void labelOverRange_Click(object sender, EventArgs e)
        {
            int overRangeLimit = 0, overRange = 0;
            string before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelOverRange.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.labelOverRange.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.OverRange = myKeyPad.StringValue.Replace(".", "");
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRange, number, before, after);

                    overRangeLimit = int.Parse(this.SelectedProductItem.OverRangeLimit);
                    overRange = int.Parse(this.SelectedProductItem.OverRange);

                    if (overRange > overRangeLimit)
                    {
                        before = this.labelOverRangeLimit.Text;

                        this.SelectedProductItem.OverRangeLimit = "99999";
                        this.labelOverRangeLimit.Text = Helper.StringToDecimalPlaces(this.SelectedProductItem.OverRangeLimit, this.ParentForm.SystemConfig.DecimalPlaces);
                        this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductItem.Number - 1);

                        after = this.labelOverRangeLimit.Text;

                        // SetTrackingHistoryData
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRangeLimit, number, before, after);

                        // 입력범위를 확인하세요
                        DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                        myMsg.ShowDialog();
                    }
                }
            }
        }
        private void labelTareRange_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

            before = this.labelTareRange.Text;
            number = this.SelectedProductNo.ToString();
            
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelTareRange.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.labelTareRange.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.TareRange = myKeyPad.StringValue.Replace(".", "");
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightTareRange, number, before, after);
                }
            }
        }
        private void labelUnderRangeLimit_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

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

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

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRangeLimit, number, before, after);
                }
            }
        }
        private void labelOverRangeLimit_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelOverRangeLimit.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))
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelOverRangeLimit.Text = myKeyPad.StringValue;
                    this.SelectedProductItem.OverRangeLimit = myKeyPad.StringValue.Replace(".", "");
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRangeLimit, number, before, after);
                }
            }
        }
        #endregion

        #region 판정설정
        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);
            myKeyPad.Location = new Point(300, 90);

            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 = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentDelayTime, number, before, after);
                }
            }
        }
        private void labelTurnDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelTurnDelayTime.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.labelTurnDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.TurnDelayTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelTurnDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5017_TurnDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.TurnDelayTime, number, before, after);
                }
            }
        }
        private void labelFeedSpeed_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFeedSpeed.Text, 5, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.IntValue < 1 || myKeyPad.IntValue > 20000)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelFeedSpeed.Text = "-";

                    this.ParentForm.ServoMotorWrite1(1, ServoMotorParameterAddress.Speed1, myKeyPad.IntValue, this.labelFeedSpeed);
                    Thread.Sleep(200);
                    this.ParentForm.ServoMotorWrite(1, ServoMotorParameterAddress.SaveAllParameters, ServoMotorParameterAddress.EEPROM);
                    after = this.labelFeedSpeed.Text;

                    this.SelectedJudgmentSetItem.FeedSpeed = int.Parse(this.labelFeedSpeed.Text);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.MotorSpeed, 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 > 5)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelJudgmentCount.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.JudgmentCount = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    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);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentCount, number, before, after);
                }
            }
        }
        private void labelSorter1DelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter1DelayTime.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.labelSorter1DelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter1DelayTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter1DelayTime, number, before, after);
                }
            }
        }
        private void labelSorter1RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter1RunTime.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.labelSorter1RunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter1RunTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

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

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter1RunTime, number, before, after);
                }
            }
        }
        private void labelSorter2DelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter2DelayTime.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.labelSorter2DelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter2DelayTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelSorter2DelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5105_Sorter2DelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter2DelayTime, number, before, after);
                }
            }
        }
        private void labelSorter2RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter2RunTime.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.labelSorter2RunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter2RunTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelSorter2RunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5106_Sorter2RunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter2RunTime, number, before, after);
                }
            }
        }
        private void labelEntryGateDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelEntryGateDelayTime.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.labelEntryGateDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.EntryGateDelayTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelEntryGateDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5032_EntryGateDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EntryGateDelayTime, number, before, after);
                }
            }
        }
        private void labelEntryGateRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelEntryGateRunTime.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.labelEntryGateRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.EntryGateRunTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelEntryGateRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5033_EntryGateRunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EntryGateRunTime, number, before, after);
                }
            }
        }
        private void labelDischargeStopperDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDischargeStopperDelayTime.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.labelDischargeStopperDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.DischargeStopperDelayTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelDischargeStopperDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5034_DischargeStopperDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.DischargeStopperDelayTime, number, before, after);
                }
            }
        }
        private void labelDischargeStopperRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDischargeStopperRunTime.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.labelDischargeStopperRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.DischargeStopperRunTime = myKeyPad.IntValue;
                    after = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelDischargeStopperRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5034_DischargeStopperRunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // SetTrackingHistoryData
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.DischargeStopperRunTime, number, before, after);
                }
            }
        }

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

            switch (this.comboBoxLane.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;
            }

        }

        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.JudgmentDelayTime = this.SelectedJudgmentSetItem.JudgmentDelayTime;
            this.CaptureJudgmentSetItem.JudgmentCount = this.SelectedJudgmentSetItem.JudgmentCount;
            this.CaptureJudgmentSetItem.FeedSpeed = this.SelectedJudgmentSetItem.FeedSpeed;
            this.CaptureJudgmentSetItem.TurnDelayTime = this.SelectedJudgmentSetItem.TurnDelayTime;

            this.CaptureJudgmentSetItem.Sorter1DelayTime = this.SelectedJudgmentSetItem.Sorter1DelayTime;
            this.CaptureJudgmentSetItem.Sorter1RunTime = this.SelectedJudgmentSetItem.Sorter1RunTime;
            this.CaptureJudgmentSetItem.Sorter2DelayTime = this.SelectedJudgmentSetItem.Sorter2DelayTime;
            this.CaptureJudgmentSetItem.Sorter2RunTime = this.SelectedJudgmentSetItem.Sorter2RunTime;

            this.CaptureJudgmentSetItem.EntryGateDelayTime = this.SelectedJudgmentSetItem.EntryGateDelayTime;
            this.CaptureJudgmentSetItem.EntryGateRunTime = this.SelectedJudgmentSetItem.EntryGateRunTime;
            this.CaptureJudgmentSetItem.DischargeStopperDelayTime = this.SelectedJudgmentSetItem.DischargeStopperDelayTime;
            this.CaptureJudgmentSetItem.DischargeStopperRunTime = this.SelectedJudgmentSetItem.DischargeStopperRunTime;

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

            this.SelectedJudgmentSetItem.JudgmentDelayTime = this.CaptureJudgmentSetItem.JudgmentDelayTime;
            this.SelectedJudgmentSetItem.JudgmentCount = this.CaptureJudgmentSetItem.JudgmentCount;
            this.SelectedJudgmentSetItem.FeedSpeed = this.CaptureJudgmentSetItem.FeedSpeed;
            this.SelectedJudgmentSetItem.TurnDelayTime = this.CaptureJudgmentSetItem.TurnDelayTime;

            this.SelectedJudgmentSetItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
            this.SelectedJudgmentSetItem.Sorter1RunTime = this.CaptureJudgmentSetItem.Sorter1RunTime;
            this.SelectedJudgmentSetItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
            this.SelectedJudgmentSetItem.Sorter2RunTime = this.CaptureJudgmentSetItem.Sorter2RunTime;

            this.SelectedJudgmentSetItem.EntryGateDelayTime = this.CaptureJudgmentSetItem.EntryGateDelayTime;
            this.SelectedJudgmentSetItem.EntryGateRunTime = this.CaptureJudgmentSetItem.EntryGateRunTime;
            this.SelectedJudgmentSetItem.DischargeStopperDelayTime = this.CaptureJudgmentSetItem.DischargeStopperDelayTime;
            this.SelectedJudgmentSetItem.DischargeStopperRunTime = this.CaptureJudgmentSetItem.DischargeStopperRunTime;

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

            this.ProductChange(this.SelectedProductNo);

            // SetTrackingHistoryData
            this.ParentForm.SetTrackingHistoryData(DataStore.E_TrackingOperation.ProductPaste, this.SelectedProductNo.ToString());
        }
        private void buttonPasteAll_Click(object sender, EventArgs e)
        {
            string fullFilePath = "";
            StructJudgmentSetItem structJudgmentItem;

            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.JudgmentDelayTime = this.CaptureJudgmentSetItem.JudgmentDelayTime;
            this.SelectedJudgmentSetItem.JudgmentCount = this.CaptureJudgmentSetItem.JudgmentCount;
            this.SelectedJudgmentSetItem.FeedSpeed = this.CaptureJudgmentSetItem.FeedSpeed;
            this.SelectedJudgmentSetItem.TurnDelayTime = this.CaptureJudgmentSetItem.TurnDelayTime;

            this.SelectedJudgmentSetItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
            this.SelectedJudgmentSetItem.Sorter1RunTime = this.CaptureJudgmentSetItem.Sorter1RunTime;
            this.SelectedJudgmentSetItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
            this.SelectedJudgmentSetItem.Sorter2RunTime = this.CaptureJudgmentSetItem.Sorter2RunTime;

            this.SelectedJudgmentSetItem.EntryGateDelayTime = this.CaptureJudgmentSetItem.EntryGateDelayTime;
            this.SelectedJudgmentSetItem.EntryGateRunTime = this.CaptureJudgmentSetItem.EntryGateRunTime;
            this.SelectedJudgmentSetItem.DischargeStopperDelayTime = this.CaptureJudgmentSetItem.DischargeStopperDelayTime;
            this.SelectedJudgmentSetItem.DischargeStopperRunTime = this.CaptureJudgmentSetItem.DischargeStopperRunTime;

            #region JudgmentSetItem.int
            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++)
            {
                structJudgmentItem.JudgmentDelayTime = this.CaptureJudgmentSetItem.JudgmentDelayTime;
                structJudgmentItem.JudgmentCount = this.CaptureJudgmentSetItem.JudgmentCount;
                structJudgmentItem.FeedSpeed = this.CaptureJudgmentSetItem.FeedSpeed;
                structJudgmentItem.TurnDelayTime = this.CaptureJudgmentSetItem.TurnDelayTime;
                structJudgmentItem.Sorter1RunTime = this.CaptureJudgmentSetItem.Sorter1RunTime;
                structJudgmentItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
                structJudgmentItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
                structJudgmentItem.Sorter2RunTime = this.CaptureJudgmentSetItem.Sorter2RunTime;
                structJudgmentItem.EntryGateDelayTime = this.CaptureJudgmentSetItem.EntryGateDelayTime;
                structJudgmentItem.EntryGateRunTime = this.CaptureJudgmentSetItem.EntryGateRunTime;
                structJudgmentItem.DischargeStopperDelayTime = this.CaptureJudgmentSetItem.DischargeStopperDelayTime;
                structJudgmentItem.DischargeStopperRunTime = this.CaptureJudgmentSetItem.DischargeStopperRunTime;

                structJudgmentItem.DummyString1 = "";
                structJudgmentItem.DummyString2 = "";
                structJudgmentItem.DummyString3 = "";
                structJudgmentItem.DummyString4 = "";
                structJudgmentItem.DummyString5 = "";

                this.ParentForm.smartFileIO.WriteStructure_Begin(structJudgmentItem, i);
            }
            this.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.smartFileIO.Close();  
            #endregion

            this.ProductChange(this.SelectedProductNo);

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

            splash.Finish();

            // SetTrackingHistoryData
            this.ParentForm.SetTrackingHistoryData(DataStore.E_TrackingOperation.ProductAllPaste, "");
        }
        #endregion
        #endregion
    }
}