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_0H.Forms;
using ITC81DB_0H_ImageDll;
using ITC81DB_0H.DialogForms;

namespace ITC81DB_0H
{
    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.comboBoxCountingOutput1Mode.Items.Clear();
            this.comboBoxCountingOutput2Mode.Items.Clear();
            this.comboBoxCountingOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);
            this.comboBoxCountingOutput2Mode.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.comboBoxCountingOutput1Mode.Items.Add("None");
                this.comboBoxCountingOutput1Mode.Items.Add("Pass");
                this.comboBoxCountingOutput1Mode.Items.Add("NG");
                this.comboBoxCountingOutput1Mode.Items.Add("Over");
                this.comboBoxCountingOutput1Mode.Items.Add("Under");

                this.comboBoxCountingOutput2Mode.Items.Add("None");
                this.comboBoxCountingOutput2Mode.Items.Add("Pass");
                this.comboBoxCountingOutput2Mode.Items.Add("NG");
                this.comboBoxCountingOutput2Mode.Items.Add("Over");
                this.comboBoxCountingOutput2Mode.Items.Add("Under");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "Auto Reset";
                this.checkBoxCountingOutput1ConveyorStop.Text = this.checkBoxCountingOutput2ConveyorStop.Text = "Equipment stop";
                this.checkBoxCountingOutput1BuzzerOn.Text = this.checkBoxCountingOutput2BuzzerOn.Text = "Buzzering";
                this.checkBoxCountingOutput1ExternalOutput.Text = this.checkBoxCountingOutput2ExternalOutput.Text = "External output";
                this.checkBoxCountingOutput1AutoReset.Text = this.checkBoxCountingOutput2AutoReset.Text = "Auto reset";

                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' setting)";
                this.labelHelp5.Text = "- Auto reset : When the judgment value other than the set mode is measured,";
                this.labelHelp6.Text = "the count initialization";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundCountingOutput));

                this.comboBoxCountingOutput1Mode.Items.Add("不使用");
                this.comboBoxCountingOutput1Mode.Items.Add("通过");
                this.comboBoxCountingOutput1Mode.Items.Add("不良");
                this.comboBoxCountingOutput1Mode.Items.Add("超过");
                this.comboBoxCountingOutput1Mode.Items.Add("低于");

                this.comboBoxCountingOutput2Mode.Items.Add("不使用");
                this.comboBoxCountingOutput2Mode.Items.Add("通过");
                this.comboBoxCountingOutput2Mode.Items.Add("不良");
                this.comboBoxCountingOutput2Mode.Items.Add("超过");
                this.comboBoxCountingOutput2Mode.Items.Add("低于");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "Auto Reset";
                this.checkBoxCountingOutput1ConveyorStop.Text = this.checkBoxCountingOutput2ConveyorStop.Text = "设备停止";
                this.checkBoxCountingOutput1BuzzerOn.Text = this.checkBoxCountingOutput2BuzzerOn.Text = "嗡嗡声";
                this.checkBoxCountingOutput1ExternalOutput.Text = this.checkBoxCountingOutput2ExternalOutput.Text = "外部输出";
                this.checkBoxCountingOutput1AutoReset.Text = this.checkBoxCountingOutput2AutoReset.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 = "（例如，设置模式通过，设置编号3：在第二遍通过后确定第一NG时，计数器重置为0）";
            }
            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.comboBoxCountingOutput1Mode.Items.Add("Нет");
                this.comboBoxCountingOutput1Mode.Items.Add("Норма");
                this.comboBoxCountingOutput1Mode.Items.Add("Дефект");
                this.comboBoxCountingOutput1Mode.Items.Add("Много");
                this.comboBoxCountingOutput1Mode.Items.Add("Мало");

                this.comboBoxCountingOutput2Mode.Items.Add("Нет");
                this.comboBoxCountingOutput2Mode.Items.Add("Норма");
                this.comboBoxCountingOutput2Mode.Items.Add("Дефект");
                this.comboBoxCountingOutput2Mode.Items.Add("Много");
                this.comboBoxCountingOutput2Mode.Items.Add("Мало");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "자동 리셋";
                this.checkBoxCountingOutput1ConveyorStop.Text = this.checkBoxCountingOutput2ConveyorStop.Text = "Остановка оборудования";
                this.checkBoxCountingOutput1BuzzerOn.Text = this.checkBoxCountingOutput2BuzzerOn.Text = "Звуковой сигнал";
                this.checkBoxCountingOutput1ExternalOutput.Text = this.checkBoxCountingOutput2ExternalOutput.Text = "Внешний выход";
                this.checkBoxCountingOutput1AutoReset.Text = this.checkBoxCountingOutput2AutoReset.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 = "";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundCounterOutput));

                this.comboBoxCountingOutput1Mode.Items.Add("Keiner");
                this.comboBoxCountingOutput1Mode.Items.Add("Bestehen");
                this.comboBoxCountingOutput1Mode.Items.Add("Schlecht");
                this.comboBoxCountingOutput1Mode.Items.Add("Max.");
                this.comboBoxCountingOutput1Mode.Items.Add("Min.");

                this.comboBoxCountingOutput2Mode.Items.Add("Keiner");
                this.comboBoxCountingOutput2Mode.Items.Add("Bestehen");
                this.comboBoxCountingOutput2Mode.Items.Add("Schlecht");
                this.comboBoxCountingOutput2Mode.Items.Add("Max.");
                this.comboBoxCountingOutput2Mode.Items.Add("Min.");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "자동 리셋";
                this.checkBoxCountingOutput1ConveyorStop.Text = this.checkBoxCountingOutput2ConveyorStop.Text = "Ausrüstung stoppt";
                this.checkBoxCountingOutput1BuzzerOn.Text = this.checkBoxCountingOutput2BuzzerOn.Text = "Summer-Einschalt";
                this.checkBoxCountingOutput1ExternalOutput.Text = this.checkBoxCountingOutput2ExternalOutput.Text = "Externer Ausgang";
                this.checkBoxCountingOutput1AutoReset.Text = this.checkBoxCountingOutput2AutoReset.Text = "Automatisches Zurücksetzen";

                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";
                this.labelHelp6.Text = "wird, wird die nummer initialisiert";
            }
            else
            {
                this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundCounterOutput));

                this.comboBoxCountingOutput1Mode.Items.Add("None");
                this.comboBoxCountingOutput1Mode.Items.Add("Pass");
                this.comboBoxCountingOutput1Mode.Items.Add("NG");
                this.comboBoxCountingOutput1Mode.Items.Add("Over");
                this.comboBoxCountingOutput1Mode.Items.Add("Under");

                this.comboBoxCountingOutput2Mode.Items.Add("None");
                this.comboBoxCountingOutput2Mode.Items.Add("Pass");
                this.comboBoxCountingOutput2Mode.Items.Add("NG");
                this.comboBoxCountingOutput2Mode.Items.Add("Over");
                this.comboBoxCountingOutput2Mode.Items.Add("Under");

                //this.checkBoxAlarm1AutoReset.Text = this.checkBoxAlarm2AutoReset.Text = "자동 리셋";
                this.checkBoxCountingOutput1ConveyorStop.Text = this.checkBoxCountingOutput2ConveyorStop.Text = "장비정지";
                this.checkBoxCountingOutput1BuzzerOn.Text = this.checkBoxCountingOutput2BuzzerOn.Text = "부저울림";
                this.checkBoxCountingOutput1ExternalOutput.Text = this.checkBoxCountingOutput2ExternalOutput.Text = "외부출력";
                this.checkBoxCountingOutput1AutoReset.Text = this.checkBoxCountingOutput2AutoReset.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 = "(ex. 설정모드 Pass 설정개수 3 - 2번 Pass 후, 1번 NG 판정 시, 카운터는 0으로 초기화)";
            }

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

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

            #region Alarm1
            // 모드
            this.comboBoxCountingOutput1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);
            this.comboBoxCountingOutput1Mode.SelectedIndex = parameter.CountingOutput1Mode;
            this.comboBoxCountingOutput1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxAlarm1Mode_SelectedIndexChanged);

            // 자동리셋
            //sValue = parameter.Alarm1AutoReset;
            //this.checkBoxAlarm1AutoReset.Click -= new EventHandler(this.checkBoxAlarm1AutoReset_Click);
            //if (int.Parse(sValue.ToString()) == 1)
            //    this.checkBoxAlarm1AutoReset.Checked = true;
            //else
            //    this.checkBoxAlarm1AutoReset.Checked = false;
            //this.checkBoxAlarm1AutoReset.Click += new EventHandler(this.checkBoxAlarm1AutoReset_Click);

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

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

            // 연속측정 여부
            this.checkBoxCountingOutput1AutoReset.Click -= new EventHandler(this.checkBoxAlarm1Continuous_Click);
            if (parameter.IsCountingOutput1Continuous == true)
                this.checkBoxCountingOutput1AutoReset.Checked = true;
            else
                this.checkBoxCountingOutput1AutoReset.Checked = false;
            this.checkBoxCountingOutput1AutoReset.Click += new EventHandler(this.checkBoxAlarm1Continuous_Click);

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

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

            #region Alarm2
            // 모드
            this.comboBoxCountingOutput2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxAlarm2Mode_SelectedIndexChanged);
            this.comboBoxCountingOutput2Mode.SelectedIndex = parameter.CountingOutput2Mode;
            this.comboBoxCountingOutput2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxAlarm2Mode_SelectedIndexChanged);

            // 자동리셋
            //sValue = parameter.Alarm2AutoReset;
            //this.checkBoxAlarm2AutoReset.Click -= new EventHandler(this.checkBoxAlarm2AutoReset_Click);
            //if (int.Parse(sValue.ToString()) == 1)
            //    this.checkBoxAlarm2AutoReset.Checked = true;
            //else
            //    this.checkBoxAlarm2AutoReset.Checked = false;
            //this.checkBoxAlarm2AutoReset.Click += new EventHandler(this.checkBoxAlarm2AutoReset_Click);

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

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

            // 연속측정 여부
            this.checkBoxCountingOutput2AutoReset.Click -= new EventHandler(this.checkBoxAlarm2Continuous_Click);
            if (parameter.IsCountingOutput2Continuous == true)
                this.checkBoxCountingOutput2AutoReset.Checked = true;
            else
                this.checkBoxCountingOutput2AutoReset.Checked = false;
            this.checkBoxCountingOutput2AutoReset.Click += new EventHandler(this.checkBoxAlarm2Continuous_Click);

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

            // 개수
            iValue = parameter.CountingOutput2Number;
            if (this.labelCountingOutput2Number.Text != iValue.ToString())
                this.labelCountingOutput2Number.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.comboBoxCountingOutput1Mode.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void labelAlarm1Number_Click(object sender, EventArgs e)
        {  
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelCountingOutput1Number.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.labelCountingOutput1Number.Text = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelCountingOutput1Number.Text);
                    this.ParentForm.ParentForm.SystemConfig2.CountingOutput1Number = 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.checkBoxCountingOutput1ConveyorStop.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.checkBoxCountingOutput1BuzzerOn.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.checkBoxCountingOutput1AutoReset.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.checkBoxCountingOutput1ExternalOutput.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.comboBoxCountingOutput2Mode.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void labelAlarm2Number_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelCountingOutput2Number.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.labelCountingOutput2Number.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.SystemConfig2.CountingOutput2Number = 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.checkBoxCountingOutput2ConveyorStop.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.checkBoxCountingOutput2BuzzerOn.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.checkBoxCountingOutput2AutoReset.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.checkBoxCountingOutput2ExternalOutput.Checked == true)
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        
        #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
    }
}
