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.Forms;
using ITC81DB_ImageDll;
using ITC81DB.DialogForms;

namespace ITC81DB
{
    public partial class ControlCenterConfiCountingOutput : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        #endregion

        #region Constructor
        public ControlCenterConfiCountingOutput(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();
            this.comboBox1Mode.Items.Clear();
            this.comboBox2Mode.Items.Clear();
            this.comboBox1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);
            this.comboBox2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm2Mode_SelectedIndexChanged);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundCounterOutput));

                this.comboBox1Mode.Items.Add("None");
                this.comboBox1Mode.Items.Add("Pass");
                this.comboBox1Mode.Items.Add("NG");
                this.comboBox1Mode.Items.Add("Over");
                this.comboBox1Mode.Items.Add("Under");
                this.comboBox1Mode.Items.Add("ExNG");
                this.comboBox1Mode.Items.Add("Metal");
                this.comboBox1Mode.Items.Add("Double");
                this.comboBox1Mode.Items.Add("ExNG1");
                this.comboBox1Mode.Items.Add("ExNG2");

                this.comboBox2Mode.Items.Add("None");
                this.comboBox2Mode.Items.Add("Pass");
                this.comboBox2Mode.Items.Add("NG");
                this.comboBox2Mode.Items.Add("Over");
                this.comboBox2Mode.Items.Add("Under");
                this.comboBox2Mode.Items.Add("ExNG");
                this.comboBox2Mode.Items.Add("Metal");
                this.comboBox2Mode.Items.Add("Double");
                this.comboBox2Mode.Items.Add("ExNG1");
                this.comboBox2Mode.Items.Add("ExNG2");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "Auto Reset";
                this.checkBox1ConveyorStop.Text = this.checkBox2ConveyorStop.Text = "Equipment stop";
                this.checkBox1BuzzerOn.Text = this.checkBox2BuzzerOn.Text = "Buzzering";
                this.checkBox1ExternalOutput.Text = this.checkBox2ExternalOutput.Text = "External output";
                this.checkBox1AutoReset.Text = this.checkBox2AutoReset.Text = "Auto reset";
                this.checkBoxSequentialMode.Text = "Cross mode";

                this.labelHelp1.Font = new Font("새굴림", 9, FontStyle.Regular);
                this.labelHelp1.Text = "- Equipment stop : Equipment stop when counted by the set number";
                this.labelHelp2.Text = "- Buzzering : Buzzering when counted by set number(Time : Buzzer ON time)";
                this.labelHelp3.Text = "- External output : Signal output to external output contact when measured by";
                this.labelHelp4.Text = "the number of modes ('Counting Output 1 or 2' setting)";
                this.labelHelp5.Text = "- Auto reset : When the 'judgment value >= set value', the count initialize";
                this.labelHelp6.Text = "- Cross mode : 2 progress after 1 condition is met, 1 progress again after 2 conditions are met";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundCountingOutput));

                this.comboBox1Mode.Items.Add("不使用");
                this.comboBox1Mode.Items.Add("通过");
                this.comboBox1Mode.Items.Add("不良");
                this.comboBox1Mode.Items.Add("超过");
                this.comboBox1Mode.Items.Add("低于");
                this.comboBox1Mode.Items.Add("其他不良");
                this.comboBox1Mode.Items.Add("金属检出");
                this.comboBox1Mode.Items.Add("重复进入");
                this.comboBox1Mode.Items.Add("其他不良1");
                this.comboBox1Mode.Items.Add("其他不良2");

                this.comboBox2Mode.Items.Add("不使用");
                this.comboBox2Mode.Items.Add("通过");
                this.comboBox2Mode.Items.Add("不良");
                this.comboBox2Mode.Items.Add("超过");
                this.comboBox2Mode.Items.Add("低于");
                this.comboBox2Mode.Items.Add("其他不良");
                this.comboBox2Mode.Items.Add("金属检出");
                this.comboBox2Mode.Items.Add("重复进入");
                this.comboBox2Mode.Items.Add("其他不良1");
                this.comboBox2Mode.Items.Add("其他不良2");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "Auto Reset";
                this.checkBox1ConveyorStop.Text = this.checkBox2ConveyorStop.Text = "设备停止";
                this.checkBox1BuzzerOn.Text = this.checkBox2BuzzerOn.Text = "嗡嗡声";
                this.checkBox1ExternalOutput.Text = this.checkBox2ExternalOutput.Text = "外部输出";
                this.checkBox1AutoReset.Text = this.checkBox2AutoReset.Text = "自动复位";
                this.checkBoxSequentialMode.Text = "交叉模式";

                this.labelHelp1.Font = new Font("새굴림", 9, FontStyle.Regular);
                this.labelHelp1.Text = "- 设备停止：计数设定数量后停止设备";
                this.labelHelp2.Text = "- 蜂鸣器声音：设置次数后蜂鸣器声音(时间：蜂鸣器开启时间）";
                this.labelHelp3.Text = "- 外部输出：计数到设定数量时，信号输出到外部输出触点";
                this.labelHelp4.Text = "（系统设定-信号输出到设置为外部输出'计数输出'的触点）";
                this.labelHelp5.Text = "- 自动复位：未设置测量值时计数复位";
                this.labelHelp6.Text = "- 交叉模式：满足1个条件后获得2个进度，满足2个条件后再次获得1个进度";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.rusBackgroundCounterOutput));

                this.comboBox1Mode.Items.Add("Нет");
                this.comboBox1Mode.Items.Add("Норма");
                this.comboBox1Mode.Items.Add("Дефект");
                this.comboBox1Mode.Items.Add("Много");
                this.comboBox1Mode.Items.Add("Мало");
                this.comboBox1Mode.Items.Add("Другие дефект");
                this.comboBox1Mode.Items.Add("Металл");
                this.comboBox1Mode.Items.Add("Двойной");
                this.comboBox1Mode.Items.Add("Другие дефект1");
                this.comboBox1Mode.Items.Add("Другие дефект2");

                this.comboBox2Mode.Items.Add("Нет");
                this.comboBox2Mode.Items.Add("Норма");
                this.comboBox2Mode.Items.Add("Дефект");
                this.comboBox2Mode.Items.Add("Много");
                this.comboBox2Mode.Items.Add("Мало");
                this.comboBox2Mode.Items.Add("Другие дефект");
                this.comboBox2Mode.Items.Add("Металл");
                this.comboBox2Mode.Items.Add("Двойной");
                this.comboBox2Mode.Items.Add("Другие дефект1");
                this.comboBox2Mode.Items.Add("Другие дефект2");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "자동 리셋";
                this.checkBox1ConveyorStop.Text = this.checkBox2ConveyorStop.Text = "Остановка оборудования";
                this.checkBox1BuzzerOn.Text = this.checkBox2BuzzerOn.Text = "Звуковой сигнал";
                this.checkBox1ExternalOutput.Text = this.checkBox2ExternalOutput.Text = "Внешний выход";
                this.checkBox1AutoReset.Text = this.checkBox2AutoReset.Text = "Автоматический сброс";
                this.checkBoxSequentialMode.Text = "Перекрестный режим";

                this.labelHelp1.Font = new Font("새굴림", 8, FontStyle.Regular);
                this.labelHelp1.Text = "- Остановка оборудования: останавливает оборудование при подсчете установленного числа";
                this.labelHelp2.Text = "- Звуковой сигнал : Звуковой сигнал при подсчете установленного числа";
                this.labelHelp3.Text = "- Внешний выход : сигнал выхода на внешний выходной контакт при измерении количества";
                this.labelHelp4.Text = "режимов";
                this.labelHelp5.Text = "- Автоматический сброс : сброс счетчика, когда измеренное значение не установлено";
                this.labelHelp6.Text = "- Перекрестный режим : 2 прогресса после выполнения 1 условия, 1 прогресс снова при выполнении 2 условий";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundCounterOutput));

                this.comboBox1Mode.Items.Add("Keiner");
                this.comboBox1Mode.Items.Add("Bestehen");
                this.comboBox1Mode.Items.Add("Schlecht");
                this.comboBox1Mode.Items.Add("Max.");
                this.comboBox1Mode.Items.Add("Min.");
                this.comboBox1Mode.Items.Add("Andere Schlecht");
                this.comboBox1Mode.Items.Add("Metall");
                this.comboBox1Mode.Items.Add("Doppelte Eingabe");
                this.comboBox1Mode.Items.Add("Andere Schlecht1");
                this.comboBox1Mode.Items.Add("Andere Schlecht2");

                this.comboBox2Mode.Items.Add("Keiner");
                this.comboBox2Mode.Items.Add("Bestehen");
                this.comboBox2Mode.Items.Add("Schlecht");
                this.comboBox2Mode.Items.Add("Max.");
                this.comboBox2Mode.Items.Add("Min.");
                this.comboBox2Mode.Items.Add("Andere Schlecht");
                this.comboBox2Mode.Items.Add("Metall");
                this.comboBox2Mode.Items.Add("Doppelte Eingabe");
                this.comboBox2Mode.Items.Add("Andere Schlecht1");
                this.comboBox2Mode.Items.Add("Andere Schlecht2");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "자동 리셋";
                this.checkBox1ConveyorStop.Text = this.checkBox2ConveyorStop.Text = "Ausrüstung stoppt";
                this.checkBox1BuzzerOn.Text = this.checkBox2BuzzerOn.Text = "Summer-Einschalt";
                this.checkBox1ExternalOutput.Text = this.checkBox2ExternalOutput.Text = "Externer Ausgang";
                this.checkBox1AutoReset.Text = this.checkBox2AutoReset.Text = "Automatisches Zurücksetzen";
                this.checkBoxSequentialMode.Text = "Cross-Modus";

                this.labelHelp1.Font = new Font("새굴림", 9, FontStyle.Regular);
                this.labelHelp1.Text = "- Ausrüstung stoppt : Gerät stoppt, wenn es nach der eingestellten Nummer gezählt wird";
                this.labelHelp2.Text = "- Summer-Einschalt : Summertöne, wenn nach eingestellter Nummer gezählt(Zeit : Summer-Einschaltzeit)";
                this.labelHelp3.Text = "- Externer Ausgang : Signalausgang an externen Ausgangskontakt, wenn anhand der Anzahl";
                this.labelHelp4.Text = "der Modi gemessen (Einstellung 'Zählen der Ausgabe')";
                this.labelHelp5.Text = "- Automatisches Zurücksetzen : Wenn ein anderer Beurteilungswert als der Einstellmodus gemessen wird, wird die nummer initialisiert";
                this.labelHelp6.Text = "- Cross-Modus : 2 Fortschritte, nachdem 1 Bedingung erfüllt ist, 1 erneuter Fortschritt, wenn 2 Bedingungen erfüllt sind";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundCounterOutput));

                this.comboBox1Mode.Items.Add("Ninguna");
                this.comboBox1Mode.Items.Add("Referencia");
                this.comboBox1Mode.Items.Add("NG");
                this.comboBox1Mode.Items.Add("Superior");
                this.comboBox1Mode.Items.Add("Inferior");
                this.comboBox1Mode.Items.Add("Otro rechazo");
                this.comboBox1Mode.Items.Add("Metales");
                this.comboBox1Mode.Items.Add("Doble");
                this.comboBox1Mode.Items.Add("Otro rechazo1");
                this.comboBox1Mode.Items.Add("Otro rechazo2");

                this.comboBox2Mode.Items.Add("Ninguna");
                this.comboBox2Mode.Items.Add("Referencia");
                this.comboBox2Mode.Items.Add("NG");
                this.comboBox2Mode.Items.Add("Superior");
                this.comboBox2Mode.Items.Add("Inferior");
                this.comboBox2Mode.Items.Add("Otro rechazo");
                this.comboBox2Mode.Items.Add("Metales");
                this.comboBox2Mode.Items.Add("Doble");
                this.comboBox2Mode.Items.Add("Otro rechazo1");
                this.comboBox2Mode.Items.Add("Otro rechazo2");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "Auto Reset";
                this.checkBox1ConveyorStop.Text = this.checkBox2ConveyorStop.Text = "Parada de equipos";
                this.checkBox1BuzzerOn.Text = this.checkBox2BuzzerOn.Text = "Zumbido";
                this.checkBox1ExternalOutput.Text = this.checkBox2ExternalOutput.Text = "Salida externa";
                this.checkBox1AutoReset.Text = this.checkBox2AutoReset.Text = "Restablecimiento automático";
                this.checkBoxSequentialMode.Text = "Modo cruzado";

                this.labelHelp1.Font = new Font("새굴림", 9, FontStyle.Regular);
                this.labelHelp1.Text = "- Parada de equipos : El equipo se detiene cuando se cuenta por el número establecido";
                this.labelHelp2.Text = "- Zumbido : Zumbido cuando se cuenta por número establecido (tiempo: timber a tiempo)";
                this.labelHelp3.Text = "- Salida externa : Salida de señal al contacto externo de salida";
                this.labelHelp4.Text = "  cuando se mide por el número de modos";
                this.labelHelp5.Text = "- Restablecimiento automático: El conteo se restablece cuando se mide un valor de juicio que no está en el modo de configuración";
                this.labelHelp6.Text = "- Modo cruzado : 2 progresos después de cumplir 1 condición, 1 progreso nuevamente cuando se cumplen 2 condiciones";
            }
            else
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundCounterOutput));

                this.comboBox1Mode.Items.Add("None");
                this.comboBox1Mode.Items.Add("Pass");
                this.comboBox1Mode.Items.Add("NG");
                this.comboBox1Mode.Items.Add("Over");
                this.comboBox1Mode.Items.Add("Under");
                this.comboBox1Mode.Items.Add("ExNG");
                this.comboBox1Mode.Items.Add("Metal");
                this.comboBox1Mode.Items.Add("Double");
                this.comboBox1Mode.Items.Add("ExNG1");
                this.comboBox1Mode.Items.Add("ExNG2");

                this.comboBox2Mode.Items.Add("None");
                this.comboBox2Mode.Items.Add("Pass");
                this.comboBox2Mode.Items.Add("NG");
                this.comboBox2Mode.Items.Add("Over");
                this.comboBox2Mode.Items.Add("Under");
                this.comboBox2Mode.Items.Add("ExNG");
                this.comboBox2Mode.Items.Add("Metal");
                this.comboBox2Mode.Items.Add("Double");
                this.comboBox2Mode.Items.Add("ExNG1");
                this.comboBox2Mode.Items.Add("ExNG2");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "자동 리셋";
                this.checkBox1ConveyorStop.Text = this.checkBox2ConveyorStop.Text = "장비정지";
                this.checkBox1BuzzerOn.Text = this.checkBox2BuzzerOn.Text = "부저울림";
                this.checkBox1ExternalOutput.Text = this.checkBox2ExternalOutput.Text = "외부출력";
                this.checkBox1AutoReset.Text = this.checkBox2AutoReset.Text = "자동리셋";
                this.checkBoxSequentialMode.Text = "교차모드";

                this.labelHelp1.Font = new Font("새굴림", 9, FontStyle.Regular);
                this.labelHelp1.Text = "- 장비정지 : 설정한 개수만큼 카운팅되었을 때 장비 정지";
                this.labelHelp2.Text = "- 부저울림 : 설정한 개수만큼 카운팅되었을 때 부저 울림(시간 : 부저 ON 시간)";
                this.labelHelp3.Text = "- 외부출력 : 설정한 개수만큼 카운팅되었을 때 외부출력 접점으로 신호 출력";
                this.labelHelp4.Text = "(시스템설정 - 외부출력 '카운터출력'으로 설정한 접점으로 신호 출력)";
                this.labelHelp5.Text = "- 자동리셋 : 설정된 모드가 아닌 판정값이 측정될 경우, 카운트 초기화";
                this.labelHelp6.Text = "- 교차모드 : 1 조건 충족 후 2 진행, 2 조건 충족 후 다시 1 진행";
            }

            this.comboBox1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);
            this.comboBox2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxAlarm2Mode_SelectedIndexChanged);
        }
        private void DefaultSetting()
        {        
        }

        private void UpdateDisplay(SystemConfigurationItem2 parameter)
        {
            bool bValue = false;
            int iValue = 0;

            this.checkBoxSequentialMode.Click -= new EventHandler(this.checkBoxSequentialMode_Click);
            if (this.ParentForm.ParentForm.SystemConfig3.IsCountingOutputCrossMode == true)
                this.checkBoxSequentialMode.Checked = true;
            else
                this.checkBoxSequentialMode.Checked = false;
            this.checkBoxSequentialMode.Click += new EventHandler(this.checkBoxSequentialMode_Click);

            #region Counting Output 1
            // 모드
            this.comboBox1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);
            this.comboBox1Mode.SelectedIndex = parameter.CountingOutput1Mode;
            this.comboBox1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);

            // 부저ON 여부
            this.checkBox1BuzzerOn.Click -= new EventHandler(this.checkBoxAlarm1BuzzerOn_Click);
            if (parameter.IsCountingOutput1BuzzerOn == true)
                this.checkBox1BuzzerOn.Checked = true;
            else
                this.checkBox1BuzzerOn.Checked = false;
            this.checkBox1BuzzerOn.Click += new EventHandler(this.checkBoxAlarm1BuzzerOn_Click);

            // 장비정지 여부
            this.checkBox1ConveyorStop.Click -= new EventHandler(this.checkBoxAlarm1ConveyorStop_Click);
            if (parameter.IsCountingOutput1ConveyorStop == true)
                this.checkBox1ConveyorStop.Checked = true;
            else
                this.checkBox1ConveyorStop.Checked = false;
            this.checkBox1ConveyorStop.Click += new EventHandler(this.checkBoxAlarm1ConveyorStop_Click);

            // 자동리셋 여부
            this.checkBox1AutoReset.Click -= new EventHandler(this.checkBoxAlarm1Continuous_Click);
            if (parameter.IsCountingOutput1Continuous == true)
                this.checkBox1AutoReset.Checked = true;
            else
                this.checkBox1AutoReset.Checked = false;
            this.checkBox1AutoReset.Click += new EventHandler(this.checkBoxAlarm1Continuous_Click);

            // 외부출력 여부
            this.checkBox1ExternalOutput.Click -= new EventHandler(this.checkBoxAlarm1ExternalOutput_Click);
            if (parameter.IsCountingOutput1ExternalOutput == true)
                this.checkBox1ExternalOutput.Checked = true;
            else
                this.checkBox1ExternalOutput.Checked = false;
            this.checkBox1ExternalOutput.Click += new EventHandler(this.checkBoxAlarm1ExternalOutput_Click);

            // 개수
            iValue = parameter.CountingOutput1Number;
            if (this.label1Number.Text != iValue.ToString())
                this.label1Number.Text = iValue.ToString();

            // 부저울림시간
            iValue = parameter.CountingOutput1BuzzerTime;
            if (this.label1BuzzerTime.Text != iValue.ToString())
                this.label1BuzzerTime.Text = iValue.ToString();
            #endregion

            #region Counting Output 2
            // 모드
            this.comboBox2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm2Mode_SelectedIndexChanged);
            this.comboBox2Mode.SelectedIndex = parameter.CountingOutput2Mode;
            this.comboBox2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxAlarm2Mode_SelectedIndexChanged);

            // 부저ON 여부
            this.checkBox2BuzzerOn.Click -= new EventHandler(this.checkBoxAlarm2BuzzerOn_Click);
            if (parameter.IsCountingOutput2BuzzerOn == true)
                this.checkBox2BuzzerOn.Checked = true;
            else
                this.checkBox2BuzzerOn.Checked = false;
            this.checkBox2BuzzerOn.Click += new EventHandler(this.checkBoxAlarm2BuzzerOn_Click);

            // 장비정지 여부
            this.checkBox2ConveyorStop.Click -= new EventHandler(this.checkBoxAlarm2ConveyorStop_Click);
            if (parameter.IsCountingOutput2ConveyorStop == true)
                this.checkBox2ConveyorStop.Checked = true;
            else
                this.checkBox2ConveyorStop.Checked = false;
            this.checkBox2ConveyorStop.Click += new EventHandler(this.checkBoxAlarm2ConveyorStop_Click);

            // 자동리셋 여부
            this.checkBox2AutoReset.Click -= new EventHandler(this.checkBoxAlarm2Continuous_Click);
            if (parameter.IsCountingOutput2Continuous == true)
                this.checkBox2AutoReset.Checked = true;
            else
                this.checkBox2AutoReset.Checked = false;
            this.checkBox2AutoReset.Click += new EventHandler(this.checkBoxAlarm2Continuous_Click);

            // 외부출력 여부
            this.checkBox2ExternalOutput.Click -= new EventHandler(this.checkBoxAlarm2ExternalOutput_Click);
            if (parameter.IsCountingOutput2ExternalOutput == true)
                this.checkBox2ExternalOutput.Checked = true;
            else
                this.checkBox2ExternalOutput.Checked = false;
            this.checkBox2ExternalOutput.Click += new EventHandler(this.checkBoxAlarm2ExternalOutput_Click);

            // 개수
            iValue = parameter.CountingOutput2Number;
            if (this.label2Number.Text != iValue.ToString())
                this.label2Number.Text = iValue.ToString();

            // 부저울림시간
            iValue = parameter.CountingOutput2BuzzerTime;
            if (this.label2BuzzerTime.Text != iValue.ToString())
                this.label2BuzzerTime.Text = iValue.ToString();
            #endregion
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.ConfiCountingOutput;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.UpdateDisplay(this.ParentForm.ParentForm.SystemConfig2);
        }
        #endregion

        #region Event Handler
        private void comboBoxAlarm1Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(1);

            this.ParentForm.ParentForm.SystemConfig2.CountingOutput1Mode = this.comboBox1Mode.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void labelAlarm1Number_Click(object sender, EventArgs e)
        {  
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label1Number.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    this.label1Number.Text = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.label1Number.Text);
                    this.ParentForm.ParentForm.SystemConfig2.CountingOutput1Number = myKeyPad.IntValue;

                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
                }
            }
        }
        private void labelCountingOutput1BuzzerTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label1BuzzerTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    value = Helper.StringZeroFillDigits4(this.label1BuzzerTime.Text);
                    this.ParentForm.ParentForm.SystemConfig2.CountingOutput1BuzzerTime = myKeyPad.IntValue;

                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
                }
            }
        }
        private void checkBoxAlarm1ConveyorStop_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(1);

            if (this.checkBox1ConveyorStop.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ConveyorStop = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ConveyorStop = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void checkBoxAlarm1BuzzerOn_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(1);

            if (this.checkBox1BuzzerOn.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1BuzzerOn = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1BuzzerOn = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void checkBoxAlarm1Continuous_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(1);

            if (this.checkBox1AutoReset.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1Continuous = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1Continuous = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void checkBoxAlarm1ExternalOutput_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(1);

            if (this.checkBox1ExternalOutput.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ExternalOutput = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ExternalOutput = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }

        private void comboBoxAlarm2Mode_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(2);

            this.ParentForm.ParentForm.SystemConfig2.CountingOutput2Mode = this.comboBox2Mode.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void labelAlarm2Number_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label2Number.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    this.label2Number.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.SystemConfig2.CountingOutput2Number = myKeyPad.IntValue;

                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
                }
            }
        }
        private void labelCountingOutput2BuzzerTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label2BuzzerTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
                }
            }
        }
        private void checkBoxAlarm2ConveyorStop_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(2);

            if (this.checkBox2ConveyorStop.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ConveyorStop = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ConveyorStop = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void checkBoxAlarm2BuzzerOn_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(2);

            if (this.checkBox2BuzzerOn.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2BuzzerOn = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2BuzzerOn = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void checkBoxAlarm2Continuous_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(2);

            if (this.checkBox2AutoReset.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2Continuous = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2Continuous = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void checkBoxAlarm2ExternalOutput_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(2);

            if (this.checkBox2ExternalOutput.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }

        private void checkBoxSequentialMode_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.ClearAlarm(0);

            if (this.checkBoxSequentialMode.Checked == true)
                this.ParentForm.ParentForm.SystemConfig3.IsCountingOutputCrossMode = true;
            else
                this.ParentForm.ParentForm.SystemConfig3.IsCountingOutputCrossMode = false;

            this.ParentForm.ParentForm.IsCountingOutputCrossStatus = false;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile3(this.ParentForm.ParentForm.SystemConfig3);
        }
        
        #region 사용안함
        //private void checkBoxAlarm1AutoReset_Click(object sender, EventArgs e)
        //{
        //    string value = "";

        //    if (this.checkBoxAlarm1AutoReset.Checked == true)
        //        this.ParentForm.ParentForm.SystemConfig.Alarm1AutoReset = "1";
        //    else
        //        this.ParentForm.ParentForm.SystemConfig.Alarm1AutoReset = "0";

        //    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.SystemConfig.Alarm1AutoReset);

        //    this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig);
        //}

        //private void checkBoxAlarm2AutoReset_Click(object sender, EventArgs e)
        //{
        //    string value = "";

        //    if (this.checkBoxAlarm2AutoReset.Checked == true)
        //        this.ParentForm.ParentForm.SystemConfig.Alarm2AutoReset = "1";
        //    else
        //        this.ParentForm.ParentForm.SystemConfig.Alarm2AutoReset = "0";

        //    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.SystemConfig.Alarm2AutoReset);

        //    this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig);
        //}
        #endregion
        #endregion
    }
}
