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 System.Drawing.Imaging;

using SmartX;

using ITC81DB_2H.Forms;
using ITC81DB_2H.DialogForms;
using ITC81DB_2H_ImageDll;
using System.Threading;
using ITC81DB_2H.Datastore;
using ITC81DB_2H.Part11_UserManager;
using System.IO;

namespace ITC81DB_2H.Controls
{
    public partial class ControlCenterEquipFunctionSetting : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        private int FileIndex;
        #endregion

        #region Constructor
        public ControlCenterEquipFunctionSetting(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.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.comboBoxPIN6.Font = this.comboBoxPIN5.Font = new Font("새굴림", 14, FontStyle.Bold);
            this.comboBoxPIN4.Font = this.comboBoxPIN3.Font = this.comboBoxPIN2.Font = new Font("새굴림", 14, FontStyle.Bold);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.English)
            {
                #region English
                this.labelTitleCommunicationLog.Text = "Log";

                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "Buzzer ON time";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "Relay Run time";
                this.labelTitleSensorChattering.Text = "Sensor Chattering";
                this.labelTitleSwitchChattering.Text = "Switch Chattering";
                this.labelTitleLanguage.Text = "Language";
                this.labelTitleEquipmentID.Text = "Equipment ID";
                this.labelTitleLogin.Text = "Login";
                this.labelExternalInputMessage1.Text = "Emergency Stop/Discharge/Air";
                this.labelExternalInputMessage2.Text = "";
                this.labelTitleExternalInputBuzzer.Text = "Buzzer";
                this.labelTitleExternalInputLamp.Text = "Lamp";

                this.labelTitleExternalInput.Text = "External Input";

                this.comboBoxPIN6.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
                this.comboBoxPIN6.Items.Clear();
                this.comboBoxPIN6.Items.Add("None");
                this.comboBoxPIN6.Items.Add("NG");
                this.comboBoxPIN6.Items.Add("START");
                this.comboBoxPIN6.Items.Add("STOP");
                this.comboBoxPIN6.Items.Add("Air Check");
                this.comboBoxPIN6.Items.Add("Metal Detector Entry Sensor");
                this.comboBoxPIN6.Items.Add("Metal Detector");
                this.comboBoxPIN6.SelectedIndexChanged += new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);

