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 INT51DB.Forms;
using INT51DB.DialogForms;
using INT51DB_ImageDll;

namespace INT51DB.Controls
{
    public partial class ControlCenterSystemExternalOutput : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        #endregion

        #region Constructor
        public ControlCenterSystemExternalOutput(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 == DataStore.LanguageID.English)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
            }
            else
            {
            }
        }
        private void DefaultSetting()
        {
            if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                #region English
                this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
                this.comboBoxSorter1Mode.Items.Clear();
                this.comboBoxSorter1Mode.Items.Add("None");
                this.comboBoxSorter1Mode.Items.Add("Over");
                this.comboBoxSorter1Mode.Items.Add("Under");
                this.comboBoxSorter1Mode.Items.Add("NG");
                this.comboBoxSorter1Mode.Items.Add("Pass");
                this.comboBoxSorter1Mode.Items.Add("Run");
                this.comboBoxSorter1Mode.Items.Add("Count");
                this.comboBoxSorter1Mode.Items.Add("Alarm");
                this.comboBoxSorter1Mode.Items.Add("ExNG");
                this.comboBoxSorter1Mode.Items.Add("Stopper1");
                this.comboBoxSorter1Mode.Items.Add("Stopper2");
                this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);

                this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
                this.comboBoxSorter2Mode.Items.Clear();
                this.comboBoxSorter2Mode.Items.Add("None");
                this.comboBoxSorter2Mode.Items.Add("Over");
                this.comboBoxSorter2Mode.Items.Add("Under");
                this.comboBoxSorter2Mode.Items.Add("NG");
                this.comboBoxSorter2Mode.Items.Add("Pass");
                this.comboBoxSorter2Mode.Items.Add("Run");
                this.comboBoxSorter2Mode.Items.Add("Count");
                this.comboBoxSorter2Mode.Items.Add("Alarm");
                this.comboBoxSorter2Mode.Items.Add("ExNG");
                this.comboBoxSorter2Mode.Items.Add("Stopper1");
                this.comboBoxSorter2Mode.Items.Add("Stopper2");
                this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

                this.comboBoxSorter3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter3Mode_SelectedIndexChanged);
                this.comboBoxSorter3Mode.Items.Clear();
                this.comboBoxSorter3Mode.Items.Add("None");
                this.comboBoxSorter3Mode.Items.Add("Over");
                this.comboBoxSorter3Mode.Items.Add("Under");
                this.comboBoxSorter3Mode.Items.Add("NG");
                this.comboBoxSorter3Mode.Items.Add("Pass");
                this.comboBoxSorter3Mode.Items.Add("Run");
                this.comboBoxSorter3Mode.Items.Add("Count");
                this.comboBoxSorter3Mode.Items.Add("Alarm");
                this.comboBoxSorter3Mode.Items.Add("ExNG");
                this.comboBoxSorter3Mode.Items.Add("Stopper1");
                this.comboBoxSorter3Mode.Items.Add("Stopper2");
                this.comboBoxSorter3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter3Mode_SelectedIndexChanged);

                this.comboBoxSorter4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter4Mode_SelectedIndexChanged);
                this.comboBoxSorter4Mode.Items.Clear();
                this.comboBoxSorter4Mode.Items.Add("None");
                this.comboBoxSorter4Mode.Items.Add("Over");
                this.comboBoxSorter4Mode.Items.Add("Under");
                this.comboBoxSorter4Mode.Items.Add("NG");
                this.comboBoxSorter4Mode.Items.Add("Pass");
                this.comboBoxSorter4Mode.Items.Add("Run");
                this.comboBoxSorter4Mode.Items.Add("Count");
                this.comboBoxSorter4Mode.Items.Add("Alarm");
                this.comboBoxSorter4Mode.Items.Add("ExNG");
                this.comboBoxSorter4Mode.Items.Add("Stopper1");
                this.comboBoxSorter4Mode.Items.Add("Stopper2");
                this.comboBoxSorter4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter4Mode_SelectedIndexChanged);

                this.comboBoxSorter9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter9Mode_SelectedIndexChanged);
                this.comboBoxSorter9Mode.Items.Clear();
                this.comboBoxSorter9Mode.Items.Add("None");
                this.comboBoxSorter9Mode.Items.Add("Pass");
                this.comboBoxSorter9Mode.Items.Add("NG");
                this.comboBoxSorter9Mode.Items.Add("Run");
                this.comboBoxSorter9Mode.Items.Add("Pass alarm");
                this.comboBoxSorter9Mode.Items.Add("Alarm");
                this.comboBoxSorter9Mode.Items.Add("ExNG");
                this.comboBoxSorter9Mode.Items.Add("Stopper1");
                this.comboBoxSorter9Mode.Items.Add("Stopper2");
                this.comboBoxSorter9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter9Mode_SelectedIndexChanged);

                this.comboBoxSorter10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter10Mode_SelectedIndexChanged);
                this.comboBoxSorter10Mode.Items.Clear();
                this.comboBoxSorter10Mode.Items.Add("None");
                this.comboBoxSorter10Mode.Items.Add("Pass");
                this.comboBoxSorter10Mode.Items.Add("NG");
                this.comboBoxSorter10Mode.Items.Add("Run");
                this.comboBoxSorter10Mode.Items.Add("Pass alarm");
                this.comboBoxSorter10Mode.Items.Add("Alarm");
                this.comboBoxSorter10Mode.Items.Add("ExNG");
                this.comboBoxSorter10Mode.Items.Add("Stopper1");
                this.comboBoxSorter10Mode.Items.Add("Stopper2");
                this.comboBoxSorter10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter10Mode_SelectedIndexChanged);
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
            }
            else
            {
                #region Korean
                this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
                this.comboBoxSorter1Mode.Items.Clear();
                this.comboBoxSorter1Mode.Items.Add("사용안함");
                this.comboBoxSorter1Mode.Items.Add("과량");
                this.comboBoxSorter1Mode.Items.Add("경량");
                this.comboBoxSorter1Mode.Items.Add("불량");
                this.comboBoxSorter1Mode.Items.Add("정량");
                this.comboBoxSorter1Mode.Items.Add("운전");
                this.comboBoxSorter1Mode.Items.Add("개수");
                this.comboBoxSorter1Mode.Items.Add("알람");
                this.comboBoxSorter1Mode.Items.Add("ExNG");
                this.comboBoxSorter1Mode.Items.Add("스토퍼1");
                this.comboBoxSorter1Mode.Items.Add("스토퍼2");
                this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);

                this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
                this.comboBoxSorter2Mode.Items.Clear();
                this.comboBoxSorter2Mode.Items.Add("사용안함");
                this.comboBoxSorter2Mode.Items.Add("과량");
                this.comboBoxSorter2Mode.Items.Add("경량");
                this.comboBoxSorter2Mode.Items.Add("불량");
                this.comboBoxSorter2Mode.Items.Add("정량");
                this.comboBoxSorter2Mode.Items.Add("운전");
                this.comboBoxSorter2Mode.Items.Add("개수");
                this.comboBoxSorter2Mode.Items.Add("알람");
                this.comboBoxSorter2Mode.Items.Add("ExNG");
                this.comboBoxSorter2Mode.Items.Add("스토퍼1");
                this.comboBoxSorter2Mode.Items.Add("스토퍼2");
                this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

                this.comboBoxSorter3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter3Mode_SelectedIndexChanged);
                this.comboBoxSorter3Mode.Items.Clear();
                this.comboBoxSorter3Mode.Items.Add("사용안함");
                this.comboBoxSorter3Mode.Items.Add("과량");
                this.comboBoxSorter3Mode.Items.Add("경량");
                this.comboBoxSorter3Mode.Items.Add("불량");
                this.comboBoxSorter3Mode.Items.Add("정량");
                this.comboBoxSorter3Mode.Items.Add("운전");
                this.comboBoxSorter3Mode.Items.Add("개수");
                this.comboBoxSorter3Mode.Items.Add("알람");
                this.comboBoxSorter3Mode.Items.Add("ExNG");
                this.comboBoxSorter3Mode.Items.Add("스토퍼1");
                this.comboBoxSorter3Mode.Items.Add("스토퍼2");
                this.comboBoxSorter3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter3Mode_SelectedIndexChanged);

                this.comboBoxSorter4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter4Mode_SelectedIndexChanged);
                this.comboBoxSorter4Mode.Items.Clear();
                this.comboBoxSorter4Mode.Items.Add("사용안함");
                this.comboBoxSorter4Mode.Items.Add("과량");
                this.comboBoxSorter4Mode.Items.Add("경량");
                this.comboBoxSorter4Mode.Items.Add("불량");
                this.comboBoxSorter4Mode.Items.Add("정량");
                this.comboBoxSorter4Mode.Items.Add("운전");
                this.comboBoxSorter4Mode.Items.Add("개수");
                this.comboBoxSorter4Mode.Items.Add("알람");
                this.comboBoxSorter4Mode.Items.Add("ExNG");
                this.comboBoxSorter4Mode.Items.Add("스토퍼1");
                this.comboBoxSorter4Mode.Items.Add("스토퍼2");
                this.comboBoxSorter4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter4Mode_SelectedIndexChanged);

                this.comboBoxSorter9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter9Mode_SelectedIndexChanged);
                this.comboBoxSorter9Mode.Items.Clear();
                this.comboBoxSorter9Mode.Items.Add("사용안함");
                this.comboBoxSorter9Mode.Items.Add("정량");
                this.comboBoxSorter9Mode.Items.Add("불량");
                this.comboBoxSorter9Mode.Items.Add("운전");
                this.comboBoxSorter9Mode.Items.Add("정량알람");
                this.comboBoxSorter9Mode.Items.Add("알람");
                this.comboBoxSorter9Mode.Items.Add("ExNG");
                this.comboBoxSorter9Mode.Items.Add("스토퍼1");
                this.comboBoxSorter9Mode.Items.Add("스토퍼2");
                this.comboBoxSorter9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter9Mode_SelectedIndexChanged);

                this.comboBoxSorter10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter10Mode_SelectedIndexChanged);
                this.comboBoxSorter10Mode.Items.Clear();
                this.comboBoxSorter10Mode.Items.Add("사용안함");
                this.comboBoxSorter10Mode.Items.Add("정량");
                this.comboBoxSorter10Mode.Items.Add("불량");
                this.comboBoxSorter10Mode.Items.Add("운전");
                this.comboBoxSorter10Mode.Items.Add("정량알람");
                this.comboBoxSorter10Mode.Items.Add("알람");
                this.comboBoxSorter10Mode.Items.Add("ExNG");
                this.comboBoxSorter10Mode.Items.Add("스토퍼1");
                this.comboBoxSorter10Mode.Items.Add("스토퍼2");
                this.comboBoxSorter10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter10Mode_SelectedIndexChanged); 
                #endregion
            }            
        }

        private void SetControls(SystemParameter3 item)
        {
            string value = "";
            int index = 0;

            #region ExternalOut1
            this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut1Mode.Trim());
            if (this.comboBoxSorter1Mode.SelectedIndex != index)
                this.comboBoxSorter1Mode.SelectedIndex = index;
            this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
            value = item.ExternalOut1DelayTime.Trim();
            if (this.labelSorter1DelayTime.Text != value)
                this.labelSorter1DelayTime.Text = value;
            value = item.ExternalOut1RunTime.Trim();
            if (this.labelSorter1RunTime.Text != value)
                this.labelSorter1RunTime.Text = value; 
            #endregion

            #region ExternalOut2
            this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut2Mode.Trim());
            if (this.comboBoxSorter2Mode.SelectedIndex != index)
                this.comboBoxSorter2Mode.SelectedIndex = index;
            this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
            value = item.ExternalOut2DelayTime.Trim();
            if (this.labelSorter2DelayTime.Text != value)
                this.labelSorter2DelayTime.Text = value;
            value = item.ExternalOut2RunTime.Trim();
            if (this.labelSorter2RunTime.Text != value)
                this.labelSorter2RunTime.Text = value;
            #endregion

            #region ExternalOut3
            this.comboBoxSorter3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter3Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut3Mode.Trim());
            if (this.comboBoxSorter3Mode.SelectedIndex != index)
                this.comboBoxSorter3Mode.SelectedIndex = index;
            this.comboBoxSorter3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter3Mode_SelectedIndexChanged);
            value = item.ExternalOut3DelayTime.Trim();
            if (this.labelSorter3DelayTime.Text != value)
                this.labelSorter3DelayTime.Text = value;
            value = item.ExternalOut3RunTime.Trim();
            if (this.labelSorter3RunTime.Text != value)
                this.labelSorter3RunTime.Text = value;
            #endregion

            #region ExternalOut4
            this.comboBoxSorter4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter4Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut4Mode.Trim());
            if (this.comboBoxSorter4Mode.SelectedIndex != index)
                this.comboBoxSorter4Mode.SelectedIndex = index;
            this.comboBoxSorter4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter4Mode_SelectedIndexChanged);
            value = item.ExternalOut4DelayTime.Trim();
            if (this.labelSorter4DelayTime.Text != value)
                this.labelSorter4DelayTime.Text = value;
            value = item.ExternalOut4RunTime.Trim();
            if (this.labelSorter4RunTime.Text != value)
                this.labelSorter4RunTime.Text = value;
            #endregion

            #region ExternalOut5
            this.comboBoxSorter9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter9Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut9Mode.Trim());
            if (this.comboBoxSorter9Mode.SelectedIndex != index)
                this.comboBoxSorter9Mode.SelectedIndex = index;
            this.comboBoxSorter9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter9Mode_SelectedIndexChanged);
            value = item.ExternalOut9DelayTime.Trim();
            if (this.labelSorter9DelayTime.Text != value)
                this.labelSorter9DelayTime.Text = value;
            value = item.ExternalOut9RunTime.Trim();
            if (this.labelSorter9RunTime.Text != value)
                this.labelSorter9RunTime.Text = value;
            #endregion

            #region ExternalOut6
            this.comboBoxSorter10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter10Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut10Mode.Trim());
            if (this.comboBoxSorter10Mode.SelectedIndex != index)
                this.comboBoxSorter10Mode.SelectedIndex = index;
            this.comboBoxSorter10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter10Mode_SelectedIndexChanged);
            value = item.ExternalOut10DelayTime.Trim();
            if (this.labelSorter10DelayTime.Text != value)
                this.labelSorter10DelayTime.Text = value;
            value = item.ExternalOut10RunTime.Trim();
            if (this.labelSorter10RunTime.Text != value)
                this.labelSorter10RunTime.Text = value;
            #endregion
        }

        public void DisplayRefresh(DataStore.UserGroup group)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.SystemExternalOutput;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.SetControls(this.ParentForm.ParentForm.CurrentSystemParameter3);
        }
        #endregion

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

            this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1Mode = this.comboBoxSorter1Mode.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxSorter1Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut1Mode, value);
        }
        private void labelSorter1DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter1DelayTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1DelayTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut1DelayTime, value);
                }
            }
        }
        private void labelSorter1RunTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter1RunTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1RunTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut1RunTime, value);
                }
            }
        } 
        #endregion

        #region ExternalOut2
        private void comboBoxSorter2Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2Mode = this.comboBoxSorter2Mode.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxSorter2Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut2Mode, value);
        }
        private void labelSorter2DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter2DelayTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2DelayTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut2DelayTime, value);
                }
            }
        }
        private void labelSorter2RunTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter2RunTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2RunTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut2RunTime, value);
                }
            }
        } 
        #endregion

        #region ExternalOut3
        private void comboBoxSorter3Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3Mode = this.comboBoxSorter3Mode.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxSorter3Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut3Mode, value);
        }
        private void labelSorter3DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter3DelayTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3DelayTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut3DelayTime, value);
                }
            }
        }
        private void labelSorter3RunTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter3RunTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3RunTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut3RunTime, value);
                }
            }
        } 
        #endregion

        #region ExternalOut4
        private void comboBoxSorter4Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode = this.comboBoxSorter4Mode.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxSorter4Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut4Mode, value);
        }
        private void labelSorter4DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter4DelayTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4DelayTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut4DelayTime, value);
                }
            }
        }
        private void labelSorter4RunTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter4RunTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4RunTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut4RunTime, value);
                }
            }
        } 
        #endregion

        #region ExternalOut9
        private void comboBoxSorter9Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut9Mode = this.comboBoxSorter9Mode.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxSorter9Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut9Mode, value);
        }
        private void labelSorter9DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter9DelayTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut9DelayTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut9DelayTime, value);
                }
            }
        }
        private void labelSorter9RunTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter9RunTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut9RunTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut9RunTime, value);
                }
            }
        } 
        #endregion

        #region ExternalOut10
        private void comboBoxSorter10Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut10Mode = this.comboBoxSorter10Mode.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxSorter10Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut10Mode, value);
        }
        private void labelSorter10DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter10DelayTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut10DelayTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut10DelayTime, value);
                }
            }
        }
        private void labelSorter10RunTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSorter10RunTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut10RunTime = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut10RunTime, value);
                }
            }
        } 
        #endregion
        #endregion
    }
}
