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

using SmartX;
using INT69DB_2A_ImageDll;
using INT69DB_2A.DialogForms;

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

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

        private ProductItem SelectedProductItem;
        private JudgmentSetItem SelectedJudgmentSetItem;
        private JudgmentSetItem CaptureJudgmentSetItem;
        private Collection<SmartButton> CollectionButtonLine;
        #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();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
            {
                this.smartKeyboard.HanYoungKeyDisable = false;
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                this.labelTitle.Text = "System";
                this.tabProduct.Text = "Product";
                this.tabJudgment.Text = "Judgment";
                this.groupBoxWeightSetting.Text = "Weight setting";

                this.groupBoxJudgment.Text = "Judgment";
                this.labelStaticFilter.Text = "Filter";
                this.labelStaticJudgmentDelayTime.Text = "J.Delay";
                this.labelStaticDoubleDelayTime.Text = "Overlap";
                this.labelStaticJudgmentCount.Text = "J.Count";
                this.labelStaticDynamic.Text = "Dynamic";
                this.labelStaticForcedZeroDelayTime.Text = "Forced Zero Delay";
               
                this.buttonWeightReference.Text = "Reference";
                this.labelTitleResult.Text = "Judgment";

                this.groupBoxConveyor.Text = "Conveyor setting";
                this.labelStaticRejectConveyorDelayTime.Text = "Reject CV Delay";
                this.labelStaticRejectConveyorRunTime.Text = "Reject CV Run";
                this.labelStaticFeedingDelayTime.Text = "Feeding CV Delay";
                this.labelStaticFeedingRunTime.Text = "Feeding CV Run";

                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingNoUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormSystemSettingUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                this.labelTitle.Text = "系统设定";
                this.tabProduct.Text = "项目设置";
                this.tabJudgment.Text = "判断设置";
                this.groupBoxWeightSetting.Text = "重量";

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

                this.groupBoxJudgment.Text = "判断";
                this.labelStaticFilter.Text = "滤波器";
                this.labelStaticJudgmentDelayTime.Text = "判断延迟";
                this.labelStaticDoubleDelayTime.Text = "重复";
                this.labelStaticJudgmentCount.Text = "重复延迟";
                this.labelStaticDynamic.Text = "动态校正";
                this.labelStaticForcedZeroDelayTime.Text = "强制零延迟";

                this.buttonWeightReference.Text = "参考价值";
                this.labelTitleResult.Text = "结果";
                this.labelTitleWeight.Text = "重量";

                this.groupBoxConveyor.Text = "输送带设置";
                this.labelStaticRejectConveyorDelayTime.Text = "筛选输送带 延迟";
                this.labelStaticRejectConveyorRunTime.Text = "筛选输送带 运行";
                this.labelStaticFeedingDelayTime.Text = "进料输送带 延迟";
                this.labelStaticFeedingRunTime.Text = "进料输送带 运行";

                this.labelTitleWeight.Text = "重量";

                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingNoUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormSystemSettingUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Japanese)
            {
                this.labelTitle.Text = "システム設定";
                this.tabProduct.Text = "製品設定";
                this.tabJudgment.Text = "判定設定";
                this.groupBoxWeightSetting.Text = "製品設定";

                this.groupBoxJudgment.Text = "判定設定";
                this.labelStaticFilter.Text = "フィルタㅡ";
                this.labelStaticJudgmentDelayTime.Text = "判定の遅れ";
                this.labelStaticDoubleDelayTime.Text = "オㅡバㅡラップ";
                this.labelStaticJudgmentCount.Text = "判定番号";
                this.labelStaticDynamic.Text = "動的定数";
                this.labelStaticForcedZeroDelayTime.Text = "強制零点遅延";

                this.buttonWeightReference.Text = "基準";
                this.labelTitleResult.Text = "結果";
                this.labelTitleWeight.Text = "重量";

                this.groupBoxConveyor.Text = "コンベア設定";
                this.labelStaticRejectConveyorDelayTime.Text = "排出コンベア遅延";
                this.labelStaticRejectConveyorRunTime.Text = "排出コンベア動作";
                this.labelStaticFeedingDelayTime.Text = "供給コンベア遅延";
                this.labelStaticFeedingRunTime.Text = "供給コンベア動作";

                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingNoUp));

                this.buttonCopy.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnCopyDown));
                this.buttonCopy.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnCopyUp));
                this.buttonPaste.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnPasteDown));
                this.buttonPaste.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnPasteUp));
                this.buttonPasteAll.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnPasteAllDown));
                this.buttonPasteAll.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnPasteAllUp));

                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingOverUp));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingPassUp));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingTareUp));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnFormSystemSettingUnderUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {

            }
            else
            {

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

            this.CollectionButtonLine = new Collection<SmartButton>();
            this.CollectionButtonLine.Clear();

            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 2:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);

                    this.buttonLine3.Visible = false;
                    this.buttonLine4.Visible = false;
                    this.buttonLine5.Visible = false;
                    this.buttonLine6.Visible = false;
                    this.buttonLine7.Visible = false;
                    this.buttonLine8.Visible = false;
                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 3:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);

                    this.buttonLine4.Visible = false;
                    this.buttonLine5.Visible = false;
                    this.buttonLine6.Visible = false;
                    this.buttonLine7.Visible = false;
                    this.buttonLine8.Visible = false;
                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 4:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);
                    this.CollectionButtonLine.Add(this.buttonLine4);

                    this.buttonLine5.Visible = false;
                    this.buttonLine6.Visible = false;
                    this.buttonLine7.Visible = false;
                    this.buttonLine8.Visible = false;
                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 5:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);
                    this.CollectionButtonLine.Add(this.buttonLine4);
                    this.CollectionButtonLine.Add(this.buttonLine5);

                    this.buttonLine6.Visible = false;
                    this.buttonLine7.Visible = false;
                    this.buttonLine8.Visible = false;
                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 6:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);
                    this.CollectionButtonLine.Add(this.buttonLine4);
                    this.CollectionButtonLine.Add(this.buttonLine5);
                    this.CollectionButtonLine.Add(this.buttonLine6);

                    this.buttonLine7.Visible = false;
                    this.buttonLine8.Visible = false;
                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 7:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);
                    this.CollectionButtonLine.Add(this.buttonLine4);
                    this.CollectionButtonLine.Add(this.buttonLine5);
                    this.CollectionButtonLine.Add(this.buttonLine6);
                    this.CollectionButtonLine.Add(this.buttonLine7);

                    this.buttonLine8.Visible = false;
                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 8:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);
                    this.CollectionButtonLine.Add(this.buttonLine4);
                    this.CollectionButtonLine.Add(this.buttonLine5);
                    this.CollectionButtonLine.Add(this.buttonLine6);
                    this.CollectionButtonLine.Add(this.buttonLine7);
                    this.CollectionButtonLine.Add(this.buttonLine8);

                    this.buttonLine9.Visible = false;
                    this.buttonLine10.Visible = false;
                    break;
                case 10:
                    this.CollectionButtonLine.Add(this.buttonLine1);
                    this.CollectionButtonLine.Add(this.buttonLine2);
                    this.CollectionButtonLine.Add(this.buttonLine3);
                    this.CollectionButtonLine.Add(this.buttonLine4);
                    this.CollectionButtonLine.Add(this.buttonLine5);
                    this.CollectionButtonLine.Add(this.buttonLine6);
                    this.CollectionButtonLine.Add(this.buttonLine7);
                    this.CollectionButtonLine.Add(this.buttonLine8);
                    this.CollectionButtonLine.Add(this.buttonLine9);
                    this.CollectionButtonLine.Add(this.buttonLine10);
                    break;
                default:
                    break;
            }

            if (this.ParentForm.SystemConfig.IsDischargeConveyor == false)
            {
                this.labelRejectConveyorDelayTime.Enabled = false;
                this.labelRejectConveyorRunTime.Enabled = false;
                this.labelStaticRejectConveyorDelayTime.ForeColor = Color.Gray;
                this.labelStaticRejectConveyorRunTime.ForeColor = Color.Gray;
                this.labelRejectConveyorDelayTime.ForeColor = Color.Gray;
                this.labelRejectConveyorRunTime.ForeColor = Color.Gray;
            }

            if (this.ParentForm.SystemConfig.IsFeedingConveyor == false)
            {
                this.labelFeedingConveyorDelayTime.Enabled = false;
                this.labelFeedingConveyorRunTime.Enabled = false;
                this.labelStaticFeedingDelayTime.ForeColor = Color.Gray;
                this.labelStaticFeedingRunTime.ForeColor = Color.Gray;
                this.labelFeedingConveyorDelayTime.ForeColor = Color.Gray;
                this.labelFeedingConveyorRunTime.ForeColor = Color.Gray;
            }

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

            this.buttonLine1.ButtonDown();
            for (int i = 1; i < this.CollectionButtonLine.Count; i++)
                this.CollectionButtonLine[i].ButtonUp();

            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.SelectedIndexChanged += new EventHandler(this.listBoxProductList_SelectedIndexChanged);
            this.listBoxProductList.SelectedIndex = this.SelectedProductNo - 1;

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

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

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

            if (this.buttonLine1.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[0].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[0].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine2.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[1].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[1].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine3.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[2].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[2].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine4.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[3].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[3].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine5.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[4].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[4].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine6.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[5].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[5].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine7.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[6].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[6].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine8.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[7].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[7].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine9.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[8].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = weightDatas[8].ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else if (this.buttonLine10.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.DoubleToString(weightDatas[9].Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

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

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

            this.smartDraw.PutDataAllClear();

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

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

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

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

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

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

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

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

            this.DisplayControls(this.SelectedJudgmentSetItem);
            this.DisplayControls(this.SelectedProductItem);
        }

        #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.buttonItemNo.Text = item.Number.ToString();
            this.textBoxProductName.Text = item.Name;
            this.textBoxLotNo.Text = item.LotNo;
            this.buttonOver.Text = Helper.StringToDecimalPlaces(item.OverRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonPass.Text = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonUnder.Text = Helper.StringToDecimalPlaces(item.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonTare.Text = Helper.StringToDecimalPlaces(item.TareRange, this.ParentForm.SystemConfig.DecimalPlaces);
        }
        #endregion

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

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

            this.smartDraw.PutDataAllClear();

            this.DrawInitialize();

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

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

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

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

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

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

            if (item == null)
                return;

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

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

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

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

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

            sValue = item.ForcedZeroDelayTime.ToString();
            if (this.labelForcedZeroDelayTime.Text != sValue)
                this.labelForcedZeroDelayTime.Text = sValue;

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

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

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

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

            this.GraphBackRedraw();
        }
        #endregion

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

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

            this.smartDraw.PutDataAllClear();

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

            this.buttonLine1.ButtonDown();
            for (int i = 1; i < this.CollectionButtonLine.Count; i++)
                this.CollectionButtonLine[i].ButtonUp();
            this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);

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

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

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

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

            this.tabControl.SelectedIndex = 0;

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

        #region Event Handler
        private void buttonBack_Click(object sender, EventArgs e)
        {
            foreach (SmartX.SmartButton bt in this.CollectionButtonLine)
                bt.ButtonUp();

            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
        }
        private void buttonItemNo_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.labelItemNo.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonItemNo.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(280, 90);

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

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

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

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ProductNumber, "", before, after);
                }
            }
        }
        private void buttonUp_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.MotorUp, CommunicationID.MainBoard);
        }
        private void buttonDown_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.MotorDown, CommunicationID.MainBoard);
        }

        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl.SelectedIndex == 0)
            {
                this.buttonCopy.Visible = false;
                this.buttonPaste.Visible = false;
                this.buttonPasteAll.Visible = false;
            }
            else
            {
                this.buttonCopy.Visible = true;
                this.buttonPaste.Visible = true;
                this.buttonPasteAll.Visible = true;
            }
        }

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

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

            before = this.SelectedProductNo.ToString();

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

            this.ParentForm.LoadProductFile(ref this.SelectedProductItem, this.listBoxProductList.SelectedIndex);

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

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

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

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

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

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

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

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

                this.textBoxLotNo.Enabled = true;

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

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

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

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

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

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

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

                this.textBoxProductName.Enabled = true;

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

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

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

                this.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(20, 300);
            this.smartKeyboard.Size = new Size(750, 295);
            this.smartKeyboard.Hide();

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

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

            this.textBoxLotNo.Enabled = false;

            this.BeforeName = this.textBoxProductName.Text;
        }
        private void buttonLotEdit_Click(object sender, EventArgs e)
        {
            this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
            this.smartKeyboard.Location = new Point(20, 300);
            this.smartKeyboard.Size = new Size(750, 295);
            this.smartKeyboard.Hide();

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

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

            this.textBoxProductName.Enabled = false;

            this.BeforeLot = this.textBoxLotNo.Text;
        }

        private void smartKeyboard_OnHanYoungKeyChange(object sender, EventArgs e)
        {
            if (this.IsHanyoung == false)
                this.IsHanyoung = true;
            else
                this.IsHanyoung = 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 buttonUnder_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.buttonUnder.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonUnder.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(100, 90);

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

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

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRange, "", before, after);
                }
            }
        }
        private void buttonPass_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.buttonPass.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonPass.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(100, 90);

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

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

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightPassRange, "", before, after);
                }
            }
        }
        private void buttonOver_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.buttonOver.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonOver.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(100, 90);

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

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

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRange, "", before, after);
                }
            }
        }
        private void buttonTare_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.buttonTare.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonTare.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(100, 90);

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

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

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightTareRange, "", before, after);
                }
            }
        } 
        #endregion

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

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

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

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 16)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    after = 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)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.JudgmentFilter, number, before, after);
                }
            }
        }
        private void labelJudgmentDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelJudgmentDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            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
                {
                    after = this.labelJudgmentDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.JudgmentDelayTime = myKeyPad.IntValue;

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

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

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

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDoubleDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            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
                {
                    after = this.labelDoubleDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.DoubleDelayTime = myKeyPad.IntValue;

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

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

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

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

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

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

                    this.GraphBackRedraw();

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

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

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

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

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

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

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

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

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

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

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

                    value = Helper.StringZeroFillDigits4(this.labelForcedZeroDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4501_ForcedZeroDelayTime, value);

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

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

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

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

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRejectConveyorDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            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
                {
                    after = this.labelRejectConveyorDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.RejectConveyorDelayTime = myKeyPad.IntValue;

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

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

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

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRejectConveyorRunTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            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
                {
                    after = this.labelRejectConveyorRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.RejectConveyorRunTime = myKeyPad.IntValue;

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

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

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

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFeedingConveyorDelayTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            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
                {
                    after = this.labelFeedingConveyorDelayTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.FeedingConveyorDelayTime = myKeyPad.IntValue;

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

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

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

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

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelFeedingConveyorRunTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            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
                {
                    after = this.labelFeedingConveyorRunTime.Text = myKeyPad.StringValue;
                    this.SelectedJudgmentSetItem.FeedingConveyorRunTime = myKeyPad.IntValue;

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

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

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

        private void buttonLine_Click(object sender, EventArgs e)
        {
            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button == this.buttonLine1)
                this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);
            else if (button == this.buttonLine2)
                this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard2);
            else if (button == this.buttonLine3)
                this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard3);
            else if (button == this.buttonLine4)
                this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard4);
            else if (button == this.buttonLine5)
                this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard5);
            else
                this.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard6);
        }
        private void buttonCopy_Click(object sender, EventArgs e)
        {
            this.buttonCopy.Text = this.buttonItemNo.Text;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                structItem.RejectConveyorDelayTime = this.CaptureJudgmentSetItem.RejectConveyorDelayTime;
                structItem.RejectConveyorOperatingTime = this.CaptureJudgmentSetItem.RejectConveyorRunTime;
                structItem.FeedingConveyorDelayTime = this.CaptureJudgmentSetItem.FeedingConveyorDelayTime;
                structItem.FeedingConveyorOperatingTime = this.CaptureJudgmentSetItem.FeedingConveyorRunTime;

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

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

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

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

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

            splash.Finish();

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

        #region TestButton
        private void buttonClear_Click(object sender, EventArgs e)
        {
            this.smartDraw.PutDataAllClear();
        }
        private void buttonMax_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 100; i++)
                this.smartDraw.PutData(240);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 100; i++)
                this.smartDraw.PutData(120);
        }
        private void buttonMin_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 100; i++)
                this.smartDraw.PutData(0);
        } 
        #endregion
      
        #endregion
    }
}