                this.comboBoxPIN5.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
                this.comboBoxPIN5.Items.Clear();
                this.comboBoxPIN5.Items.Add("None");
                this.comboBoxPIN5.Items.Add("NG");
                this.comboBoxPIN5.Items.Add("START");
                this.comboBoxPIN5.Items.Add("STOP");
                this.comboBoxPIN5.Items.Add("Air Check");
                this.comboBoxPIN5.Items.Add("Metal Detector Entry Sensor");
                this.comboBoxPIN5.Items.Add("Metal Detector");
                this.comboBoxPIN5.SelectedIndexChanged += new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);

                this.comboBoxPIN4.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
                this.comboBoxPIN4.Items.Clear();
                this.comboBoxPIN4.Items.Add("None");
                this.comboBoxPIN4.Items.Add("NG");
                this.comboBoxPIN4.Items.Add("START");
                this.comboBoxPIN4.Items.Add("STOP");
                this.comboBoxPIN4.Items.Add("Air Check");
                this.comboBoxPIN4.Items.Add("Metal Detector Entry Sensor");
                this.comboBoxPIN4.Items.Add("Metal Detector");
                this.comboBoxPIN4.SelectedIndexChanged += new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);

                this.comboBoxPIN3.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
                this.comboBoxPIN3.Items.Clear();
                this.comboBoxPIN3.Items.Add("None");
                this.comboBoxPIN3.Items.Add("NG");
                this.comboBoxPIN3.Items.Add("START");
                this.comboBoxPIN3.Items.Add("STOP");
                this.comboBoxPIN3.Items.Add("Air Check");
                this.comboBoxPIN3.Items.Add("Metal Detector Entry Sensor");
                this.comboBoxPIN3.Items.Add("Metal Detector");
                this.comboBoxPIN3.SelectedIndexChanged += new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);

                this.comboBoxPIN2.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                this.comboBoxPIN2.Items.Clear();
                this.comboBoxPIN2.Items.Add("None");
                this.comboBoxPIN2.Items.Add("NG");
                this.comboBoxPIN2.Items.Add("START");
                this.comboBoxPIN2.Items.Add("STOP");
                this.comboBoxPIN2.Items.Add("Air Check");
                this.comboBoxPIN2.Items.Add("Metal Detector Entry Sensor");
                this.comboBoxPIN2.Items.Add("Metal Detector");
                this.comboBoxPIN2.SelectedIndexChanged += new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonExternalInputBuzzer.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonExternalInputBuzzer.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonExternalInputLamp.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonExternalInputLamp.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonCommunicationLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonCommunicationLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Chinese)
            {
                #region Chinese
                this.labelTitleCommunicationLog.Text = "日志";

                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "蜂鸣器开启时间";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "继电器接通时间";
                this.labelTitleSensorChattering.Text = "传感器抖动";
                this.labelTitleSwitchChattering.Text = "开关喋喋不休";
                this.labelTitleLanguage.Text = "语言";
                this.labelTitleEquipmentID.Text = "设备编号";
                this.labelTitleLogin.Text = "登錄";
                this.labelExternalInputMessage1.Text = "排出确认, 气压确认, 紧急停止";
                this.labelExternalInputMessage2.Text = "";
                this.labelTitleExternalInputBuzzer.Text = "蜂鸣器";
                this.labelTitleExternalInputLamp.Text = "灯";

                this.labelTitleExternalInput.Text = "外部输入";

                this.comboBoxPIN6.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
                this.comboBoxPIN6.Items.Clear();
                this.comboBoxPIN6.Items.Add("不使用");
                this.comboBoxPIN6.Items.Add("NG");
                this.comboBoxPIN6.Items.Add("开启");
                this.comboBoxPIN6.Items.Add("停止");
                this.comboBoxPIN6.Items.Add("气压确认");
                this.comboBoxPIN6.Items.Add("金属检出进入传感器");
                this.comboBoxPIN6.Items.Add("金属检出");
                this.comboBoxPIN6.SelectedIndexChanged += new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);

                this.comboBoxPIN5.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
                this.comboBoxPIN5.Items.Clear();
                this.comboBoxPIN5.Items.Add("不使用");
                this.comboBoxPIN5.Items.Add("NG");
                this.comboBoxPIN5.Items.Add("开启");
                this.comboBoxPIN5.Items.Add("停止");
                this.comboBoxPIN5.Items.Add("气压确认");
                this.comboBoxPIN5.Items.Add("金属检出进入传感器");
                this.comboBoxPIN5.Items.Add("金属检出");
                this.comboBoxPIN5.SelectedIndexChanged += new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);

                this.comboBoxPIN4.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
                this.comboBoxPIN4.Items.Clear();
                this.comboBoxPIN4.Items.Add("不使用");
                this.comboBoxPIN4.Items.Add("NG");
                this.comboBoxPIN4.Items.Add("开启");
                this.comboBoxPIN4.Items.Add("停止");
                this.comboBoxPIN4.Items.Add("气压确认");
                this.comboBoxPIN4.Items.Add("金属检出进入传感器");
                this.comboBoxPIN4.Items.Add("金属检出");
                this.comboBoxPIN4.SelectedIndexChanged += new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);

                this.comboBoxPIN3.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
                this.comboBoxPIN3.Items.Clear();
                this.comboBoxPIN3.Items.Add("不使用");
                this.comboBoxPIN3.Items.Add("NG");
                this.comboBoxPIN3.Items.Add("开启");
                this.comboBoxPIN3.Items.Add("停止");
                this.comboBoxPIN3.Items.Add("气压确认");
                this.comboBoxPIN3.Items.Add("金属检出进入传感器");
                this.comboBoxPIN3.Items.Add("金属检出");
                this.comboBoxPIN3.SelectedIndexChanged += new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);

                this.comboBoxPIN2.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                this.comboBoxPIN2.Items.Clear();
                this.comboBoxPIN2.Items.Add("不使用");
                this.comboBoxPIN2.Items.Add("NG");
                this.comboBoxPIN2.Items.Add("开启");
                this.comboBoxPIN2.Items.Add("停止");
                this.comboBoxPIN2.Items.Add("气压确认");
                this.comboBoxPIN2.Items.Add("金属检出进入传感器");
                this.comboBoxPIN2.Items.Add("金属检出");
                this.comboBoxPIN2.SelectedIndexChanged += new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonExternalInputBuzzer.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonExternalInputBuzzer.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonExternalInputLamp.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonExternalInputLamp.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonCommunicationLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonCommunicationLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Russian)
            {
                this.comboBoxPIN6.Font = this.comboBoxPIN5.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.comboBoxPIN4.Font = this.comboBoxPIN3.Font = this.comboBoxPIN2.Font = new Font("새굴림", 12, FontStyle.Bold);

                #region Russian
                this.labelTitleCommunicationLog.Text = "Журнал обмена";

                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 8, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "Длительность звуковога сигнала";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "Длительность включения реле ";
                this.labelTitleSensorChattering.Text = "Датчик дребезжит";
                this.labelTitleSwitchChattering.Text = "Переключить болтовню";
                this.labelTitleLanguage.Text = "Язык";
                this.labelTitleEquipmentID.Text = "ID оборудования";
                this.labelTitleLogin.Text = "Логин";
                this.labelExternalInputMessage1.Text = "Аврийная остановка/разрядки";
                this.labelExternalInputMessage2.Text = "/давления";
                this.labelTitleExternalInputBuzzer.Text = "Сигнал";
                this.labelTitleExternalInputLamp.Text = "лампа";

                this.labelTitleExternalInput.Text = "Внешний вход";

                this.comboBoxPIN6.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
                this.comboBoxPIN6.Items.Clear();
                this.comboBoxPIN6.Items.Add("Нет");
                this.comboBoxPIN6.Items.Add("Другие неисправности");
                this.comboBoxPIN6.Items.Add("Старт");
                this.comboBoxPIN6.Items.Add("Стоп");
                this.comboBoxPIN6.Items.Add("Проверка давления");
                this.comboBoxPIN6.SelectedIndexChanged += new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);

                this.comboBoxPIN5.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
                this.comboBoxPIN5.Items.Clear();
                this.comboBoxPIN5.Items.Add("Нет");
                this.comboBoxPIN5.Items.Add("Другие неисправности");
                this.comboBoxPIN5.Items.Add("Старт");
                this.comboBoxPIN5.Items.Add("Стоп");
                this.comboBoxPIN5.Items.Add("Проверка давления");
                this.comboBoxPIN5.SelectedIndexChanged += new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);

                this.comboBoxPIN4.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
                this.comboBoxPIN4.Items.Clear();
                this.comboBoxPIN4.Items.Add("Нет");
                this.comboBoxPIN4.Items.Add("Другие неисправности");
                this.comboBoxPIN4.Items.Add("Старт");
                this.comboBoxPIN4.Items.Add("Стоп");
                this.comboBoxPIN4.Items.Add("Проверка давления");
                this.comboBoxPIN4.SelectedIndexChanged += new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);

                this.comboBoxPIN3.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
                this.comboBoxPIN3.Items.Clear();
                this.comboBoxPIN3.Items.Add("Нет");
                this.comboBoxPIN3.Items.Add("Другие неисправности");
                this.comboBoxPIN3.Items.Add("Старт");
                this.comboBoxPIN3.Items.Add("Стоп");
                this.comboBoxPIN3.Items.Add("Проверка давления");
                this.comboBoxPIN3.SelectedIndexChanged += new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);

                this.comboBoxPIN2.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                this.comboBoxPIN2.Items.Clear();
                this.comboBoxPIN2.Items.Add("Нет");
                this.comboBoxPIN2.Items.Add("Другие неисправности");
                this.comboBoxPIN2.Items.Add("Старт");
                this.comboBoxPIN2.Items.Add("Стоп");
                this.comboBoxPIN2.Items.Add("Проверка давления");
                this.comboBoxPIN2.SelectedIndexChanged += new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                           
                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonExternalInputBuzzer.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonExternalInputBuzzer.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonExternalInputLamp.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonExternalInputLamp.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonCommunicationLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonCommunicationLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.German)
            {
                #region German
                this.labelTitleCommunicationLog.Text = "Protokoll";

                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "Summer-Einschaltzeit";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "Relais-Einschaltzeit";
                this.labelTitleSensorChattering.Text = "Sensor klappert";
                this.labelTitleSwitchChattering.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleSwitchChattering.Text = "Schalten Sie das Geschwätz um";
                this.labelTitleLanguage.Text = "Sprache";
                this.labelTitleEquipmentID.Text = "ID-Vorrichtung";
                this.labelTitleLogin.Text = "Einloggen";
                this.labelExternalInputMessage1.Text = "Not-Halt/Entladung/Luft";
                this.labelExternalInputMessage2.Text = "";
                this.labelTitleExternalInputBuzzer.Text = "Summer";
                this.labelTitleExternalInputLamp.Text = "Ampel";

                this.labelTitleExternalInput.Text = "Externe Eingabe";

                this.comboBoxPIN6.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
                this.comboBoxPIN6.Items.Clear();
                this.comboBoxPIN6.Items.Add("Keiner");
                this.comboBoxPIN6.Items.Add("NG");
                this.comboBoxPIN6.Items.Add("START");
                this.comboBoxPIN6.Items.Add("STOPP");
                this.comboBoxPIN6.Items.Add("Luft Prüfen");
                this.comboBoxPIN6.Items.Add("Metallerkennungs-Eingangssensor");
                this.comboBoxPIN6.Items.Add("Metalldetektion");
                this.comboBoxPIN6.SelectedIndexChanged += new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);

                this.comboBoxPIN5.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
                this.comboBoxPIN5.Items.Clear();
                this.comboBoxPIN5.Items.Add("Keiner");
                this.comboBoxPIN5.Items.Add("NG");
                this.comboBoxPIN5.Items.Add("START");
                this.comboBoxPIN5.Items.Add("STOPP");
                this.comboBoxPIN5.Items.Add("Luft Prüfen");
                this.comboBoxPIN5.Items.Add("Metallerkennungs-Eingangssensor");
                this.comboBoxPIN5.Items.Add("Metalldetektion");
                this.comboBoxPIN5.SelectedIndexChanged += new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);

                this.comboBoxPIN4.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
                this.comboBoxPIN4.Items.Clear();
                this.comboBoxPIN4.Items.Add("Keiner");
                this.comboBoxPIN4.Items.Add("NG");
                this.comboBoxPIN4.Items.Add("START");
                this.comboBoxPIN4.Items.Add("STOPP");
                this.comboBoxPIN4.Items.Add("Luft Prüfen");
                this.comboBoxPIN4.Items.Add("Metallerkennungs-Eingangssensor");
                this.comboBoxPIN4.Items.Add("Metalldetektion");
                this.comboBoxPIN4.SelectedIndexChanged += new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);

                this.comboBoxPIN3.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
                this.comboBoxPIN3.Items.Clear();
                this.comboBoxPIN3.Items.Add("Keiner");
                this.comboBoxPIN3.Items.Add("NG");
                this.comboBoxPIN3.Items.Add("START");
                this.comboBoxPIN3.Items.Add("STOPP");
                this.comboBoxPIN3.Items.Add("Luft Prüfen");
                this.comboBoxPIN3.Items.Add("Metallerkennungs-Eingangssensor");
                this.comboBoxPIN3.Items.Add("Metalldetektion");
                this.comboBoxPIN3.SelectedIndexChanged += new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);

                this.comboBoxPIN2.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                this.comboBoxPIN2.Items.Clear();
                this.comboBoxPIN2.Items.Add("Keiner");
                this.comboBoxPIN2.Items.Add("NG");
                this.comboBoxPIN2.Items.Add("START");
                this.comboBoxPIN2.Items.Add("STOPP");
                this.comboBoxPIN2.Items.Add("Luft Prüfen");
                this.comboBoxPIN2.Items.Add("Metallerkennungs-Eingangssensor");
                this.comboBoxPIN2.Items.Add("Metalldetektion");
                this.comboBoxPIN2.SelectedIndexChanged += new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonExternalInputBuzzer.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonExternalInputBuzzer.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonExternalInputLamp.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonExternalInputLamp.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonCommunicationLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonCommunicationLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {

            }
            else
            {
                #region Korean
                this.labelTitleCommunicationLog.Text = "통신로그";

                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "부저 ON 시간";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "릴레이 동작 시간";
                this.labelTitleSensorChattering.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSensorChattering.Text = "센서채터링";
                this.labelTitleSwitchChattering.Text = "스위치채터링";
                this.labelTitleLanguage.Text = "언어설정";
                this.labelTitleEquipmentID.Text = "장비 ID";
                this.labelTitleLogin.Text = "로그인";
                this.labelExternalInputMessage1.Text = "배출, 공압, 비상정지";
                this.labelExternalInputMessage2.Text = "";
                this.labelTitleExternalInputBuzzer.Text = "부저";
                this.labelTitleExternalInputLamp.Text = "램프";

                this.labelTitleExternalInput.Text = "외부입력 설정";

                this.comboBoxPIN6.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
                this.comboBoxPIN6.Items.Clear();
                this.comboBoxPIN6.Items.Add("사용안함");
                this.comboBoxPIN6.Items.Add("NG");
                this.comboBoxPIN6.Items.Add("START");
                this.comboBoxPIN6.Items.Add("STOP");
                this.comboBoxPIN6.Items.Add("공압확인");
                this.comboBoxPIN6.Items.Add("금속검출 진입센서");
                this.comboBoxPIN6.Items.Add("금속검출");
                this.comboBoxPIN6.SelectedIndexChanged += new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);

                this.comboBoxPIN5.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
                this.comboBoxPIN5.Items.Clear();
                this.comboBoxPIN5.Items.Add("사용안함");
                this.comboBoxPIN5.Items.Add("NG");
                this.comboBoxPIN5.Items.Add("START");
                this.comboBoxPIN5.Items.Add("STOP");
                this.comboBoxPIN5.Items.Add("공압확인");
                this.comboBoxPIN5.Items.Add("금속검출 진입센서");
                this.comboBoxPIN5.Items.Add("금속검출");
                this.comboBoxPIN5.SelectedIndexChanged += new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);

                this.comboBoxPIN4.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
                this.comboBoxPIN4.Items.Clear();
                this.comboBoxPIN4.Items.Add("사용안함");
                this.comboBoxPIN4.Items.Add("NG");
                this.comboBoxPIN4.Items.Add("START");
                this.comboBoxPIN4.Items.Add("STOP");
                this.comboBoxPIN4.Items.Add("공압확인");
                this.comboBoxPIN4.Items.Add("금속검출 진입센서");
                this.comboBoxPIN4.Items.Add("금속검출");
                this.comboBoxPIN4.SelectedIndexChanged += new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);

                this.comboBoxPIN3.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
                this.comboBoxPIN3.Items.Clear();
                this.comboBoxPIN3.Items.Add("사용안함");
                this.comboBoxPIN3.Items.Add("NG");
                this.comboBoxPIN3.Items.Add("START");
                this.comboBoxPIN3.Items.Add("STOP");
                this.comboBoxPIN3.Items.Add("공압확인");
                this.comboBoxPIN3.Items.Add("금속검출 진입센서");
                this.comboBoxPIN3.Items.Add("금속검출");
                this.comboBoxPIN3.SelectedIndexChanged += new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);

                this.comboBoxPIN2.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                this.comboBoxPIN2.Items.Clear();
                this.comboBoxPIN2.Items.Add("사용안함");
                this.comboBoxPIN2.Items.Add("NG");
                this.comboBoxPIN2.Items.Add("START");
                this.comboBoxPIN2.Items.Add("STOP");
                this.comboBoxPIN2.Items.Add("공압확인");
                this.comboBoxPIN2.Items.Add("금속검출 진입센서");
                this.comboBoxPIN2.Items.Add("금속검출");
                this.comboBoxPIN2.SelectedIndexChanged += new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonExternalInputBuzzer.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonExternalInputBuzzer.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonExternalInputLamp.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonExternalInputLamp.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonCommunicationLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonCommunicationLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
        }
        private void DefaultSetting()
        {
            this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
            this.comboBoxLanguage.Items.Clear();
            this.comboBoxLanguage.Items.Add("한국어");
            this.comboBoxLanguage.Items.Add("English");
            //this.comboBoxLanguage.Items.Add("Español");
            //this.comboBoxLanguage.Items.Add("Deutsch");
            //this.comboBoxLanguage.Items.Add("中文");
            //this.comboBoxLanguage.Items.Add("русский");
            this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

            this.FileIndex = 0;
        }

        private void FileCopy(FileInfo file, string fileName)
        {
            try
            {
                if (this.FileIndex == 0)
                {
                    file.CopyTo(fileName);
                    this.FileIndex = 0;
                }
                else
                {
                    file.CopyTo(fileName.Insert(fileName.Length - 4, "_" + this.FileIndex.ToString()));
                    this.FileIndex = 0;
                }
            }
            catch
            {
                this.FileIndex++;
                this.FileCopy(file, fileName);
            }
        }

        private void UpdateListBox()
        {
            bool directoryCheck = false;
            DirectoryInfo dir = new DirectoryInfo(this.ParentForm.ParentForm.PathDataLogFolder);

            directoryCheck = dir.Exists;
            // 폴더 체크
            if (directoryCheck == false)
                dir.Create();

            FileInfo[] files = dir.GetFiles();

            this.listBoxDataList.Items.Clear();

            foreach (FileInfo file in files)
            {
                this.listBoxDataList.Items.Add(file.Name);
            }

            this.labelFileCount1.Text = this.listBoxDataList.Items.Count.ToString();
        }
        public void DisplayHiddenMenu(bool bValue)
        {
            this.buttonCapture.Visible = bValue;
        }
        private void UpdateParameterDisplay(SystemConfigurationItem1 item, SystemConfigurationItem2 item2, SystemParameter1 parameter)
        {
            string value = "";
            int index = 0;

            // Equipment ID
            value = item.EquipmentID.ToString();
            if (this.labelEquipmentID.Text != value)
                this.labelEquipmentID.Text = value;

            // 언어
            index = (int)item.Language;
            if (this.comboBoxLanguage.SelectedIndex != index)
            {
                this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                this.comboBoxLanguage.SelectedIndex = index;
                this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
            }

            // 로그인
            if (item.IsLogin == false)
                this.buttonLogin.ButtonUp();
            else
                this.buttonLogin.ButtonDown();

            // 부저ON시간
            value = parameter.BuzzerOnTime.Trim();
            if (this.labelBuzzerOnTime.Text != value)
                this.labelBuzzerOnTime.Text = value;

            // 릴레이동작시간
            value = parameter.RelayOnTime.Trim();
            if (this.labelRelayOnTime.Text != value)
                this.labelRelayOnTime.Text = value;

            // 채터링감지
            value = parameter.Chattering.Trim();
            if (this.labelChattering.Text != value)
                this.labelChattering.Text = value;

            // 스위치채터링
            value = parameter.SwitchChattering.Trim();
            if (this.labelSwitchChattering.Text != value)
                this.labelSwitchChattering.Text = value;
            
            // 입력포트
            index = parameter.PI6;
            if (this.comboBoxPIN6.SelectedIndex != index)
            {
                this.comboBoxPIN6.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
                this.comboBoxPIN6.SelectedIndex = index;
                this.comboBoxPIN6.SelectedIndexChanged += new EventHandler(this.comboBoxPIN6_SelectedIndexChanged);
            }
            index = parameter.PI5;
            if (this.comboBoxPIN5.SelectedIndex != index)
            {
                this.comboBoxPIN5.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
                this.comboBoxPIN5.SelectedIndex = index;
                this.comboBoxPIN5.SelectedIndexChanged += new EventHandler(this.comboBoxPIN5_SelectedIndexChanged);
            }
            index = parameter.PI4;
            if (this.comboBoxPIN4.SelectedIndex != index)
            {
                this.comboBoxPIN4.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
                this.comboBoxPIN4.SelectedIndex = index;
                this.comboBoxPIN4.SelectedIndexChanged += new EventHandler(this.comboBoxPIN4_SelectedIndexChanged);
            }
            index = parameter.PI3;
            if (this.comboBoxPIN3.SelectedIndex != index)
            {
                this.comboBoxPIN3.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
                this.comboBoxPIN3.SelectedIndex = index;
                this.comboBoxPIN3.SelectedIndexChanged += new EventHandler(this.comboBoxPIN3_SelectedIndexChanged);
            }
            index = parameter.PI2;
            if (this.comboBoxPIN2.SelectedIndex != index)
            {
                this.comboBoxPIN2.SelectedIndexChanged -= new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
                this.comboBoxPIN2.SelectedIndex = index;
                this.comboBoxPIN2.SelectedIndexChanged += new EventHandler(this.comboBoxPIN2_SelectedIndexChanged);
            }

            // 외부 입력 시 부저/램프
            if (item.IsExternalInputBuzzer == false)
                this.buttonExternalInputBuzzer.ButtonUp();
            else
                this.buttonExternalInputBuzzer.ButtonDown();

            if (item.IsExternalInputLamp == false)
                this.buttonExternalInputLamp.ButtonUp();
            else
                this.buttonExternalInputLamp.ButtonDown();

            // 통신로그
            if (this.ParentForm.ParentForm.IsCommunicationLogOpen == false)
                this.buttonCommunicationLog.ButtonUp();
            else
                this.buttonCommunicationLog.ButtonDown();
        }

        private void UpdateDisplayUser(UserItem user)
        {
            if ((user.Group == Define.E_UserGroup.Admin || user.Group == Define.E_UserGroup.Developer) && this.ParentForm.ParentForm.SystemConfig1.IsLogin == true)
                this.DisplayHiddenMenu(true);
            else
                this.DisplayHiddenMenu(false);
        }

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

            this.UpdateListBox();
            this.UpdateParameterDisplay(this.ParentForm.ParentForm.SystemConfig1, this.ParentForm.ParentForm.SystemConfig2, 
                this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.UpdateDisplayUser(status.CurrentUser);
        }
        #endregion

        #region Event Handler
        private void labelEquipmentID_Click(object sender, EventArgs e)
        {
            string before = "", after = "";
            before = this.labelEquipmentID.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelEquipmentID.Text, 3, 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
                {
                    if (int.Parse(this.labelEquipmentID.Text) != myKeyPad.IntValue)
                    {
                        this.ParentForm.ParentForm.Update30000ModbusItem();
                        after = this.labelEquipmentID.Text = myKeyPad.StringValue;

                        this.ParentForm.ParentForm.SystemConfig1.EquipmentID = myKeyPad.IntValue;
                        this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);

                        if (before != after)
                            this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.EquipmentID, "", before, after);
                    }
                }
            }
        }
        private void labelBuzzerOnTime_Click(object sender, EventArgs e)
        {
            string before = "", after = "";
            string value = "";
            before = this.labelBuzzerOnTime.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelBuzzerOnTime.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
                {
                    after = this.labelBuzzerOnTime.Text = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelBuzzerOnTime.Text);
                    this.ParentForm.ParentForm.CurrentSystemParameter1.BuzzerOnTime = myKeyPad.StringValue;

                    this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.BuzzerOnTime, value);

                    if (before != after)
                        this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.BuzzerONTime, "", before, after);
                }
            }
        }
        private void labelRelayOnTime_Click(object sender, EventArgs e)
        {
            string before = "", after = "";
            string value = "";
            before = this.labelRelayOnTime.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRelayOnTime.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
                {
                    after = this.labelRelayOnTime.Text = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.labelRelayOnTime.Text);
                    this.ParentForm.ParentForm.CurrentSystemParameter1.RelayOnTime = myKeyPad.StringValue;

                    this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.RelayRunTime, value);

                    if (before != after)
                        this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.RelayONTime, "", before, after);
                }
            }
        }
        private void labelChattering_Click(object sender, EventArgs e)
        {
            string before = "", after = "";
            string value = "";
            before = this.labelChattering.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelChattering.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    value = Helper.StringZeroFillDigits4(this.labelChattering.Text);
                    this.ParentForm.ParentForm.CurrentSystemParameter1.Chattering = myKeyPad.StringValue;

                    this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.Chattering, value);

                    if (before != after)
                        this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Chattering, "", before, after);
                }
            }
        }
        private void labelSwitchChattering_Click(object sender, EventArgs e)
        {
            string before = "", after = "";
            string value = "";
            before = this.labelSwitchChattering.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSwitchChattering.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    value = Helper.StringZeroFillDigits4(this.labelSwitchChattering.Text);
                    this.ParentForm.ParentForm.CurrentSystemParameter1.SwitchChattering = myKeyPad.StringValue;

                    this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SwitchChattering, value);

                    if (before != after)
                        this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.SwitchChattering, "", before, after);
                }
            }
        }
        private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.ParentForm.ParentForm.SystemConfig1.Language.ToString();
            if (this.comboBoxLanguage.SelectedIndex == 0)
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.Korean;
            else if (this.comboBoxLanguage.SelectedIndex == 1)
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.English;
            else if (this.comboBoxLanguage.SelectedIndex == 2)
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.Spanish;
            else if (this.comboBoxLanguage.SelectedIndex == 3)
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.German;
            else if (this.comboBoxLanguage.SelectedIndex == 4)
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.Chinese;
            else if (this.comboBoxLanguage.SelectedIndex == 5)
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.Russian;
            else
                this.ParentForm.ParentForm.SystemConfig1.Language = Define.E_LanguageID.Korean;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
            after = this.ParentForm.ParentForm.SystemConfig1.Language.ToString();

            if (before != after)
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Language, "", before, after);

            // 각 화면 언어 적용
            SmartSplash splash = new SmartSplash();
            splash.CenterPosition = true;
            splash.AnimationInterval = 200;
            splash.LoadingImagePathname = "SmartLoading4";
            splash.Start();

            this.ParentForm.ParentForm.ChildFormMainDisplay.InitializeDesign();
            this.ParentForm.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.ParentForm.ChildFormMainDisplay.MainSubMenu.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainBarGraph.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainLineGraph.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainList.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainDataStatistics.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightBigScreen.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightSmall.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainFeedback.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainModbus.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterBasicDataStatistics.InitializeDesign();
            this.ParentForm.CenterBasicHelp.InitializeDesign();
            this.ParentForm.CenterBasicProduct.InitializeDesign();
            this.ParentForm.CenterBasicTime.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterConfiEthernet.InitializeDesign();
            this.ParentForm.CenterConfiHelp.InitializeDesign();

            if (this.ParentForm.CenterConfiOptionBoard != null)
                this.ParentForm.CenterConfiOptionBoard.InitializeDesign();
            if (this.ParentForm.CenterConfiSerial != null)
                this.ParentForm.CenterConfiSerial.InitializeDesign();
            if (this.ParentForm.CenterConfiEthernet.ControlEthernetLocalIP != null)
                this.ParentForm.CenterConfiEthernet.ControlEthernetLocalIP.InitializeDesign();
            if (this.ParentForm.CenterConfiEthernet.ControlModbusTCP != null)
                this.ParentForm.CenterConfiEthernet.ControlModbusTCP.InitializeDesign();
            if (this.ParentForm.CenterConfiSerial.ControlBarcode != null)
                this.ParentForm.CenterConfiSerial.ControlBarcode.InitializeDesign();
            if (this.ParentForm.CenterConfiSerial.ControlHitachi != null)
                this.ParentForm.CenterConfiSerial.ControlHitachi.InitializeDesign();
            if (this.ParentForm.CenterConfiSerial.ControlMarkoprint != null)
                this.ParentForm.CenterConfiSerial.ControlMarkoprint.InitializeDesign();
            if (this.ParentForm.CenterConfiSerial.ControlModbusRTU != null)
                this.ParentForm.CenterConfiSerial.ControlModbusRTU.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterEquipFunctionSetting.InitializeDesign();
            this.UpdateParameterDisplay(this.ParentForm.ParentForm.SystemConfig1, this.ParentForm.ParentForm.SystemConfig2, 
                this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.CenterEquipHelp.InitializeDesign();
            this.ParentForm.CenterEquipInitialize.InitializeDesign();
            this.ParentForm.CenterEquipUpdate.InitializeDesign();
            this.ParentForm.CenterEquipUser.InitializeDesign();
            this.ParentForm.CenterEquipUserGroupEditor.InitializeDesign();
            this.ParentForm.CenterEquipEngineer.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterLogHelp.InitializeDesign();
            this.ParentForm.CenterLogHistory.InitializeDesign();
            this.ParentForm.CenterLogInspection.InitializeDesign();
            this.ParentForm.CenterLogOthers.InitializeDesign();

            this.ParentForm.CenterInforAS.InitializeDesign();
            this.ParentForm.CenterInforHelp.InitializeDesign();
            this.ParentForm.CenterInforSystem.InitializeDesign();
            this.ParentForm.CenterInforSystem2.InitializeDesign();
            this.ParentForm.CenterInforSystem3.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterSystemCalibration.InitializeDesign();
            this.ParentForm.CenterSystemExternalOutput.InitializeDesign();
            this.ParentForm.CenterSystemHelp.InitializeDesign();
            this.ParentForm.CenterSystemIOTest.InitializeDesign();
            this.ParentForm.CenterSystemJudgment.InitializeDesign();
            this.ParentForm.CenterSystemSorterSetting.InitializeDesign();
            this.ParentForm.CenterSystemAutoZero.InitializeDesign();
            this.ParentForm.CenterSystemBLDCMotorSetting.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterInforAS.DefaultSetting();

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

            before = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI6);
            value = Helper.StringZeroFillDigits4(this.comboBoxPIN6.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter1.PI6 = this.comboBoxPIN6.SelectedIndex;
            after = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI6);

            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI6, value);

            if (before != after)
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.ExIn6Mode, "", before, after);
        }
        private void comboBoxPIN5_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI5);
            value = Helper.StringZeroFillDigits4(this.comboBoxPIN5.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter1.PI5 = this.comboBoxPIN5.SelectedIndex;
            after = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI5);

            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI5, value);

            if (before != after)
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.ExIn5Mode, "", before, after);
        }
        private void comboBoxPIN4_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI4);
            value = Helper.StringZeroFillDigits4(this.comboBoxPIN4.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter1.PI4 = this.comboBoxPIN4.SelectedIndex;
            after = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI4);

            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI4, value);

            if (before != after)
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.ExIn4Mode, "", before, after);
        }
        private void comboBoxPIN3_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI3);
            value = Helper.StringZeroFillDigits4(this.comboBoxPIN3.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter1.PI3 = this.comboBoxPIN3.SelectedIndex;
            after = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI3);

            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI3, value);

            if (before != after)
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.ExIn3Mode, "", before, after);
        }
        private void comboBoxPIN2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI2);
            value = Helper.StringZeroFillDigits4(this.comboBoxPIN2.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter1.PI2 = this.comboBoxPIN2.SelectedIndex;
            after = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnExternalInput(this.ParentForm.ParentForm.CurrentSystemParameter1.PI2);

            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI2, value);

            if (before != after)
                this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.ExIn2Mode, "", before, after);
        }

        private void buttonLogin_Click(object sender, EventArgs e)
        {
            DialogFormYesNo myDlg;
            string before = "", after = "";

            if (this.ParentForm.ParentForm.SystemConfig3.IsPart11 == true)
            {
                if (this.buttonLogin.ButtonStatus == SmartButton.BUTSTATUS.UP)
                    this.buttonLogin.ButtonDown();
                return;
            }

            if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == false)
                before = "OFF";
            else
                before = "ON";

            if (this.buttonLogin.ButtonStatus == SmartX.SmartButton.BUTSTATUS.UP)
                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 16);
            else
                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 15);

            if (myDlg.ShowDialog() == DialogResult.Yes)
            {
                if (this.buttonLogin.ButtonStatus == SmartX.SmartButton.BUTSTATUS.UP)
                {
                    this.ParentForm.ParentForm.SystemConfig1.IsLogin = false;
                    this.ParentForm.LoginVisible(false);
                    after = "OFF";

                    // User 삭제
                    UserManager.UserManager_UserAllDel();
                }
                else
                {
                    this.ParentForm.ParentForm.SystemConfig1.IsLogin = true;
                    this.ParentForm.LoginVisible(true);
                    after = "ON";
                }

                this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);

                if (before != after)
                    this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.IsLogin, "", before, after);

                DialogFormMessage msg = new DialogFormMessage(18, this.ParentForm.ParentForm.SystemConfig1.Language);
                msg.ShowDialog();
            }
            else
            {
                this.buttonLogin.Click -= new EventHandler(this.buttonLogin_Click);

                if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == false)
                    this.buttonLogin.ButtonUp();
                else
                    this.buttonLogin.ButtonDown();

                this.buttonLogin.Click += new EventHandler(this.buttonLogin_Click);
            }
        }
        private void buttonExternalInputBuzzer_Click(object sender, EventArgs e)
        {
            if (this.buttonExternalInputBuzzer.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.SystemConfig1.IsExternalInputBuzzer = true;
            else
                this.ParentForm.ParentForm.SystemConfig1.IsExternalInputBuzzer = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
        }
        private void buttonExternalInputLamp_Click(object sender, EventArgs e)
        {
            if (this.buttonExternalInputLamp.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.SystemConfig1.IsExternalInputLamp = true;
            else
                this.ParentForm.ParentForm.SystemConfig1.IsExternalInputLamp = false;

            this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
        }

        private void buttonCapture_Click(object sender, EventArgs e)
        {
            string filePath = "";
            Bitmap bitMap = new Bitmap(800, 600);

            bitMap = IntechGraphics.CopyFromScreen();
            filePath = string.Format("{0}\\{1}_FunctionSetting.jpg", this.ParentForm.ParentForm.PathDataLogFolder, DateTime.Now.ToString("yyyyMMdd"));
            bitMap.Save(filePath, ImageFormat.Jpeg);
        }

        private void buttonCommunicationLog_Click(object sender, EventArgs e)
        {
            if (this.buttonCommunicationLog.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.smartFileCommunicationLog.Close();
                this.ParentForm.ParentForm.smartFileCommunicationLog.Open(this.ParentForm.ParentForm.BufferSmartUart);
                this.ParentForm.ParentForm.IsCommunicationLogOpen = true;
            }
            else
            {
                this.ParentForm.ParentForm.smartFileCommunicationLog.Close();
                this.ParentForm.ParentForm.IsCommunicationLogOpen = false;
            }
        }

        private void buttonBackupDataList_Click(object sender, EventArgs e)
        {
            int count = 0;
            bool directoryCheck = false;
            string filePath = "";
            DirectoryInfo dir = new DirectoryInfo(this.ParentForm.ParentForm.PathDataLogFolder);
            directoryCheck = dir.Exists;
            // 폴더 체크
            if (directoryCheck == false)
                dir.Create();

            FileInfo[] checkFiles = dir.GetFiles();

            if (this.ParentForm.ParentForm.IsCommunicationLogOpen == true)
                this.ParentForm.ParentForm.smartFileCommunicationLog.Close();
            //this.ParentForm.ParentForm.smartFileCheckLog.Close();
            //this.ParentForm.ParentForm.IsErrorLogOpen = false;

            count = this.listBoxDataList.Items.Count;
            if (count == 0 && checkFiles.Length == 0)
            {
                DialogFormMessage msg = new DialogFormMessage(4, this.ParentForm.ParentForm.SystemConfig1.Language);
                msg.ShowDialog();
                return;
            }

            SmartSplash splash = new SmartSplash();
            splash.CenterPosition = true;
            splash.AnimationInterval = 200;
            splash.LoadingImagePathname = "SmartLoading4";
            splash.Start();

            try
            {
                DirectoryInfo dinfo = new DirectoryInfo("하드 디스크\\");
                dinfo.GetDirectories();
            }
            catch
            {
                splash.Finish();

                DialogFormMessage msg = new DialogFormMessage(5, this.ParentForm.ParentForm.SystemConfig1.Language);
                msg.ShowDialog();
                return;
            }

            try
            {
                filePath = "하드 디스크\\";

                FileInfo[] files = dir.GetFiles();

                foreach (FileInfo file in files)
                {
                    this.FileCopy(file, filePath + file.Name);

                    this.listBoxDataList.Items.Remove(file.Name);
                    file.Delete();
                }
                this.labelFileCount1.Text = this.listBoxDataList.Items.Count.ToString();

                // CheckLog
                //this.ParentForm.ParentForm.smartFileCheckLog.Open();
                //this.ParentForm.ParentForm.IsErrorLogOpen = true;

                splash.Finish();

                DialogFormMessage msg = new DialogFormMessage(count.ToString(), this.ParentForm.ParentForm.SystemConfig1.Language);
                msg.ShowDialog();

                if (this.ParentForm.ParentForm.IsCommunicationLogOpen == true)
                    this.ParentForm.ParentForm.smartFileCommunicationLog.Open();
            }
            catch
            {
                splash.Finish();

                DialogFormMessage msg = new DialogFormMessage(6, this.ParentForm.ParentForm.SystemConfig1.Language);
                msg.ShowDialog();
                return;
            }
        }
        #endregion        
    }
}
