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

using ITC81DB_2.DialogForms;
using ITC81DB_2.Forms;
using SmartX;
using System.Collections.ObjectModel;
using ITC81DB_2_ImageDll;

namespace ITC81DB_2.Controls
{
    public partial class ControlCenterSystemJudgmentSetting : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;

        private string RefrenceADC;
        private JudgmentSetItem CaptureJudgmentSetItem1;
        private JudgmentSetItem CaptureJudgmentSetItem2;
        #endregion

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

            this.ParentForm = parent;

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

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

        #region Method
        public void InitializeDesign()
        {
            Class1 images = new Class1();

            if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.English)
            {
                this.buttonWeightReference.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engJudgmentStandardDisable));
                this.buttonWeightReference.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engJudgmentStandardDown));
                this.buttonWeightReference.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engJudgmentStandardUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Chinese)
            {
                this.buttonWeightReference.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnJudgmentStandardDisable));
                this.buttonWeightReference.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnJudgmentStandardDown));
                this.buttonWeightReference.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnJudgmentStandardUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
                this.buttonWeightReference.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnJudgmentStandardDisable));
                this.buttonWeightReference.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnJudgmentStandardDown));
                this.buttonWeightReference.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnJudgmentStandardUp));
            }
            else
            {
                this.buttonWeightReference.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korJudgmentStandardDisable));
                this.buttonWeightReference.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korJudgmentStandardDown));
                this.buttonWeightReference.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korJudgmentStandardUp));
            }

            this.ChangeScreen();
        }
        private void DefaultSetting()
        {
            this.RefrenceADC = "0";
            this.CaptureJudgmentSetItem1 = new JudgmentSetItem();
            this.CaptureJudgmentSetItem2 = new JudgmentSetItem();

            this.ControlInitialize();
        }

        private void ControlInitialize()
        {
            this.labelDoubleDelayTime.Text = " -";
            this.labelJudgmentDelayTime.Text = " -";
            this.labelFilter.Text = " -";
            this.labelJudgmentDelayTime.Text = " -";
            this.smartDraw.PutDataAllClear();
        }

        public void DrawInitialize()
        {
            SmartX.SmartDraw.CHARTREFRESH charRefreshType = SmartX.SmartDraw.CHARTREFRESH.LEFTSCROLL;
            SmartX.SmartDraw.CHARTPENSTYLE[] charPenStyle;
            charPenStyle = new SmartX.SmartDraw.CHARTPENSTYLE[1];
            charPenStyle[0].m_chColor = Color.Yellow;
            charPenStyle[0].m_iPenWidth = 2;

            this.smartDraw.SetChartCfg(25, 250, 300, 240, 1, charRefreshType, 1);
            //this.smartDraw.SetChartCfg(25, 250, 400, 240, 2, charRefreshType, 1);
            this.smartDraw.ChartChannelPenStyle = charPenStyle;
            this.smartDraw.ChartDrawStep = 1;
        }
        public void GraphBackRedraw()
        {
            int xPoint, temp;

            this.smartDraw.PutDataAllClear();

            this.DrawInitialize();

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

            // 가로 중심선
            this.smartDraw.BackDraw.SetPenStyle(Color.Blue, 1);
            this.smartDraw.BackDraw.Line(25, 130, 325, 130);
            //this.smartDraw.BackDraw.Line(25, 130, 425, 130);

            // 세로선 
            this.smartDraw.BackDraw.SetPenStyle(Color.Blue, 3);
            this.smartDraw.BackDraw.Line(25, 10, 25, 250);
            this.smartDraw.BackDraw.Line(325, 10, 325, 250);
            //this.smartDraw.BackDraw.Line(425, 10, 425, 250);

            // 세로 중심선
            this.smartDraw.BackDraw.SetPenStyle(Color.Red, 1);
            this.smartDraw.BackDraw.Line(175, 50, 175, 210);
            //this.smartDraw.BackDraw.Line(225, 50, 225, 210);

            // 판정개수 표시선
            temp = int.Parse(this.labelJudgmentCount.Text);
            xPoint = 175 - temp;
            //xPoint = 225 - temp;
            this.smartDraw.BackDraw.SetPenStyle(Color.Red, 1);
            this.smartDraw.BackDraw.Line(xPoint, 50, xPoint, 210);
        }

        public void ChangeScreen()
        {
            Class1 images = new Class1();

            this.buttonUp.Visible = false;
            this.buttonDown.Visible = false;

            // 0 : 컨베어, 4 : 업다운, 6 : 정지계량
            if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.English)
            {
                switch (this.ParentForm.ParentForm.SystemConfig.EquipmentType)
                {
                    case 0:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundJudgment));
                        break;
                    case 4:
                        this.buttonUp.Visible = true;
                        this.buttonDown.Visible = true;
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundJudgment_Updown_Discharge));
                        break;
                    default:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundJudgment));
                        break;
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Chinese)
            {
                switch (this.ParentForm.ParentForm.SystemConfig.EquipmentType)
                {
                    case 0:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundJudgment));
                        break;
                    case 4:
                        this.buttonUp.Visible = true;
                        this.buttonDown.Visible = true;
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundJudgment_Updown_Discharge));
                        break;
                    default:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundJudgment));
                        break;
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
                switch (this.ParentForm.ParentForm.SystemConfig.EquipmentType)
                {
                    case 0:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.spnBackgroundJudgment));
                        break;
                    case 4:
                        this.buttonUp.Visible = true;
                        this.buttonDown.Visible = true;
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.spnBackgroundJudgment_Updown_Discharge));
                        break;
                    default:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.spnBackgroundJudgment));
                        break;
                }
            }
            else
            {
                switch (this.ParentForm.ParentForm.SystemConfig.EquipmentType)
                {
                    case 0:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundJudgment));
                        break;
                    case 4:
                        this.buttonUp.Visible = true;
                        this.buttonDown.Visible = true;
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundJudgment_Updown_Discharge));
                        break;
                    default:
                        this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundJudgment));
                        break;
                }
            }

            this.LabelLocation(this.ParentForm.ParentForm.SystemConfig.EquipmentType);
        }

        // 모드별 배경화면 및 Label Visible/위치 변경
        private void LabelLocation(int equipmentType)
        {
            switch (equipmentType)
            {
                case 4:
                    this.labelDescendDelayTime.Visible = true;
                    this.labelAscendDelayTime.Visible = true;

                    this.labelDescendDelayTime.Location = new Point(109, 152);
                    this.labelJudgmentDelayTime.Location = new Point(109, 196);
                    this.labelDoubleDelayTime.Location = new Point(109, 240);
                    this.labelAscendDelayTime.Location = new Point(109, 284);
                    this.labelJudgmentCount.Location = new Point(109, 328);
                    this.labelFeedSpeed.Location = new Point(109, 372);
                    this.labelDynamicCorrection.Location = new Point(109, 416);
                    break;
                default:
                    this.labelDescendDelayTime.Visible = false;
                    this.labelAscendDelayTime.Visible = false;

                    this.labelJudgmentDelayTime.Location = new Point(109, 152);
                    this.labelDoubleDelayTime.Location = new Point(109, 196);
                    this.labelJudgmentCount.Location = new Point(109, 240);
                    this.labelFeedSpeed.Location = new Point(109, 284);
                    this.labelDynamicCorrection.Location = new Point(109, 328);
                    break;
            }
        }

        private void UpdateSystemParameterDisplay(JudgmentSetItem item)
        {
            string value = "";

            value = item.Filter.ToString();
            if (this.labelFilter.Text != value)
                this.labelFilter.Text = value;
            
            value = item.DescendDelayTime.ToString();
            if (this.labelDescendDelayTime.Text != value)
                this.labelDescendDelayTime.Text = value;

            value = item.AscendDelayTime.ToString();
            if (this.labelAscendDelayTime.Text != value)
                this.labelAscendDelayTime.Text = value;

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

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

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

            value = item.FeedSpeed1.ToString();
            if (this.labelFeedSpeed.Text != value)
                this.labelFeedSpeed.Text = value;

            value = Helper.DoubleToString(item.DynamicCorrection, 6);
            if (this.labelDynamicCorrection.Text != value)
                this.labelDynamicCorrection.Text = value;

            this.GraphBackRedraw();
        }
        public void UpdateEquipmentStatusDisplay(Define.E_EquipmentStatus status)
        {
            if (status == Define.E_EquipmentStatus.Start)
            {
                this.smartDraw.PutDataAllClear();
                this.labelProductNo.Enabled = false;
                this.buttonWeightReference.Enabled = false;
                this.buttonCopy.Enabled = false;
                this.buttonPaste.Enabled = false;
                this.buttonPasteAll.Enabled = false;
                this.buttonLine1.Enabled = false;
                this.buttonLine2.Enabled = false;
                this.buttonDown.Enabled = false;
                this.buttonUp.Enabled = false;
                this.buttonLineCopy.Enabled = false;
            }
            else
            {
                this.labelProductNo.Enabled = true;
                this.buttonWeightReference.Enabled = true;
                this.buttonCopy.Enabled = true;
                this.buttonPaste.Enabled = true;
                this.buttonPasteAll.Enabled = true;
                this.buttonLine1.Enabled = true;
                this.buttonLine2.Enabled = true;
                this.buttonDown.Enabled = true;
                this.buttonUp.Enabled = true;
                this.buttonLineCopy.Enabled = true;
            }
        }
        public void UpdateCurrentProductDisplay(Define.E_EquipmentStatus status, ProductItem pItem1, ProductItem pItem2)
        {
            string value = "";

            value = pItem1.Number.ToString();
            if (this.labelProductNo.Text != value)
                this.labelProductNo.Text = value;

            if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.UpdateSystemParameterDisplay(this.ParentForm.ParentForm.CurrentJudgmentSetItem1);
            else
                this.UpdateSystemParameterDisplay(this.ParentForm.ParentForm.CurrentJudgmentSetItem2);
        }
        public void UpdateGraphDataDisplay(Define.E_EquipmentStatus status, WeightData weightData, Collection<int> values)
        {
            int iValue = 0, temp = 0, inputValue = 0;
            string sValue = "";

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

            this.smartDraw.PutDataAllClear();

            iValue = int.Parse(this.RefrenceADC);
            //if (this.RefrenceADC.Length == 5)
            //    iValue = int.Parse(this.RefrenceADC.Substring(2, 3));
            //else if(this.RefrenceADC.Length == 4)
            //    iValue = int.Parse(this.RefrenceADC.Substring(1, 3));
            //else if (this.RefrenceADC.Length == 3)
            //    iValue = int.Parse(this.RefrenceADC.Substring(0, 3));

            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 UpdateStopWeightDisplay(Define.E_EquipmentStatus status, WeightData data1, WeightData data2)
        {
            string value = "";

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

                value = data1.ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
            else
            {
                value = Helper.DoubleToString(data2.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeightValue.Text != value)
                    this.labelWeightValue.Text = value;

                value = data2.ADCValue;
                if (this.labelADCValue.Text != value)
                    this.labelADCValue.Text = value;
            }
        }
        public void UpdateConstantDisplay(Define.E_EquipmentStatus status, CalibrationItem item)
        {
            string value = "";

            if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                value = Helper.StringToDecimalPlaces(item.Constant1.Trim(), 6);
                if (this.labelConstant.Text != value)
                    this.labelConstant.Text = value;
            }
            else
            {
                value = Helper.StringToDecimalPlaces(item.Constant2.Trim(), 6);
                if (this.labelConstant.Text != value)
                    this.labelConstant.Text = value;
            }
        }
        public void UpdateChecksumDisplay(string value1, string value2)
        {
            this.label1.Text = value1;
            this.label2.Text = value2;
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.SystemJudgmentSetting;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_DisplayMode.SystemSetting);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.labelProductNo.Text = this.ParentForm.ParentForm.SystemConfig.ProductNumber.ToString();
            
            this.ControlInitialize();

            this.UpdateSystemParameterDisplay(this.ParentForm.ParentForm.CurrentJudgmentSetItem1);

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

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

            // Read Calibration Constant
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._3601_ConstantRead, "");

            this.buttonLine1.ButtonDown();
            this.buttonLine2.ButtonUp();
            this.ParentForm.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);
        }
        #endregion

        #region Event Handler
        private void labelFilter_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5001_Filter, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5021_Filter, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                }
            }
        }
        private void labelJudgmentDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5002_JudgmentDelayTime, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5022_JudgmentDelayTime, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                }
            }
        }
        private void labelDoubleDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5003_DoubleDelayTime, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5023_DoubleDelayTime, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                }
            }
        }
        private void labelJudgmentCount_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5004_JudgmentCount, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5024_JudgmentCount, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                }
            }
        }
        private void labelFeedSpeed_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1 = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5005_FeedSpeed, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1 = myKeyPad.IntValue;
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5025_FeedSpeed, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                }
            }
        }
        private void labelDynamicCorrection_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection = myKeyPad.doubleValue;
                        value = string.Format("{0:f6}", this.labelDynamicCorrection.Text);
                        value = value.Remove(1, 1);
                        value = Helper.StringZeroFillDigits7(value);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5006_DynamicCorrection, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection = myKeyPad.doubleValue;
                        value = string.Format("{0:f6}", this.labelDynamicCorrection.Text);
                        value = value.Remove(1, 1);
                        value = Helper.StringZeroFillDigits7(value);
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5026_DynamicCorrection, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                }
            }
        }
        private void labelDescendDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime = myKeyPad.IntValue;
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5012_DownDelayTime1, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime = myKeyPad.IntValue;
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5029_DownDelayTime2, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }                   
                }
            }
        }
        private void labelAscendDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

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

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

                    if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                    {
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime = myKeyPad.IntValue;
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5011_UpDelayTime1, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }
                    else
                    {
                        value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                        this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime = myKeyPad.IntValue;
                        this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5028_UpDelayTime2, value);
                        this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
                    }      
                }
            }
        }

        private void buttonDown_Click(object sender, EventArgs e)
        {
            if(this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.MotorDown, CommunicationID.SubBoard1);
            else
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.MotorDown, CommunicationID.SubBoard2);
        }
        private void buttonUp_Click(object sender, EventArgs e)
        {
            if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.MotorUp, CommunicationID.SubBoard1);
            else
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.MotorUp, CommunicationID.SubBoard2);
        }

        private void labelProductNo_Click(object sender, EventArgs e)
        {
            string message = "";

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

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 1000)
                {
                    // 입력범위를 확인하세요
                    message = "1~1000";
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language, message);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelProductNo.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.SystemConfig.ProductNumber = myKeyPad.IntValue;
                    this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig);
                    this.ParentForm.ParentForm.TransferProductParameter1(this.ParentForm.ParentForm.SystemConfig.ProductNumber);
                    this.labelProductNo.Text = "**";
                }
            }
        }   
        private void buttonCopy_Click(object sender, EventArgs e)
        {
            this.buttonCopy.Text = this.labelProductNo.Text;

            #region #1
            this.CaptureJudgmentSetItem1.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter;
            this.CaptureJudgmentSetItem1.DescendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime;
            this.CaptureJudgmentSetItem1.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime;
            this.CaptureJudgmentSetItem1.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime;
            this.CaptureJudgmentSetItem1.AscendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime;
            this.CaptureJudgmentSetItem1.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount;
            this.CaptureJudgmentSetItem1.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1;
            this.CaptureJudgmentSetItem1.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection;
            this.CaptureJudgmentSetItem1.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode;
            this.CaptureJudgmentSetItem1.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime;
            this.CaptureJudgmentSetItem1.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime;
            this.CaptureJudgmentSetItem1.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode;
            this.CaptureJudgmentSetItem1.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime;
            this.CaptureJudgmentSetItem1.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime; 
            #endregion

            #region #2
            this.CaptureJudgmentSetItem2.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter;
            this.CaptureJudgmentSetItem2.DescendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime;
            this.CaptureJudgmentSetItem2.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime;
            this.CaptureJudgmentSetItem2.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime;
            this.CaptureJudgmentSetItem2.AscendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime;
            this.CaptureJudgmentSetItem2.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount;
            this.CaptureJudgmentSetItem2.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1;
            this.CaptureJudgmentSetItem2.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection;
            this.CaptureJudgmentSetItem2.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode;
            this.CaptureJudgmentSetItem2.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime;
            this.CaptureJudgmentSetItem2.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime;
            this.CaptureJudgmentSetItem2.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode;
            this.CaptureJudgmentSetItem2.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime;
            this.CaptureJudgmentSetItem2.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime; 
            #endregion

        }
        private void buttonPaste_Click(object sender, EventArgs e)
        {
            if (this.buttonCopy.Text == "00")
                return;

            #region #1
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter = this.CaptureJudgmentSetItem1.Filter;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime = this.CaptureJudgmentSetItem1.DescendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime = this.CaptureJudgmentSetItem1.JudgmentDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime = this.CaptureJudgmentSetItem1.DoubleDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime = this.CaptureJudgmentSetItem1.AscendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount = this.CaptureJudgmentSetItem1.JudgmentCount;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1 = this.CaptureJudgmentSetItem1.FeedSpeed1;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection = this.CaptureJudgmentSetItem1.DynamicCorrection;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode = this.CaptureJudgmentSetItem1.Sorter1Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime = this.CaptureJudgmentSetItem1.Sorter1DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime = this.CaptureJudgmentSetItem1.Sorter1RunTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode = this.CaptureJudgmentSetItem1.Sorter2Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime = this.CaptureJudgmentSetItem1.Sorter2DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime = this.CaptureJudgmentSetItem1.Sorter2RunTime;
            this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
            #endregion

            #region #2
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter = this.CaptureJudgmentSetItem2.Filter;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime = this.CaptureJudgmentSetItem2.DescendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime = this.CaptureJudgmentSetItem2.JudgmentDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime = this.CaptureJudgmentSetItem2.DoubleDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime = this.CaptureJudgmentSetItem2.AscendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount = this.CaptureJudgmentSetItem2.JudgmentCount;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1 = this.CaptureJudgmentSetItem2.FeedSpeed1;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection = this.CaptureJudgmentSetItem2.DynamicCorrection;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode = this.CaptureJudgmentSetItem2.Sorter1Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime = this.CaptureJudgmentSetItem2.Sorter1DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime = this.CaptureJudgmentSetItem2.Sorter1RunTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode = this.CaptureJudgmentSetItem2.Sorter2Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime = this.CaptureJudgmentSetItem2.Sorter2DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime = this.CaptureJudgmentSetItem2.Sorter2RunTime;
            this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1); 
            #endregion

            this.labelProductNo.Text = "**";
            this.ParentForm.ParentForm.TransferProductParameter1(this.ParentForm.ParentForm.SystemConfig.ProductNumber);
        }
        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.ParentForm.Enabled = false;

            #region #1
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter = this.CaptureJudgmentSetItem1.Filter;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime = this.CaptureJudgmentSetItem1.DescendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime = this.CaptureJudgmentSetItem1.JudgmentDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime = this.CaptureJudgmentSetItem1.DoubleDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime = this.CaptureJudgmentSetItem1.AscendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount = this.CaptureJudgmentSetItem1.JudgmentCount;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1 = this.CaptureJudgmentSetItem1.FeedSpeed1;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed2 = this.CaptureJudgmentSetItem1.FeedSpeed2;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed3 = this.CaptureJudgmentSetItem1.FeedSpeed3;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection = this.CaptureJudgmentSetItem1.DynamicCorrection;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode = this.CaptureJudgmentSetItem1.Sorter1Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime = this.CaptureJudgmentSetItem1.Sorter1DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime = this.CaptureJudgmentSetItem1.Sorter1RunTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode = this.CaptureJudgmentSetItem1.Sorter2Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime = this.CaptureJudgmentSetItem1.Sorter2DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime = this.CaptureJudgmentSetItem1.Sorter2RunTime;

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

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

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter;
                structItem.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime;
                structItem.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount;
                structItem.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1;
                structItem.FeedSpeed2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed2;
                structItem.FeedSpeed3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed3;
                structItem.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection;
                structItem.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode;
                structItem.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime;
                structItem.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime;
                structItem.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode;
                structItem.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime;
                structItem.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime;
                structItem.AutoJudgmentLength = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgmentLength;
                structItem.AutoJudgment1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgment1;
                structItem.AutoJudgment2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgment2;
                structItem.AutoJudgment3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgment3;
                structItem.DescendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime;
                structItem.AscendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";

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

            #region #2
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter = this.CaptureJudgmentSetItem2.Filter;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime = this.CaptureJudgmentSetItem2.DescendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime = this.CaptureJudgmentSetItem2.JudgmentDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime = this.CaptureJudgmentSetItem2.DoubleDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime = this.CaptureJudgmentSetItem2.AscendDelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount = this.CaptureJudgmentSetItem2.JudgmentCount;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1 = this.CaptureJudgmentSetItem2.FeedSpeed1;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed2 = this.CaptureJudgmentSetItem2.FeedSpeed2;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed3 = this.CaptureJudgmentSetItem2.FeedSpeed3;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection = this.CaptureJudgmentSetItem2.DynamicCorrection;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode = this.CaptureJudgmentSetItem2.Sorter1Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime = this.CaptureJudgmentSetItem2.Sorter1DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime = this.CaptureJudgmentSetItem2.Sorter1RunTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode = this.CaptureJudgmentSetItem2.Sorter2Mode;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime = this.CaptureJudgmentSetItem2.Sorter2DelayTime;
            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime = this.CaptureJudgmentSetItem2.Sorter2RunTime;

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

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

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter;
                structItem.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime;
                structItem.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount;
                structItem.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1;
                structItem.FeedSpeed2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed2;
                structItem.FeedSpeed3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed3;
                structItem.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection;
                structItem.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode;
                structItem.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime;
                structItem.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime;
                structItem.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode;
                structItem.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime;
                structItem.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime;
                structItem.AutoJudgmentLength = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgmentLength;
                structItem.AutoJudgment1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgment1;
                structItem.AutoJudgment2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgment2;
                structItem.AutoJudgment3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgment3;
                structItem.DescendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime;
                structItem.AscendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";

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

            this.labelProductNo.Text = "**";
            this.ParentForm.ParentForm.TransferProductParameter1(this.ParentForm.ParentForm.SystemConfig.ProductNumber);

            this.ParentForm.Enabled = true;

            splash.Finish();
        }
        private void buttonWeightReference_Click(object sender, EventArgs e)
        {
            string value = "";

            value = this.labelWeightValue.Text;
            if (this.buttonWeightReference.Text != value)
                this.buttonWeightReference.Text = value;

            this.RefrenceADC = this.labelADCValue.Text;
        }
        private void buttonLine_Click(object sender, EventArgs e)
        {
            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button == this.buttonLine1)
            {
                this.UpdateSystemParameterDisplay(this.ParentForm.ParentForm.CurrentJudgmentSetItem1);
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard1);
            }
            else
            {
                this.UpdateSystemParameterDisplay(this.ParentForm.ParentForm.CurrentJudgmentSetItem2);
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.ModeJudgment, CommunicationID.SubBoard2);
            }

            this.buttonWeightReference.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            this.labelWeightJudgment.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
        }
        private void buttonLineCopy_Click(object sender, EventArgs e)
        {
            if (this.buttonLine1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed2;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed3;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime;
            }

            if (this.buttonLine2.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DescendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DescendDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AscendDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AscendDelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed2;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed3;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime;
                this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime;
            }

            this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
            this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

            this.labelProductNo.Text = "**";
            this.ParentForm.ParentForm.TransferProductParameter1(this.ParentForm.ParentForm.SystemConfig.ProductNumber);
        }
        #endregion
    }
}
