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_2C.DialogForms;
using INT63DC_2C.Controls;
using INT63DC_ImageDll;

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

        public int SelectedProductNo;
        private ProductItem SelectedProductItem;
        public JudgmentSetItem SelectedJudgmentSetItem;
        private JudgmentSetItem CaptureJudgmentSetItem;

        private ControlDynamicSetting ChildControlDynamic;
        #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:
                    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.labelStaticFilter.Text = "Filter";
                    this.labelStaticJudgmentDelayTime.Text = "J.Delay";
                    this.labelStaticTurnDelayTime.Text = "Turn Delay";
                    this.labelTitleFeedSpeed.Text = "Feed Speed";
                    this.labelStaticJudgmentCount.Text = "J.count";
                    this.labelStaticSorter1DelayTime.Text = "Sorter1 Delay";
                    this.labelStaticSorter1RunTime.Text = "Sorter1 Run";
                    this.labelStaticSorter2DelayTime.Text = "Sorter2 Delay";
                    this.labelStaticSorter2RunTime.Text = "Sorter2 Run";
                    this.labelStaticSorter3DelayTime.Text = "Sorter3 Delay";
                    this.labelStaticSorter3RunTime.Text = "Sorter3 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)); 
                    #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.labelStaticFilter.Text = "滤波器";
                    this.labelStaticJudgmentDelayTime.Text = "判断延迟";
                    this.labelStaticTurnDelayTime.Text = "旋转延迟";
                    this.labelTitleFeedSpeed.Text = "速度";
                    this.labelStaticJudgmentCount.Text = "重复延迟";
                    this.labelStaticSorter1DelayTime.Text = "分类机1 延迟时间";
                    this.labelStaticSorter1RunTime.Text = "分类机1 运行时间";
                    this.labelStaticSorter2DelayTime.Text = "分类机2 延迟时间";
                    this.labelStaticSorter2RunTime.Text = "分类机2 运行时间";
                    this.labelStaticSorter3DelayTime.Text = "分类机3 延迟时间";
                    this.labelStaticSorter3RunTime.Text = "分类机3 运行时间";

                    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.labelStaticFilter.Text = "Filtr";
                    this.labelStaticJudgmentDelayTime.Text = "Zpoždění kapsy";
                    this.labelStaticTurnDelayTime.Text = "Zpoždění rotace";
                    this.labelTitleFeedSpeed.Text = "Rychlost";
                    this.labelStaticJudgmentCount.Text = "Číslo kapsy";
                    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.labelStaticSorter3DelayTime.Font = font;
                    this.labelStaticSorter3DelayTime.Text = "Vyřazovač3 Zpoždění";
                    this.labelStaticSorter3RunTime.Font = font;
                    this.labelStaticSorter3RunTime.Text = "Vyřazovač3 Č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.labelStaticFilter.Text = "Filter";
                    this.labelStaticJudgmentDelayTime.Text = "Taschenverzögerung";
                    this.labelStaticTurnDelayTime.Text = "Rotationsverzögerung";
                    this.labelTitleFeedSpeed.Text = "Geschwindigkeit";
                    this.labelStaticJudgmentCount.Text = "Taschennummer";
                    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.labelStaticSorter3DelayTime.Font = font;
                    this.labelStaticSorter3DelayTime.Text = "Sortierer3 Vezögerung";
                    this.labelStaticSorter3RunTime.Font = font;
                    this.labelStaticSorter3RunTime.Text = "Sortierer3 Laufzeit";

                    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.labelStaticFilter.Text = "フィルタㅡ";
                    this.labelStaticJudgmentDelayTime.Text = "判定の遅れ";
                    this.labelStaticTurnDelayTime.Text = "タㅡン遅延";
                    this.labelTitleFeedSpeed.Text = "速度";
                    this.labelStaticJudgmentCount.Text = "判定番号";
                    this.labelStaticSorter1DelayTime.Text = "ソㅡタㅡ1 遅延時間";
                    this.labelStaticSorter1RunTime.Text = "ソㅡタㅡ1 運転時間";
                    this.labelStaticSorter2DelayTime.Text = "ソㅡタㅡ2 遅延時間";
                    this.labelStaticSorter2RunTime.Text = "ソㅡタㅡ2 運転時間";
                    this.labelStaticSorter3DelayTime.Text = "ソㅡタㅡ3 遅延時間";
                    this.labelStaticSorter3RunTime.Text = "ソㅡタㅡ3 運転時間";

                    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()
        {
            this.ChildControlDynamic = new ControlDynamicSetting(this);

            this.Controls.Add(this.ChildControlDynamic);

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

            if (this.ParentForm.SystemConfig.Sorter3Location == 0)
            {
                this.smartSeparatorLine3.Visible = false;
                this.labelStaticSorter3DelayTime.Visible = false;
                this.labelStaticSorter3RunTime.Visible = false;
                this.labelSorter3DelayTime.Visible = false;
                this.labelSorter3RunTime.Visible = false;
            }
        }
        private void DefaultSetting()
        {
            this.comboBoxLane.Items.Clear();
            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                this.comboBoxLane.Items.Add(i + 1);

            this.labelFilter.Text = "-";
            this.labelTurnDelayTime.Text = "-";
            this.labelJudgmentCount.Text = "-";
            this.labelSorter1DelayTime.Text = "-";
            this.labelSorter1RunTime.Text = "-";
            this.labelSorter2DelayTime.Text = "-";
            this.labelSorter2RunTime.Text = "-";
            this.labelSorter3DelayTime.Text = "-";
            this.labelSorter3RunTime.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.labelJudgmentDelayTime.Text = "-";
            this.labelFeedSpeed.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.ParentForm.LoadDynamicCorrectionFile(ref this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

            this.DisplayControls(this.SelectedProductItem);
            this.DisplayControls(this.SelectedJudgmentSetItem);
            this.ChildControlDynamic.DisplayRefresh(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)
        {
            if (this.ParentForm.SystemConfig.MotorSelect == 1)
            {
                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
            if (this.ParentForm.SystemConfig.MotorSelect == 1)
                this.ParentForm.ServoModbusOpen();

            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.ParentForm.LoadDynamicCorrectionFile(ref this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);
            this.DisplayControls(this.SelectedJudgmentSetItem);
            this.ChildControlDynamic.DisplayRefresh(this.SelectedJudgmentSetItem);

            this.buttonCopy.Text = "00";
            this.CaptureJudgmentSetItem = new JudgmentSetItem();

            this.buttonSetting.ButtonUp();
            this.ChildControlDynamic.Visible = false;

            if(this.ParentForm.SystemConfig.Sorter3Location == 0)
                this.UpdateSorter3Enabled(false);
            else
                this.UpdateSorter3Enabled(true);
        }

        public void UpdateSorter3Enabled(bool bValue)
        {
            this.labelSorter3DelayTime.Enabled = bValue;
            this.labelSorter3RunTime.Enabled = bValue;
            this.labelStaticSorter3DelayTime.Enabled = bValue;
            this.labelStaticSorter3RunTime.Enabled = bValue;
        }
        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.DoubleToString(weightDatas[index].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeightValue.Text != value)
                this.labelWeightValue.Text = value;

            value = weightDatas[index].ADCValue;
            if (this.labelADCValue.Text != value)
                this.labelADCValue.Text = value;
        }
        public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";
            int index = 0;

            index = this.comboBoxLane.SelectedIndex;

            value = Helper.DoubleToString(weightDatas[index].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeightJudgment.Text != value)
                this.labelWeightJudgment.Text = value;
        }
        public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, WeightData weightData)
        {
            string value = "";

            value = Helper.DoubleToString(weightData.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeightJudgment.Text != value)
                this.labelWeightJudgment.Text = value;
        }
        public void UpdateGraphDataDisplay(DataStore.EquipmentStatus status, WeightData weightData, Collection<int> values, string time1)
        {
            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)
        {
            this.labelTimeroutCount.Visible = false;

            if (this.SelectedJudgmentSetItem == null && this.SelectedJudgmentSetItem == null)
                return;

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

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

            this.SelectedJudgmentSetItem.ForcedZeroDelayTime = jItem.ForcedZeroDelayTime;

            this.SelectedJudgmentSetItem.DynamicCorrection1 = jItem.DynamicCorrection1;
            this.SelectedJudgmentSetItem.DynamicCorrection2 = jItem.DynamicCorrection2;
            this.SelectedJudgmentSetItem.DynamicCorrection3 = jItem.DynamicCorrection3;
            this.SelectedJudgmentSetItem.DynamicCorrection4 = jItem.DynamicCorrection4;
            this.SelectedJudgmentSetItem.DynamicCorrection5 = jItem.DynamicCorrection5;
            this.SelectedJudgmentSetItem.DynamicCorrection6 = jItem.DynamicCorrection6;
            this.SelectedJudgmentSetItem.DynamicCorrection7 = jItem.DynamicCorrection7;
            this.SelectedJudgmentSetItem.DynamicCorrection8 = jItem.DynamicCorrection8;
            this.SelectedJudgmentSetItem.DynamicCorrection9 = jItem.DynamicCorrection9;
            this.SelectedJudgmentSetItem.DynamicCorrection10 = jItem.DynamicCorrection10;
            this.SelectedJudgmentSetItem.DynamicCorrection11 = jItem.DynamicCorrection11;
            this.SelectedJudgmentSetItem.DynamicCorrection12 = jItem.DynamicCorrection12;

            this.SelectedJudgmentSetItem.EntryGateDelayTime = jItem.EntryGateDelayTime;
            this.SelectedJudgmentSetItem.EntryGateRunTime = jItem.EntryGateRunTime;
            this.SelectedJudgmentSetItem.DischargeStopperDelayTime = jItem.DischargeStopperDelayTime;
            this.SelectedJudgmentSetItem.DischargeStopperRunTime = jItem.DischargeStopperRunTime;
            this.SelectedJudgmentSetItem.Stopper2DelayTime = jItem.Stopper2DelayTime;
            this.SelectedJudgmentSetItem.Stopper2RunTime = jItem.Stopper2RunTime;
            #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 서보모터 속도 변경
            if (this.ParentForm.SystemConfig.MotorSelect == 1)
            {
                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.smartLabel1.Text = this.ModbusWrite.ToString();
                this.ModbusWrite++;

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

            this.DisplayControls(this.SelectedJudgmentSetItem);
            this.DisplayControls(this.SelectedProductItem);
            this.ChildControlDynamic.DisplayRefresh(this.SelectedJudgmentSetItem);
        }
        public void UpdateDisplayProductChangeInfo(int cnt)
        {
            this.labelTimeroutCount.Visible = true;
            this.labelTimeroutCount.Text = cnt.ToString();
        }
        private int ModbusWrite = 0;
        #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.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.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.Sorter3DelayTime;
            if (this.labelSorter3DelayTime.Text != sValue)
                this.labelSorter3DelayTime.Text = sValue;

            sValue = item.Sorter3RunTime;
            if (this.labelSorter3RunTime.Text != sValue)
                this.labelSorter3RunTime.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);

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.E_TrackingOperation.MainCut, "");
        }

        private void labelItemNo_Click(object sender, EventArgs e)
        {
            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;

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

        #region 품목설정
        private void listBoxProductList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listBoxProductList.SelectedItem == null)
                return;

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

            this.ProductChange(this.SelectedProductNo);
        }

        private void textBoxProductName_KeyPress(object sender, KeyPressEventArgs e)
        {
            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;
            }
            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)
        {
            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;
            }
            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;
        }
        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;
        }

        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)
        {
            string beforeUnder = "", beforeUnderLimit = "", afterUnder = "", afterUnderLimit = "", number = "";
            int underRangeLimit = 0, underRange = 0;

            number = this.SelectedProductNo.ToString();
            beforeUnder = this.labelUnderRange.Text;
            beforeUnderLimit = this.labelUnderRangeLimit.Text;

            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(".", "");
                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        afterUnder = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRange, number, beforeUnder, afterUnder);
                    }

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

                    if (underRange < underRangeLimit)
                    {
                        this.SelectedProductItem.UnderRangeLimit = "0";
                        this.labelUnderRangeLimit.Text = Helper.StringToDecimalPlaces(this.SelectedProductItem.UnderRangeLimit, this.ParentForm.SystemConfig.DecimalPlaces);
                        this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                        // 중량 Limit 설정 확인하세요!
                        // Low Limit Range
                        DialogFormMessage myMsg = new DialogFormMessage(11, this.ParentForm.SystemConfig.Language);
                        myMsg.ShowDialog();

                        // Part11
                        if (this.ParentForm.SystemConfig.IsPart11 == true)
                        {
                            afterUnderLimit = this.labelUnderRangeLimit.Text;
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRange, number, beforeUnderLimit, afterUnderLimit);
                        }
                    }
                }
            }
        }
        private void labelPassRange_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            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(".", "");
                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightPassRange, number, before, after);
                    }
                }
            }
        }
        private void labelOverRange_Click(object sender, EventArgs e)
        {
            string beforeOver = "", beforeOverLimit = "", afterOver = "", afterOverLimit = "", number = "";
            int overRangeLimit = 0, overRange = 0;

            number = this.SelectedProductNo.ToString();
            beforeOver = this.labelOverRange.Text;
            beforeOverLimit = this.labelOverRangeLimit.Text;

            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(".", "");
                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        afterOver = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRange, number, beforeOver, afterOver);
                    }

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

                    if (overRange > overRangeLimit)
                    {
                        this.SelectedProductItem.OverRangeLimit = "99999";
                        this.labelOverRangeLimit.Text = Helper.StringToDecimalPlaces(this.SelectedProductItem.OverRangeLimit, this.ParentForm.SystemConfig.DecimalPlaces);
                        this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                        // 중량 Limit 설정 확인하세요!
                        // Low Limit Range
                        DialogFormMessage myMsg = new DialogFormMessage(11, this.ParentForm.SystemConfig.Language);
                        myMsg.ShowDialog();

                        // Part11
                        if (this.ParentForm.SystemConfig.IsPart11 == true)
                        {
                            afterOverLimit = this.labelOverRangeLimit.Text;
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRangeLimit, number, beforeOverLimit, afterOverLimit);
                        }
                    }
                }
            }
        }
        private void labelTareRange_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            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(".", "");
                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightTareRange, number, before, after);
                    }
                }
            }
        }
        private void labelUnderRangeLimit_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            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(".", "");
                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRangeLimit, number, before, after);
                    }
                }
            }
        }
        private void labelOverRangeLimit_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            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(".", "");
                    this.ParentForm.SaveProductFile(this.SelectedProductItem, this.SelectedProductNo - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRangeLimit, number, before, after);
                    }
                }
            }
        }
        #endregion

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

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

            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;
                    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.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentFilter, number, before, after);
                    }
                }
            }
        }
        private void labelJudgmentDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

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

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

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

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

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentTurnDelayTime, number, before, after);
                    }
                }
            }
        }
        private void labelFeedSpeed_Click(object sender, EventArgs e)
        {
            string before = "", after = "", number = "";

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

            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);
                    this.smartLabel1.Text = this.ModbusWrite.ToString();
                    this.ModbusWrite++;

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

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

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

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

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

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

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

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter1DelayTime, number, before, after);
                    }
                }
            }
        }
        private void labelSorter1RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

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

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter1RunTime, number, before, after);
                    }
                }
            }
        }
        private void labelSorter2DelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

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

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter2DelayTime, number, before, after);
                    }
                }
            }
        }
        private void labelSorter2RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

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

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter2RunTime, number, before, after);
                    }
                }
            }
        }
        private void labelSorter3DelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter3DelayTime.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.labelSorter3DelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter3DelayTime = myKeyPad.StringValue;
                    value = Helper.StringZeroFillDigits4(this.labelSorter3DelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5108_Sorter3DelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter3DelayTime, number, before, after);
                    }
                }
            }
        }
        private void labelSorter3RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter3RunTime.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.labelSorter3RunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.Sorter3RunTime = myKeyPad.StringValue;
                    value = Helper.StringZeroFillDigits4(this.labelSorter3RunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5109_Sorter3RunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.SelectedJudgmentSetItem, this.SelectedProductNo - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        after = myKeyPad.StringValue;
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter3RunTime, 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;
                case 12:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard13);
                    break;
                case 13:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard14);
                    break;
                case 14:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard15);
                    break;
                case 15:
                    this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard16);
                    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.Filter = this.SelectedJudgmentSetItem.Filter;
            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.DynamicCorrection = this.SelectedJudgmentSetItem.DynamicCorrection;
            this.CaptureJudgmentSetItem.ForcedZeroDelayTime = this.SelectedJudgmentSetItem.ForcedZeroDelayTime;
            this.CaptureJudgmentSetItem.OriginOffset = this.SelectedJudgmentSetItem.OriginOffset;

            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.Sorter3DelayTime = this.SelectedJudgmentSetItem.Sorter3DelayTime;
            this.CaptureJudgmentSetItem.Sorter3RunTime = this.SelectedJudgmentSetItem.Sorter3RunTime;
            this.CaptureJudgmentSetItem.Sorter4DelayTime = this.SelectedJudgmentSetItem.Sorter4DelayTime;
            this.CaptureJudgmentSetItem.Sorter4RunTime = this.SelectedJudgmentSetItem.Sorter4RunTime;

            this.CaptureJudgmentSetItem.DynamicCorrection1 = this.SelectedJudgmentSetItem.DynamicCorrection1;
            this.CaptureJudgmentSetItem.DynamicCorrection2 = this.SelectedJudgmentSetItem.DynamicCorrection2;
            this.CaptureJudgmentSetItem.DynamicCorrection3 = this.SelectedJudgmentSetItem.DynamicCorrection3;
            this.CaptureJudgmentSetItem.DynamicCorrection4 = this.SelectedJudgmentSetItem.DynamicCorrection4;
            this.CaptureJudgmentSetItem.DynamicCorrection5 = this.SelectedJudgmentSetItem.DynamicCorrection5;
            this.CaptureJudgmentSetItem.DynamicCorrection6 = this.SelectedJudgmentSetItem.DynamicCorrection6;
            this.CaptureJudgmentSetItem.DynamicCorrection7 = this.SelectedJudgmentSetItem.DynamicCorrection7;
            this.CaptureJudgmentSetItem.DynamicCorrection8 = this.SelectedJudgmentSetItem.DynamicCorrection8;
            this.CaptureJudgmentSetItem.DynamicCorrection9 = this.SelectedJudgmentSetItem.DynamicCorrection9;
            this.CaptureJudgmentSetItem.DynamicCorrection10 = this.SelectedJudgmentSetItem.DynamicCorrection10;
            this.CaptureJudgmentSetItem.DynamicCorrection11 = this.SelectedJudgmentSetItem.DynamicCorrection11;
            this.CaptureJudgmentSetItem.DynamicCorrection12 = this.SelectedJudgmentSetItem.DynamicCorrection12;
            this.CaptureJudgmentSetItem.DynamicCorrection13 = this.SelectedJudgmentSetItem.DynamicCorrection13;
            this.CaptureJudgmentSetItem.DynamicCorrection14 = this.SelectedJudgmentSetItem.DynamicCorrection14;
            this.CaptureJudgmentSetItem.DynamicCorrection15 = this.SelectedJudgmentSetItem.DynamicCorrection15;
            this.CaptureJudgmentSetItem.DynamicCorrection16 = this.SelectedJudgmentSetItem.DynamicCorrection16;

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

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                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.Filter = this.CaptureJudgmentSetItem.Filter;
            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.DynamicCorrection = this.CaptureJudgmentSetItem.DynamicCorrection;
            this.SelectedJudgmentSetItem.ForcedZeroDelayTime = this.CaptureJudgmentSetItem.ForcedZeroDelayTime;
            this.SelectedJudgmentSetItem.OriginOffset = this.CaptureJudgmentSetItem.OriginOffset;

            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.Sorter3DelayTime = this.CaptureJudgmentSetItem.Sorter3DelayTime;
            this.SelectedJudgmentSetItem.Sorter3RunTime = this.CaptureJudgmentSetItem.Sorter3RunTime;
            this.SelectedJudgmentSetItem.Sorter4DelayTime = this.CaptureJudgmentSetItem.Sorter4DelayTime;
            this.SelectedJudgmentSetItem.Sorter4RunTime = this.CaptureJudgmentSetItem.Sorter4RunTime;

            this.SelectedJudgmentSetItem.DynamicCorrection1 = this.CaptureJudgmentSetItem.DynamicCorrection1;
            this.SelectedJudgmentSetItem.DynamicCorrection2 = this.CaptureJudgmentSetItem.DynamicCorrection2;
            this.SelectedJudgmentSetItem.DynamicCorrection3 = this.CaptureJudgmentSetItem.DynamicCorrection3;
            this.SelectedJudgmentSetItem.DynamicCorrection4 = this.CaptureJudgmentSetItem.DynamicCorrection4;
            this.SelectedJudgmentSetItem.DynamicCorrection5 = this.CaptureJudgmentSetItem.DynamicCorrection5;
            this.SelectedJudgmentSetItem.DynamicCorrection6 = this.CaptureJudgmentSetItem.DynamicCorrection6;
            this.SelectedJudgmentSetItem.DynamicCorrection7 = this.CaptureJudgmentSetItem.DynamicCorrection7;
            this.SelectedJudgmentSetItem.DynamicCorrection8 = this.CaptureJudgmentSetItem.DynamicCorrection8;
            this.SelectedJudgmentSetItem.DynamicCorrection9 = this.CaptureJudgmentSetItem.DynamicCorrection9;
            this.SelectedJudgmentSetItem.DynamicCorrection10 = this.CaptureJudgmentSetItem.DynamicCorrection10;
            this.SelectedJudgmentSetItem.DynamicCorrection11 = this.CaptureJudgmentSetItem.DynamicCorrection11;
            this.SelectedJudgmentSetItem.DynamicCorrection12 = this.CaptureJudgmentSetItem.DynamicCorrection12;
            this.SelectedJudgmentSetItem.DynamicCorrection13 = this.CaptureJudgmentSetItem.DynamicCorrection13;
            this.SelectedJudgmentSetItem.DynamicCorrection14 = this.CaptureJudgmentSetItem.DynamicCorrection14;
            this.SelectedJudgmentSetItem.DynamicCorrection15 = this.CaptureJudgmentSetItem.DynamicCorrection15;
            this.SelectedJudgmentSetItem.DynamicCorrection16 = this.CaptureJudgmentSetItem.DynamicCorrection16;

            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.SelectedJudgmentSetItem.Stopper2DelayTime = this.CaptureJudgmentSetItem.Stopper2DelayTime;
            this.SelectedJudgmentSetItem.Stopper2RunTime = this.CaptureJudgmentSetItem.Stopper2RunTime;

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

            this.ProductChange(this.SelectedProductNo);

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

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

            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.Sorter3DelayTime = this.CaptureJudgmentSetItem.Sorter3DelayTime;
            this.SelectedJudgmentSetItem.Sorter3RunTime = this.CaptureJudgmentSetItem.Sorter3RunTime;
            this.SelectedJudgmentSetItem.Sorter4DelayTime = this.CaptureJudgmentSetItem.Sorter4DelayTime;
            this.SelectedJudgmentSetItem.Sorter4RunTime = this.CaptureJudgmentSetItem.Sorter4RunTime;

            this.SelectedJudgmentSetItem.DynamicCorrection1 = this.CaptureJudgmentSetItem.DynamicCorrection1;
            this.SelectedJudgmentSetItem.DynamicCorrection2 = this.CaptureJudgmentSetItem.DynamicCorrection2;
            this.SelectedJudgmentSetItem.DynamicCorrection3 = this.CaptureJudgmentSetItem.DynamicCorrection3;
            this.SelectedJudgmentSetItem.DynamicCorrection4 = this.CaptureJudgmentSetItem.DynamicCorrection4;
            this.SelectedJudgmentSetItem.DynamicCorrection5 = this.CaptureJudgmentSetItem.DynamicCorrection5;
            this.SelectedJudgmentSetItem.DynamicCorrection6 = this.CaptureJudgmentSetItem.DynamicCorrection6;
            this.SelectedJudgmentSetItem.DynamicCorrection7 = this.CaptureJudgmentSetItem.DynamicCorrection7;
            this.SelectedJudgmentSetItem.DynamicCorrection8 = this.CaptureJudgmentSetItem.DynamicCorrection8;
            this.SelectedJudgmentSetItem.DynamicCorrection9 = this.CaptureJudgmentSetItem.DynamicCorrection9;
            this.SelectedJudgmentSetItem.DynamicCorrection10 = this.CaptureJudgmentSetItem.DynamicCorrection10;
            this.SelectedJudgmentSetItem.DynamicCorrection11 = this.CaptureJudgmentSetItem.DynamicCorrection11;
            this.SelectedJudgmentSetItem.DynamicCorrection12 = this.CaptureJudgmentSetItem.DynamicCorrection12;
            this.SelectedJudgmentSetItem.DynamicCorrection13 = this.CaptureJudgmentSetItem.DynamicCorrection13;
            this.SelectedJudgmentSetItem.DynamicCorrection14 = this.CaptureJudgmentSetItem.DynamicCorrection14;
            this.SelectedJudgmentSetItem.DynamicCorrection15 = this.CaptureJudgmentSetItem.DynamicCorrection15;
            this.SelectedJudgmentSetItem.DynamicCorrection16 = this.CaptureJudgmentSetItem.DynamicCorrection16;

            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.SelectedJudgmentSetItem.Stopper2DelayTime = this.CaptureJudgmentSetItem.Stopper2DelayTime;
            this.SelectedJudgmentSetItem.Stopper2RunTime = this.CaptureJudgmentSetItem.Stopper2RunTime;

            #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.Filter = this.CaptureJudgmentSetItem.Filter;
                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.DynamicCorrection = this.CaptureJudgmentSetItem.DynamicCorrection;

                structJudgmentItem.OriginOffset = this.CaptureJudgmentSetItem.OriginOffset;
                structJudgmentItem.ForcedZeroDelayTime = this.CaptureJudgmentSetItem.ForcedZeroDelayTime;
                structJudgmentItem.Sorter1DelayTime = this.CaptureJudgmentSetItem.Sorter1DelayTime;
                structJudgmentItem.Sorter2DelayTime = this.CaptureJudgmentSetItem.Sorter2DelayTime;
                structJudgmentItem.Sorter2RunTime = this.CaptureJudgmentSetItem.Sorter2RunTime;
                structJudgmentItem.DummyString1 = "";
                structJudgmentItem.Sorter4DelayTime = this.CaptureJudgmentSetItem.Sorter4DelayTime;
                structJudgmentItem.Sorter4RunTime = this.CaptureJudgmentSetItem.Sorter4RunTime;
                structJudgmentItem.Sorter3DelayTime = this.CaptureJudgmentSetItem.Sorter3DelayTime;
                structJudgmentItem.Sorter3RunTime = this.CaptureJudgmentSetItem.Sorter3RunTime;

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

            #region DynamicCorrectionItem.int
            fullFilePath = this.ParentForm.PathSystemFileFolder + "DynamicCorrectionItem.int";
            this.ParentForm.smartFileIO.FilePathName = fullFilePath;
            this.ParentForm.smartFileIO.Open(this.ParentForm.BufferSmartUart);
            for (int i = 0; i < 1000; i++)
            {
                structDynamicItem.DynamicCorrection1 = this.CaptureJudgmentSetItem.DynamicCorrection1;
                structDynamicItem.DynamicCorrection2 = this.CaptureJudgmentSetItem.DynamicCorrection2;
                structDynamicItem.DynamicCorrection3 = this.CaptureJudgmentSetItem.DynamicCorrection3;
                structDynamicItem.DynamicCorrection4 = this.CaptureJudgmentSetItem.DynamicCorrection4;
                structDynamicItem.DynamicCorrection5 = this.CaptureJudgmentSetItem.DynamicCorrection5;
                structDynamicItem.DynamicCorrection6 = this.CaptureJudgmentSetItem.DynamicCorrection6;
                structDynamicItem.DynamicCorrection7 = this.CaptureJudgmentSetItem.DynamicCorrection7;
                structDynamicItem.DynamicCorrection8 = this.CaptureJudgmentSetItem.DynamicCorrection8;
                structDynamicItem.DynamicCorrection9 = this.CaptureJudgmentSetItem.DynamicCorrection9;
                structDynamicItem.DynamicCorrection10 = this.CaptureJudgmentSetItem.DynamicCorrection10;
                structDynamicItem.DynamicCorrection11 = this.CaptureJudgmentSetItem.DynamicCorrection11;
                structDynamicItem.DynamicCorrection12 = this.CaptureJudgmentSetItem.DynamicCorrection12;

                structDynamicItem.DummyDouble1 = 0.0;
                structDynamicItem.DummyDouble2 = 0.0;
                structDynamicItem.DummyDouble3 = 0.0;
                structDynamicItem.DummyDouble4 = 0.0;
                structDynamicItem.DummyDouble5 = 0.0;
                structDynamicItem.DummyDouble6 = 0.0;
                structDynamicItem.DynamicCorrection13 = this.CaptureJudgmentSetItem.DynamicCorrection13;
                structDynamicItem.DynamicCorrection14 = this.CaptureJudgmentSetItem.DynamicCorrection14;
                structDynamicItem.DynamicCorrection15 = this.CaptureJudgmentSetItem.DynamicCorrection15;
                structDynamicItem.DynamicCorrection16 = this.CaptureJudgmentSetItem.DynamicCorrection16;

                structDynamicItem.DummyInt1 = 0;
                structDynamicItem.DummyInt2 = 0;
                structDynamicItem.DummyInt3 = 0;
                structDynamicItem.DummyInt4 = 0;
                structDynamicItem.Stopper2DelayTime = this.CaptureJudgmentSetItem.Stopper2DelayTime;
                structDynamicItem.Stopper2RunTime = this.CaptureJudgmentSetItem.Stopper2RunTime;
                structDynamicItem.EntryGateDelayTime = this.CaptureJudgmentSetItem.EntryGateDelayTime;
                structDynamicItem.EntryGateRunTime = this.CaptureJudgmentSetItem.EntryGateRunTime;
                structDynamicItem.DischargeStopperDelayTime = this.CaptureJudgmentSetItem.DischargeStopperDelayTime;
                structDynamicItem.DischargeStopperRunTime = this.CaptureJudgmentSetItem.DischargeStopperRunTime;

                this.ParentForm.smartFileIO.WriteStructure_Begin(structDynamicItem, 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();

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.E_TrackingOperation.ProductAllPaste, this.SelectedProductNo.ToString());
        }
        #endregion

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