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

using ITC81DB.Forms;
using ITC81DB.DialogForms;
using ITC81DB_ImageDll;

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

        private Collection<ComboBox> CollectionComboBox;
        #endregion

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

            this.ParentForm = parent;

            // 순서 바꾸지 말 것
            this.DefaultSetting();
            this.InitializeDesign();
        }
        #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.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                #region English
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundExternalOutput));

                this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);

                for (int i = 0; i < this.CollectionComboBox.Count; i++)
                {
                    this.CollectionComboBox[i].Items.Clear();
                    this.CollectionComboBox[i].Items.Add("None");
                    this.CollectionComboBox[i].Items.Add("Over");
                    this.CollectionComboBox[i].Items.Add("Under");
                    this.CollectionComboBox[i].Items.Add("NG");
                    this.CollectionComboBox[i].Items.Add("Pass");
                    this.CollectionComboBox[i].Items.Add("Run");
                    this.CollectionComboBox[i].Items.Add("Count");
                    this.CollectionComboBox[i].Items.Add("Counting output1");
                    this.CollectionComboBox[i].Items.Add("Counting output2");
                    this.CollectionComboBox[i].Items.Add("ExNG");
                    this.CollectionComboBox[i].Items.Add("Latch control"); // 10
                    this.CollectionComboBox[i].Items.Add("Stopper");
                    this.CollectionComboBox[i].Items.Add("External input");
                    this.CollectionComboBox[i].Items.Add("Alarm(Level)");
                    this.CollectionComboBox[i].Items.Add("Alarm(Pulse)");
                }

                this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                #region Chinese
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundExternalOutput));

                this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);

                for (int i = 0; i < this.CollectionComboBox.Count; i++)
                {
                    this.CollectionComboBox[i].Items.Clear();
                    this.CollectionComboBox[i].Items.Add("不使用");
                    this.CollectionComboBox[i].Items.Add("超过");
                    this.CollectionComboBox[i].Items.Add("低于");
                    this.CollectionComboBox[i].Items.Add("不良");
                    this.CollectionComboBox[i].Items.Add("通过");
                    this.CollectionComboBox[i].Items.Add("运行");
                    this.CollectionComboBox[i].Items.Add("计数");
                    this.CollectionComboBox[i].Items.Add("计数输出1");
                    this.CollectionComboBox[i].Items.Add("计数输出2");
                    this.CollectionComboBox[i].Items.Add("其他不良");
                    this.CollectionComboBox[i].Items.Add("闩锁控制");
                    this.CollectionComboBox[i].Items.Add("阻挡器");
                    this.CollectionComboBox[i].Items.Add("外部输入");
                    this.CollectionComboBox[i].Items.Add("警报(级别)");
                    this.CollectionComboBox[i].Items.Add("警报(脉冲)");
                }

                this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                #region Russian
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.rusBackgroundExternalOutput));

                this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);

                for (int i = 0; i < this.CollectionComboBox.Count; i++)
                {
                    this.CollectionComboBox[i].Items.Clear();
                    this.CollectionComboBox[i].Items.Add("Нет");
                    this.CollectionComboBox[i].Items.Add("Много");
                    this.CollectionComboBox[i].Items.Add("Мало");
                    this.CollectionComboBox[i].Items.Add("Дефект");
                    this.CollectionComboBox[i].Items.Add("Норма");
                    this.CollectionComboBox[i].Items.Add("Выполнение");
                    this.CollectionComboBox[i].Items.Add("Подсчет");
                    this.CollectionComboBox[i].Items.Add("Счетный выход1");
                    this.CollectionComboBox[i].Items.Add("Счетный выход2");
                    this.CollectionComboBox[i].Items.Add("Другие неисправности");
                    this.CollectionComboBox[i].Items.Add("контроль защелки");
                    this.CollectionComboBox[i].Items.Add("Остановка");
                    this.CollectionComboBox[i].Items.Add("Внешний вход");
                    this.CollectionComboBox[i].Items.Add("Сигнализация(Уровень)");
                    this.CollectionComboBox[i].Items.Add("Сигнализация(имп)");
                }

                this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                #region German
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundExternalOutput));

                this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);

                for (int i = 0; i < this.CollectionComboBox.Count; i++)
                {
                    this.CollectionComboBox[i].Items.Clear();
                    this.CollectionComboBox[i].Items.Add("Keiner");
                    this.CollectionComboBox[i].Items.Add("Max.");
                    this.CollectionComboBox[i].Items.Add("Min.");
                    this.CollectionComboBox[i].Items.Add("Schlecht");
                    this.CollectionComboBox[i].Items.Add("Bestehen");
                    this.CollectionComboBox[i].Items.Add("Lauf");
                    this.CollectionComboBox[i].Items.Add("Einstellen");
                    this.CollectionComboBox[i].Items.Add("Zählen der Ausgabe1");
                    this.CollectionComboBox[i].Items.Add("Zählen der Ausgabe2");
                    this.CollectionComboBox[i].Items.Add("Ex.Schlecht");
                    this.CollectionComboBox[i].Items.Add("Verriegelungssteuerung");
                    this.CollectionComboBox[i].Items.Add("Stoppen");
                    this.CollectionComboBox[i].Items.Add("Externer Eingang");
                    this.CollectionComboBox[i].Items.Add("Alarm(Stufe)");
                    this.CollectionComboBox[i].Items.Add("Alarm(Impuls)");
                }

                this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);          
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                #region 스페인어
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundExternalOutput));

                this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);

                for (int i = 0; i < this.CollectionComboBox.Count; i++)
                {
                    this.CollectionComboBox[i].Items.Clear();
                    this.CollectionComboBox[i].Items.Add("Ninguna");
                    this.CollectionComboBox[i].Items.Add("Superior");
                    this.CollectionComboBox[i].Items.Add("Inferior");
                    this.CollectionComboBox[i].Items.Add("NG");
                    this.CollectionComboBox[i].Items.Add("Referencia");
                    this.CollectionComboBox[i].Items.Add("Correr");
                    this.CollectionComboBox[i].Items.Add("Conteo");
                    this.CollectionComboBox[i].Items.Add("Conteo de salida1");
                    this.CollectionComboBox[i].Items.Add("Conteo de salida2");
                    this.CollectionComboBox[i].Items.Add("Otro rechazo");
                    this.CollectionComboBox[i].Items.Add("Control de pestillo"); // 10
                    this.CollectionComboBox[i].Items.Add("Tapón");
                    this.CollectionComboBox[i].Items.Add("Salida internet");
                    this.CollectionComboBox[i].Items.Add("Alarma(Nivel)");
                    this.CollectionComboBox[i].Items.Add("Alarma(Pulso)");
                }

                this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);
                #endregion
            }
            else
            {
                #region Korean
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundExternalOutput));

                this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);

                for (int i = 0; i < this.CollectionComboBox.Count; i++)
                {
                    this.CollectionComboBox[i].Items.Clear();
                    this.CollectionComboBox[i].Items.Add("사용안함");
                    this.CollectionComboBox[i].Items.Add("과량");
                    this.CollectionComboBox[i].Items.Add("경량");
                    this.CollectionComboBox[i].Items.Add("불량");
                    this.CollectionComboBox[i].Items.Add("정량");
                    this.CollectionComboBox[i].Items.Add("운전"); // 5
                    this.CollectionComboBox[i].Items.Add("개수");
                    this.CollectionComboBox[i].Items.Add("카운터출력1");
                    this.CollectionComboBox[i].Items.Add("카운터출력2");
                    this.CollectionComboBox[i].Items.Add("ExNG");
                    this.CollectionComboBox[i].Items.Add("시건장치 제어"); // 10
                    this.CollectionComboBox[i].Items.Add("Stopper");
                    this.CollectionComboBox[i].Items.Add("외부입력");
                    this.CollectionComboBox[i].Items.Add("알람(Level)");
                    this.CollectionComboBox[i].Items.Add("알람(Pulse)");
                }

                this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
                this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
                this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
                this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
                this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
                this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);       
                #endregion
            }            
        }
        private void DefaultSetting()
        {
            this.CollectionComboBox = new Collection<ComboBox>();
            this.CollectionComboBox.Clear();
            this.CollectionComboBox.Add(this.comboBoxExOutput1Mode);
            this.CollectionComboBox.Add(this.comboBoxExOutput2Mode);
            this.CollectionComboBox.Add(this.comboBoxExOutput3Mode);
            this.CollectionComboBox.Add(this.comboBoxExOutput4Mode);
            this.CollectionComboBox.Add(this.comboBoxExOutput9Mode);
            this.CollectionComboBox.Add(this.comboBoxExOutput10Mode);
        }

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

            #region ExternalOut1
            this.comboBoxExOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput1Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut1Mode.Trim());
            if (this.comboBoxExOutput1Mode.SelectedIndex != index)
                this.comboBoxExOutput1Mode.SelectedIndex = index;
            this.comboBoxExOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput1Mode_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.comboBoxExOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput2Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut2Mode.Trim());
            if (this.comboBoxExOutput2Mode.SelectedIndex != index)
                this.comboBoxExOutput2Mode.SelectedIndex = index;
            this.comboBoxExOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput2Mode_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.comboBoxExOutput3Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput3Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut3Mode.Trim());
            if (this.comboBoxExOutput3Mode.SelectedIndex != index)
                this.comboBoxExOutput3Mode.SelectedIndex = index;
            this.comboBoxExOutput3Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput3Mode_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.comboBoxExOutput4Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput4Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut4Mode.Trim());
            if (this.comboBoxExOutput4Mode.SelectedIndex != index)
                this.comboBoxExOutput4Mode.SelectedIndex = index;
            this.comboBoxExOutput4Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput4Mode_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 ExternalOut9
            this.comboBoxExOutput9Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput9Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut9Mode.Trim());
            if (this.comboBoxExOutput9Mode.SelectedIndex != index)
                this.comboBoxExOutput9Mode.SelectedIndex = index;
            this.comboBoxExOutput9Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput9Mode_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 ExternalOut10
            this.comboBoxExOutput10Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxExOutput10Mode_SelectedIndexChanged);
            index = int.Parse(item.ExternalOut10Mode.Trim());
            if (this.comboBoxExOutput10Mode.SelectedIndex != index)
                this.comboBoxExOutput10Mode.SelectedIndex = index;
            this.comboBoxExOutput10Mode.SelectedIndexChanged += new EventHandler(this.comboBoxExOutput10Mode_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(SystemStatus status)
        {
            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 comboBoxExOutput1Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

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

            value = Helper.StringZeroFillDigits4(this.comboBoxExOutput1Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            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.SystemConfig1.Language);

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

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

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
                    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.SystemConfig1.Language);

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

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

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

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

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

            value = Helper.StringZeroFillDigits4(this.comboBoxExOutput2Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            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.SystemConfig1.Language);

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

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

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
                    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.SystemConfig1.Language);

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

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

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

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

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

            value = Helper.StringZeroFillDigits4(this.comboBoxExOutput3Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            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.SystemConfig1.Language);

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

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

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
                    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.SystemConfig1.Language);

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

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

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

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

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

            value = Helper.StringZeroFillDigits4(this.comboBoxExOutput4Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            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.SystemConfig1.Language);

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

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

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
                    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.SystemConfig1.Language);

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

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

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

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

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

            value = Helper.StringZeroFillDigits4(this.comboBoxExOutput9Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            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.SystemConfig1.Language);

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

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

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
                    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.SystemConfig1.Language);

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

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

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

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

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

            value = Helper.StringZeroFillDigits4(this.comboBoxExOutput10Mode.SelectedIndex.ToString());
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            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.SystemConfig1.Language);

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

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

                    value = Helper.StringZeroFillDigits4(myKeyPad.StringValue);
                    this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
                    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.SystemConfig1.Language);

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

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

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