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

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

        #region Constructor
        public ControlCenterEquipEngineer(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);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                #region 영어
                this.labelTitleEquipmentType.Text = "Equipment Type";
                this.labelTitleCommunicationOption.Text = "Communication Option";
                this.labelTitleSortingNGLength.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSortingNGLength.Text = "Sorting NG Length";
                this.labelTitleConveyorLength.Text = "Conveyor Length";
                this.labelTitleProductEntryUndetected.Text = "Product entry undetected";
                this.labelTitleSelectInverter.Text = "Select Inverter";
                this.labelTitleOptionBoard.Text = "Option board";
                this.labelTitleFileNameExtension.Text = "File Name Extension";
                this.labelTitleDataBackupFormat.Text = "Databackup Format";
                this.labelTitleStatPrintFormat.Text = "Statistics Print Format";
                this.labelTitleBarcode.Text = "Barcode";
                this.labelTitleSortByProductNo.Text = "Sorting by Product Number";

                this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
                this.comboBoxEquipmentType.Items.Clear();
                this.comboBoxEquipmentType.Items.Add("Conveyor");
                this.comboBoxEquipmentType.Items.Add("Stop-Weight");
                this.comboBoxEquipmentType.Items.Add("Updown");
                this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.Items.Clear();
                this.comboBoxOptionBoard.Items.Add("None");
                this.comboBoxOptionBoard.Items.Add("OPT1");
                this.comboBoxOptionBoard.Items.Add("OPT2");
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);

                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.Items.Clear();
                this.comboBoxBarcode.Items.Add("None");
                this.comboBoxBarcode.Items.Add("STD1");
                this.comboBoxBarcode.Items.Add("DS4800/DS5100");
                this.comboBoxBarcode.Items.Add("Cognex DM150Q");
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);

                this.buttonCommunicationOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonCommunicationOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonSortingNGLength.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonSortingNGLength.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonSortingByProductNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonSortingByProductNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                #region 중국어
                this.labelTitleEquipmentType.Text = "设备类型";
                this.labelTitleCommunicationOption.Text = "通讯选项";
                this.labelTitleSortingNGLength.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSortingNGLength.Text = "产品长度有缺陷时的选择";
                this.labelTitleConveyorLength.Text = "输送带长度";
                this.labelTitleProductEntryUndetected.Text = "未检测到产品条目";
                this.labelTitleSelectInverter.Text = "选择逆变器";
                this.labelTitleOptionBoard.Text = "选项板";
                this.labelTitleFileNameExtension.Text = "数据备份:文件扩展名";
                this.labelTitleDataBackupFormat.Text = "数据备份:格式";
                this.labelTitleStatPrintFormat.Text = "数据统计:列印格式";
                this.labelTitleBarcode.Text = "条形码";
                this.labelTitleSortByProductNo.Text = "按产品编号排序";

                this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
                this.comboBoxEquipmentType.Items.Clear();
                this.comboBoxEquipmentType.Items.Add("输送带");
                this.comboBoxEquipmentType.Items.Add("停止后重量");
                this.comboBoxEquipmentType.Items.Add("上下操作");
                this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.Items.Clear();
                this.comboBoxOptionBoard.Items.Add("不使用");
                this.comboBoxOptionBoard.Items.Add("OPT1");
                this.comboBoxOptionBoard.Items.Add("OPT2");
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);

                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.Items.Clear();
                this.comboBoxBarcode.Items.Add("不使用");
                this.comboBoxBarcode.Items.Add("STD1");
                this.comboBoxBarcode.Items.Add("DS4800/DS5100");
                this.comboBoxBarcode.Items.Add("Cognex DM150Q");
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);

                this.buttonCommunicationOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonCommunicationOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonSortingNGLength.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonSortingNGLength.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonSortingByProductNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonSortingByProductNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                #region 러시아어
                this.labelTitleEquipmentType.Text = "Тип оборудования";
                this.labelTitleCommunicationOption.Text = "Варианты связи";
                this.labelTitleSortingNGLength.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleSortingNGLength.Text = "Выбор при дефектной длине изделия";
                this.labelTitleConveyorLength.Text = "Длина конвейера";
                this.labelTitleProductEntryUndetected.Text = "Вход продукта незамеченным";
                this.labelTitleSelectInverter.Text = "Выберите инвертор";
                this.labelTitleOptionBoard.Text = "Опции";
                this.labelTitleFileNameExtension.Text = "Расширение файла";
                this.labelTitleDataBackupFormat.Text = "Формат";
                this.labelTitleStatPrintFormat.Text = "Формат печати(Статистика)";
                this.labelTitleBarcode.Text = "Штрих-код";
                this.labelTitleSortByProductNo.Text = "Сортировка по номеру продукта";

                this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
                this.comboBoxEquipmentType.Items.Clear();
                this.comboBoxEquipmentType.Items.Add("Конвейер");
                this.comboBoxEquipmentType.Items.Add("Взвешивание с остановкой");
                this.comboBoxEquipmentType.Items.Add("Вверх-вниз");
                this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.Items.Clear();
                this.comboBoxOptionBoard.Items.Add("Нет");
                this.comboBoxOptionBoard.Items.Add("OPT1");
                this.comboBoxOptionBoard.Items.Add("OPT2");
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);

                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.Items.Clear();
                this.comboBoxBarcode.Items.Add("Нет");
                this.comboBoxBarcode.Items.Add("STD1");
                this.comboBoxBarcode.Items.Add("DS4800/DS5100");
                this.comboBoxBarcode.Items.Add("Cognex DM150Q");
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);

                this.buttonCommunicationOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonCommunicationOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonSortingNGLength.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonSortingNGLength.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonSortingByProductNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonSortingByProductNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                #region 독일어
                this.labelTitleEquipmentType.Text = "Waagentyp";
                this.labelTitleCommunicationOption.Text = "Kommunikationsmöglichkeiten";
                this.labelTitleSortingNGLength.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleSortingNGLength.Text = "Auswahl bei fehlerhafter Produktlänge";
                this.labelTitleConveyorLength.Text = "Fördererlänge";
                this.labelTitleProductEntryUndetected.Text = "Produkteintrag unerkannt";
                this.labelTitleSelectInverter.Text = "Wechselrichter auswählen";
                this.labelTitleOptionBoard.Text = "Optionsplatine";
                this.labelTitleFileNameExtension.Text = "Dateinamenerweiterung";
                this.labelTitleDataBackupFormat.Text = "Datensicherung Format";
                this.labelTitleStatPrintFormat.Text = "Statistik-Druckformat";
                this.labelTitleBarcode.Text = "Barcode";
                this.labelTitleSortByProductNo.Text = "Sortierung nach Produktnummer";

                this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
                this.comboBoxEquipmentType.Items.Clear();
                this.comboBoxEquipmentType.Items.Add("Förderer");
                this.comboBoxEquipmentType.Items.Add("Stoppen");
                this.comboBoxEquipmentType.Items.Add("Obenunten");
                this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.Items.Clear();
                this.comboBoxOptionBoard.Items.Add("Keiner");
                this.comboBoxOptionBoard.Items.Add("OPT1");
                this.comboBoxOptionBoard.Items.Add("OPT2");
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);

                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.Items.Clear();
                this.comboBoxBarcode.Items.Add("Keiner");
                this.comboBoxBarcode.Items.Add("STD1");
                this.comboBoxBarcode.Items.Add("DS4800/DS5100");
                this.comboBoxBarcode.Items.Add("Cognex DM150Q");
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);

                this.buttonCommunicationOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonCommunicationOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonSortingNGLength.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonSortingNGLength.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonSortingByProductNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonSortingByProductNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                #region 스페인어
                this.labelTitleEquipmentType.Text = "Tipo de equipo";
                this.labelTitleCommunicationOption.Text = "Opción de comunicación";
                this.labelTitleSortingNGLength.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.labelTitleSortingNGLength.Text = "Clasificación cuando la longitud del producto es defectuosa";
                this.labelTitleConveyorLength.Text = "Longitud del transportador";
                this.labelTitleProductEntryUndetected.Text = "Entrada de producto no detectada";
                this.labelTitleSelectInverter.Text = "Seleccionar inversor";
                this.labelTitleOptionBoard.Text = "Tablero opcional";
                this.labelTitleFileNameExtension.Text = "Extensión de nombre de archivo";
                this.labelTitleDataBackupFormat.Text = "Copia de seguridad Formato";
                this.labelTitleStatPrintFormat.Text = "Formato de impresión de estadísticas";
                this.labelTitleBarcode.Text = "Código de barras";
                this.labelTitleSortByProductNo.Text = "Clasificación por número de producto";

                this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
                this.comboBoxEquipmentType.Items.Clear();
                this.comboBoxEquipmentType.Items.Add("Transportador");
                this.comboBoxEquipmentType.Items.Add("Peso después de parar");
                this.comboBoxEquipmentType.Items.Add("Arriba abajo");
                this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.Items.Clear();
                this.comboBoxOptionBoard.Items.Add("Ninguna");
                this.comboBoxOptionBoard.Items.Add("OPT1");
                this.comboBoxOptionBoard.Items.Add("OPT2");
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);

                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.Items.Clear();
                this.comboBoxBarcode.Items.Add("Ninguna");
                this.comboBoxBarcode.Items.Add("STD1");
                this.comboBoxBarcode.Items.Add("DS4800/DS5100");
                this.comboBoxBarcode.Items.Add("Cognex DM150Q");
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);

                this.buttonCommunicationOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonCommunicationOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonSortingNGLength.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonSortingNGLength.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonSortingByProductNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonSortingByProductNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
            else
            {
                #region 한국어
                this.labelTitleEquipmentType.Text = "장비타입";
                this.labelTitleCommunicationOption.Text = "통신모드 옵션 사용";
                this.labelTitleSortingNGLength.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSortingNGLength.Text = "제품길이 이상 시 선별";
                this.labelTitleConveyorLength.Text = "컨베어 길이";
                this.labelTitleProductEntryUndetected.Text = "제품진입 미감지";
                this.labelTitleSelectInverter.Text = "인버터 선택";
                this.labelTitleOptionBoard.Text = "옵션보드";
                this.labelTitleFileNameExtension.Text = "데이터백업 확장자";
                this.labelTitleDataBackupFormat.Text = "데이터백업 포맷";
                this.labelTitleStatPrintFormat.Text = "데이터집계 출력 포맷";
                this.labelTitleBarcode.Text = "바코드";
                this.labelTitleSortByProductNo.Text = "품번선별 기능 사용";

                this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
                this.comboBoxEquipmentType.Items.Clear();
                this.comboBoxEquipmentType.Items.Add("컨베어");
                this.comboBoxEquipmentType.Items.Add("정지계량");
                this.comboBoxEquipmentType.Items.Add("업다운");
                this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.Items.Clear();
                this.comboBoxOptionBoard.Items.Add("None");
                this.comboBoxOptionBoard.Items.Add("OPT1");
                this.comboBoxOptionBoard.Items.Add("OPT2");
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);

                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.Items.Clear();
                this.comboBoxBarcode.Items.Add("None");
                this.comboBoxBarcode.Items.Add("STD1");
                this.comboBoxBarcode.Items.Add("DS4800/DS5100");
                this.comboBoxBarcode.Items.Add("Cognex DM150Q");
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);

                this.buttonCommunicationOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonCommunicationOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonSortingNGLength.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonSortingNGLength.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonSortingByProductNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonSortingByProductNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
        }
        private void DefaultSetting()
        {
            this.comboBoxSelectInverter.SelectedIndexChanged -= new EventHandler(this.comboBoxSelectInverter_SelectedIndexChanged);
            this.comboBoxSelectInverter.Items.Clear();
            this.comboBoxSelectInverter.Items.Add("Mitsubishi");
            this.comboBoxSelectInverter.Items.Add("LS Electric");
            this.comboBoxSelectInverter.SelectedIndexChanged += new EventHandler(this.comboBoxSelectInverter_SelectedIndexChanged);

            this.comboBoxDataBackupFormat.SelectedIndexChanged -= new EventHandler(this.comboBoxFormat_SelectedIndexChanged);
            this.comboBoxDataBackupFormat.Items.Clear();
            this.comboBoxDataBackupFormat.Items.Add("STD1");
            this.comboBoxDataBackupFormat.Items.Add("OPT1"); // 종근당
            this.comboBoxDataBackupFormat.SelectedIndexChanged += new EventHandler(this.comboBoxFormat_SelectedIndexChanged);

            this.comboBoxFilenameExtension.SelectedIndexChanged -= new EventHandler(this.comboBoxFilenameExtension_SelectedIndexChanged);
            this.comboBoxFilenameExtension.Items.Clear();
            this.comboBoxFilenameExtension.Items.Add("CSV");
            this.comboBoxFilenameExtension.Items.Add("TXT");
            this.comboBoxFilenameExtension.SelectedIndexChanged += new EventHandler(this.comboBoxFilenameExtension_SelectedIndexChanged);

            this.comboBoxStatisticsPrintFormat.SelectedIndexChanged -= new EventHandler(this.comboBoxStatisticsPrintFormat_SelectedIndexChanged);
            this.comboBoxStatisticsPrintFormat.Items.Clear();
            this.comboBoxStatisticsPrintFormat.Items.Add("STD1");
            this.comboBoxStatisticsPrintFormat.Items.Add("OPT1"); // 삼천당제약
            this.comboBoxStatisticsPrintFormat.SelectedIndexChanged += new EventHandler(this.comboBoxStatisticsPrintFormat_SelectedIndexChanged);
        }

        private void UpdateParameterDisplay(SystemConfigurationItem1 item, SystemConfigurationItem2 item2, SystemParameter1 parameter)
        {
            int index = 0;
            string value = "";

            // 장비타입
            this.comboBoxEquipmentType.SelectedIndexChanged -= new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);
            switch (int.Parse(parameter.EquipmentType))
            {
                case 0: // 컨베어
                    this.comboBoxEquipmentType.SelectedIndex = 0;
                    break;
                case 4: // 업다운
                    this.comboBoxEquipmentType.SelectedIndex = 2;
                    break;
                case 6: // 정지계량
                    this.comboBoxEquipmentType.SelectedIndex = 1;
                    break;
                default:
                    this.comboBoxEquipmentType.SelectedIndex = 0;
                    break;
            }
            this.comboBoxEquipmentType.SelectedIndexChanged += new EventHandler(this.comboBoxEquipmentType_SelectedIndexChanged);

            // 통신옵션 사용
            if (item2.IsCommunicationOption == true)
                this.buttonCommunicationOption.ButtonDown();
            else
                this.buttonCommunicationOption.ButtonUp();

            // 길이 NG 시 선별 사용
            if (parameter.SortingWhenNGLength == "1")
                this.buttonSortingNGLength.ButtonDown();
            else
                this.buttonSortingNGLength.ButtonUp();

            // 컨베어 입력
            value = item2.ConveyorLength.ToString();
            if (this.labelConveyorLength.Text != value)
                this.labelConveyorLength.Text = value;

            // 옵션보드
            index = int.Parse(parameter.OptionBoard.Trim());
            if (this.comboBoxOptionBoard.SelectedIndex != index)
            {
                this.comboBoxOptionBoard.SelectedIndexChanged -= new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
                this.comboBoxOptionBoard.SelectedIndex = index;
                this.comboBoxOptionBoard.SelectedIndexChanged += new EventHandler(this.comboBoxOptionBoard_SelectedIndexChanged);
            }

            // 데이터백업 포맷
            index = item.DatabackupFormat;
            if (this.comboBoxDataBackupFormat.SelectedIndex != index)
            {
                this.comboBoxDataBackupFormat.SelectedIndexChanged -= new EventHandler(this.comboBoxFormat_SelectedIndexChanged);
                this.comboBoxDataBackupFormat.SelectedIndex = index;
                this.comboBoxDataBackupFormat.SelectedIndexChanged += new EventHandler(this.comboBoxFormat_SelectedIndexChanged);
            }

            // 데이터백업 확장자
            index = item2.FileNameExtension;
            if (this.comboBoxFilenameExtension.SelectedIndex != index)
            {
                this.comboBoxFilenameExtension.SelectedIndexChanged -= new EventHandler(this.comboBoxFilenameExtension_SelectedIndexChanged);
                this.comboBoxFilenameExtension.SelectedIndex = index;
                this.comboBoxFilenameExtension.SelectedIndexChanged += new EventHandler(this.comboBoxFilenameExtension_SelectedIndexChanged);
            }

            // 데이터집계 출력 포맷
            index = item.StatisticsPrintFormat;
            if (this.comboBoxStatisticsPrintFormat.SelectedIndex != index)
            {
                this.comboBoxStatisticsPrintFormat.SelectedIndexChanged -= new EventHandler(this.comboBoxStatisticsPrintFormat_SelectedIndexChanged);
                this.comboBoxStatisticsPrintFormat.SelectedIndex = index;
                this.comboBoxStatisticsPrintFormat.SelectedIndexChanged += new EventHandler(this.comboBoxStatisticsPrintFormat_SelectedIndexChanged);
            }

            // 바코드
            index = item2.Barcode;
            if (this.comboBoxBarcode.SelectedIndex != index)
            {
                this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                this.comboBoxBarcode.SelectedIndex = index;
                this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
            }

            // 품번선별
            if (parameter.SortingByProductNo == "1")
                this.buttonSortingByProductNo.ButtonDown();
            else
                this.buttonSortingByProductNo.ButtonUp();

            value = Helper.StringToDecimalPlaces(item2.EntryNotDetectedWeight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            if (this.labelEntryNotDetected.Text != value)
                this.labelEntryNotDetected.Text = value;

            // 인버터
            index = int.Parse(parameter.Inverter);
            if (this.comboBoxSelectInverter.SelectedIndex != index)
            {
                this.comboBoxSelectInverter.SelectedIndexChanged -= new EventHandler(this.comboBoxSelectInverter_SelectedIndexChanged);
                this.comboBoxSelectInverter.SelectedIndex = index;
                this.comboBoxSelectInverter.SelectedIndexChanged += new EventHandler(this.comboBoxSelectInverter_SelectedIndexChanged);
            }
        }

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

            this.UpdateParameterDisplay(this.ParentForm.ParentForm.SystemConfig1, this.ParentForm.ParentForm.SystemConfig2,
                this.ParentForm.ParentForm.CurrentSystemParameter1);
        }
        #endregion

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

            switch (this.comboBoxEquipmentType.SelectedIndex)
            {
                case 0: // 컨베어
                    this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType = "0";
                    break;
                case 1: // 정지계량
                    this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType = "6";
                    break;
                case 2: // 업다운
                    this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType = "4";
                    break;
                default:
                    this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType = "0";
                    break;
            }

            value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType);
            this.ParentForm.CenterSystemJudgmentManual.ChangeScreen();
            this.ParentForm.CenterInforSystem2.ReInitializeDesign();
            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.EquipmentType, value);
        }
        private void buttonCommunicationOption_Click(object sender, EventArgs e)
        {
            if (this.buttonCommunicationOption.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption = true;
            else
                this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption = false;

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

            this.ParentForm.ParentForm.ChildFormMenu.CenterConfiSerial.ChangeCommunicationMode();
            this.ParentForm.ParentForm.ChildFormMenu.CenterConfiEthernet.ChangeCommunicationMode();
        }
        private void buttonSortingNGLength_Click(object sender, EventArgs e)
        {
            string value = "";

            if (this.buttonSortingNGLength.ButtonStatus == SmartButton.BUTSTATUS.UP)
            {
                value = "0000";
                this.ParentForm.ParentForm.CurrentSystemParameter1.SortingWhenNGLength = "0";
            }
            else
            {
                value = "0001";
                this.ParentForm.ParentForm.CurrentSystemParameter1.SortingWhenNGLength = "1";
            }
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.SortingWhenNGLength, value);
            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
        }
        private void labelConveyorLength_Click(object sender, EventArgs e)
        {
            string value = "", message = "";

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelConveyorLength.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
                }
            }
        }
        private void labelEntryNotDeteced_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelEntryNotDetected.Text, 5, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces,
              false, this.ParentForm.ParentForm.SystemConfig1.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0.0)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelEntryNotDetected.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.SystemConfig2.EntryNotDetectedWeight = myKeyPad.StringValue.Replace(".", "");
                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);

                    value = Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.SystemConfig2.EntryNotDetectedWeight);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.EntryNotDetectedWeight, value);
                }
            }
        }

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

            this.ParentForm.ParentForm.CurrentSystemParameter1.Inverter = this.comboBoxSelectInverter.SelectedIndex.ToString();
            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);

            value = Helper.StringZeroFillDigits4(this.comboBoxSelectInverter.SelectedIndex.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.Inverter, value);
        }
        private void comboBoxOptionBoard_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            value = Helper.StringZeroFillDigits4(this.comboBoxOptionBoard.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter1.OptionBoard = value;
            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OptionBoard, value);

            this.ParentForm.CenterSystemExternalInput.OptionBoardSet(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.ChildFormMenu.CenterConfiOptionBoard.InitializeDesign();

            this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightBigScreen.UpdateDisplay();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightSmallScreen.UpdateDisplay();
        }
        private void comboBoxFilenameExtension_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.SystemConfig2.FileNameExtension = this.comboBoxFilenameExtension.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void comboBoxStatisticsPrintFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.SystemConfig1.StatisticsPrintFormat = this.comboBoxStatisticsPrintFormat.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
        }
        private void comboBoxFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.SystemConfig1.DatabackupFormat = this.comboBoxDataBackupFormat.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
        }
        private void comboBoxBarcode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            DialogFormYesNo myDlg;

            if (this.comboBoxBarcode.SelectedIndex > 0)
            {
                if (this.ParentForm.ParentForm.SystemConfig2.Barcode > 0)
                {
                    this.ParentForm.ParentForm.SystemConfig2.Barcode = this.comboBoxBarcode.SelectedIndex;
                    this.ParentForm.ParentForm.BarcodeSerialSetting();
                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
                }
                else
                {
                    myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 17); // 사용하시겠습니까?

                    if (myDlg.ShowDialog() == DialogResult.Yes)
                    {
                        this.ParentForm.ParentForm.SystemConfig2.Barcode = this.comboBoxBarcode.SelectedIndex;

                        this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = 0;
                        this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = 0;

                        if (this.ParentForm.ParentForm.SystemConfig2.IsUsingRandomMode == true)
                        {
                            this.ParentForm.ParentForm.SystemConfig2.IsGroup1UsingRandomMode = false;
                            this.ParentForm.ParentForm.SystemConfig2.IsGroup2UsingRandomMode = false;
                            this.ParentForm.ParentForm.SystemConfig2.IsGroup3UsingRandomMode = false;
                            this.ParentForm.ParentForm.SystemConfig2.IsGroup4UsingRandomMode = false;
                            this.ParentForm.ParentForm.SystemConfig2.IsGroup5UsingRandomMode = false;
                        }

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

                        DialogFormMessage msg = new DialogFormMessage(18, this.ParentForm.ParentForm.SystemConfig1.Language);
                        msg.ShowDialog();
                    }
                    else
                    {
                        this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                        this.comboBoxBarcode.SelectedIndex = this.ParentForm.ParentForm.SystemConfig2.Barcode;
                        this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                    }
                }
            }
            else
            {
                if (this.ParentForm.ParentForm.SystemConfig2.Barcode == 0)
                    return;

                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 18); // 사용을 중지하시겠습니까?

                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    this.ParentForm.ParentForm.SystemConfig2.Barcode = 0;
                    this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = 0;
                    this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = 0;
                    this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
                    this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);

                    DialogFormMessage msg = new DialogFormMessage(18, this.ParentForm.ParentForm.SystemConfig1.Language);
                    msg.ShowDialog();
                }
                else
                {
                    this.comboBoxBarcode.SelectedIndexChanged -= new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                    this.comboBoxBarcode.SelectedIndex = this.ParentForm.ParentForm.SystemConfig2.Barcode;
                    this.comboBoxBarcode.SelectedIndexChanged += new EventHandler(this.comboBoxBarcode_SelectedIndexChanged);
                }
            }

            this.ParentForm.ParentForm.SystemConfig2.Barcode = this.comboBoxBarcode.SelectedIndex;
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
        }
        private void buttonSortingByProductNo_Click(object sender, EventArgs e)
        {
            string value = "";

            if (this.buttonSortingByProductNo.ButtonStatus == SmartButton.BUTSTATUS.UP)
            {
                value = "0000";
                this.ParentForm.ParentForm.CurrentSystemParameter1.SortingByProductNo = "0";
                this.ParentForm.ParentForm.ChildFormMenu.CenterBasicProduct.VisibleButtonSort(false);
            }
            else
            {
                value = "0001";
                this.ParentForm.ParentForm.CurrentSystemParameter1.SortingByProductNo = "1";
                this.ParentForm.ParentForm.ChildFormMenu.CenterBasicProduct.VisibleButtonSort(true);
            }
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.IsSortByProductNo, value);
            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
        }

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

            bitMap = IntechGraphics.CopyFromScreen();
            filePath = string.Format("{0}{1}_EngineerSetting.jpg",
                this.ParentForm.ParentForm.PathDataBackupFolder, this.ParentForm.ParentForm.SystemConfig1.SerialNumber);
            bitMap.Save(filePath, ImageFormat.Jpeg);
        }
        #endregion
    }
}
