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 System.IO;

using SmartX;

using ITC81DB.Forms;
using ITC81DB.DialogForms;
using ITC81DB_ImageDll;
using System.Threading;

namespace ITC81DB.Controls
{
    public partial class ControlCenterEquipFunctionSetting : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        #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);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                #region English
                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.labelTitleChattering.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleChattering.Text = "Chattering";
                this.labelTitleSensorErrorDetectingTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSensorErrorDetectingTime.Text = "Sensor error detection time";
                this.labelTitleLanguage.Text = "Language";
                this.labelTitleEquipmentID.Text = "Equipment ID";
                this.labelTitleLogin.Text = "Login";
                this.labelTitleAverageTracking.Text = "Average tracking";                

                this.buttonCapture.Text = "Capture";
                this.labelTitleCommunicationLog.Text = "Comm-Log";
                this.labelTitleStartStopLog.Text = "Start/Stop Log";
                this.labelTitleBarcodeLog.Text = "Barcode Log";

                //this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                //this.comboBoxLanguage.Items.Clear();
                //this.comboBoxLanguage.Items.Add("Korean");
                //this.comboBoxLanguage.Items.Add("English");
                //this.comboBoxLanguage.Items.Add("German");
                //this.comboBoxLanguage.Items.Add("Chinese");
                //this.comboBoxLanguage.Items.Add("Russian");
                //this.comboBoxLanguage.Items.Add("Spanish");
                //this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonRFIDSpeedwayR420.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonRFIDSpeedwayR420.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonAverageTracking.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonAverageTracking.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonStartStopLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonStartStopLog.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));
                this.buttonBarcodeLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonBarcodeLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                #region Chinese
                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "蜂鸣器开启时间";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "继电器接通时间";
                this.labelTitleChattering.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleChattering.Text = "颤振";
                this.labelTitleSensorErrorDetectingTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSensorErrorDetectingTime.Text = "传感器错误检测时间";
                this.labelTitleLanguage.Text = "语言";
                this.labelTitleEquipmentID.Text = "设备编号";
                this.labelTitleLogin.Text = "登錄";
                this.labelTitleAverageTracking.Text = "参考值更新";

                this.buttonCapture.Text = "捕获";
                this.labelTitleCommunicationLog.Text = "Comm-Log";
                this.labelTitleStartStopLog.Text = "Start/Stop Log";
                this.labelTitleBarcodeLog.Text = "Barcode Log";

                //this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                //this.comboBoxLanguage.Items.Clear();
                //this.comboBoxLanguage.Items.Add("韩国语");
                //this.comboBoxLanguage.Items.Add("英语");
                //this.comboBoxLanguage.Items.Add("德语");
                //this.comboBoxLanguage.Items.Add("中文");
                //this.comboBoxLanguage.Items.Add("俄语");
                //this.comboBoxLanguage.Items.Add("西班牙语");
                //this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonRFIDSpeedwayR420.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonRFIDSpeedwayR420.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonAverageTracking.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonAverageTracking.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnOFF));
                this.buttonStartStopLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonStartStopLog.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));
                this.buttonBarcodeLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnON));
                this.buttonBarcodeLog.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 Russian
                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 8, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "Длительность звуковога сигнала";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "Длительность включения реле ";
                this.labelTitleChattering.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleChattering.Text = "Стабилизация веса";
                this.labelTitleSensorErrorDetectingTime.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleSensorErrorDetectingTime.Text = "Время обнаружения ошибки датчика";
                this.labelTitleLanguage.Text = "Язык";
                this.labelTitleEquipmentID.Text = "ID оборудования";
                this.labelTitleLogin.Text = "Логин";
                this.labelTitleAverageTracking.Text = "Среднее отслеживание";

                this.buttonCapture.Text = "Заголовок";
                this.labelTitleCommunicationLog.Text = "Comm-Log";
                this.labelTitleStartStopLog.Text = "Start/Stop Log";
                this.labelTitleBarcodeLog.Text = "Barcode Log";

                //this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                //this.comboBoxLanguage.Items.Clear();
                //this.comboBoxLanguage.Items.Add("Корейский");
                //this.comboBoxLanguage.Items.Add("английский");
                //this.comboBoxLanguage.Items.Add("Немецкий");
                //this.comboBoxLanguage.Items.Add("Китайский");
                //this.comboBoxLanguage.Items.Add("Русский");
                //this.comboBoxLanguage.Items.Add("испанский");
                //this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonRFIDSpeedwayR420.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonRFIDSpeedwayR420.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonAverageTracking.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonAverageTracking.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                this.buttonStartStopLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonStartStopLog.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));
                this.buttonBarcodeLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusON));
                this.buttonBarcodeLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                #region German
                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.labelTitleChattering.Font = new Font("새굴림", 10, FontStyle.Bold);
                this.labelTitleChattering.Text = "Beruhigung des Dehnungsmessers";
                this.labelTitleSensorErrorDetectingTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSensorErrorDetectingTime.Text = "Sensorfehlererkennungszeit";
                this.labelTitleLanguage.Text = "Sprache";
                this.labelTitleEquipmentID.Text = "ID-Vorrichtung";
                this.labelTitleLogin.Text = "Einloggen";
                this.labelTitleAverageTracking.Text = "Referenzwertaktualisierung";

                this.buttonCapture.Text = "Fang";
                this.labelTitleCommunicationLog.Text = "Comm-Log";
                this.labelTitleStartStopLog.Text = "Start/Stop Log";
                this.labelTitleBarcodeLog.Text = "Barcode Log";

                //this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                //this.comboBoxLanguage.Items.Clear();
                //this.comboBoxLanguage.Items.Add("Koreanisch");
                //this.comboBoxLanguage.Items.Add("Englisch");
                //this.comboBoxLanguage.Items.Add("Deutsch");
                //this.comboBoxLanguage.Items.Add("Chinesisch");
                //this.comboBoxLanguage.Items.Add("Russisch");
                //this.comboBoxLanguage.Items.Add("Spanisch");
                //this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonRFIDSpeedwayR420.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonRFIDSpeedwayR420.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonAverageTracking.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonAverageTracking.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                this.buttonStartStopLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonStartStopLog.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));
                this.buttonBarcodeLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerON));
                this.buttonBarcodeLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerOFF));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                #region 스페인어
                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "Zumbador a tiempo";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "Relé a tiempo";
                this.labelTitleChattering.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleChattering.Text = "Chapoteo";
                this.labelTitleSensorErrorDetectingTime.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.labelTitleSensorErrorDetectingTime.Text = "Tiempo de detección de error del sensor";
                this.labelTitleLanguage.Text = "Idioma";
                this.labelTitleEquipmentID.Text = "ID de equipo";
                this.labelTitleLogin.Text = "Acceso";
                this.labelTitleAverageTracking.Text = "Seguimiento promedio";

                this.buttonCapture.Text = "Captura";
                this.labelTitleCommunicationLog.Text = "Comm-Log";
                this.labelTitleStartStopLog.Text = "Start/Stop Log";
                this.labelTitleBarcodeLog.Text = "Barcode Log";

                //this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                //this.comboBoxLanguage.Items.Clear();
                //this.comboBoxLanguage.Items.Add("Coreano");
                //this.comboBoxLanguage.Items.Add("Inglés");
                //this.comboBoxLanguage.Items.Add("Alemán");
                //this.comboBoxLanguage.Items.Add("Chino");
                //this.comboBoxLanguage.Items.Add("Russian");
                //this.comboBoxLanguage.Items.Add("Español");
                //this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonRFIDSpeedwayR420.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonRFIDSpeedwayR420.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonAverageTracking.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonAverageTracking.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonStartStopLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonStartStopLog.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));
                this.buttonBarcodeLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonBarcodeLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                #endregion
            }
            else
            {
                #region Korean
                this.labelTitleBuzzerONTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleBuzzerONTime.Text = "부저 ON 시간";
                this.labelTitleRelayRunTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleRelayRunTime.Text = "릴레이 동작 시간";
                this.labelTitleChattering.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleChattering.Text = "채터링감지";
                this.labelTitleSensorErrorDetectingTime.Font = new Font("새굴림", 11, FontStyle.Bold);
                this.labelTitleSensorErrorDetectingTime.Text = "센서에러 감지시간";
                this.labelTitleLanguage.Text = "언어설정";
                this.labelTitleEquipmentID.Text = "장비 ID";
                this.labelTitleLogin.Text = "로그인";
                this.labelTitleAverageTracking.Text = "기준치 갱신(평균 추적)";
                
                this.buttonCapture.Text = "Capture";
                this.labelTitleCommunicationLog.Text = "통신로그";
                this.labelTitleStartStopLog.Text = "Start/Stop로그";
                this.labelTitleBarcodeLog.Text = "바코드로그";

                this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
                this.comboBoxLanguage.Items.Clear();
                this.comboBoxLanguage.Items.Add("한국어");
                this.comboBoxLanguage.Items.Add("영어");
                this.comboBoxLanguage.Items.Add("독일어");
                this.comboBoxLanguage.Items.Add("중국어");
                this.comboBoxLanguage.Items.Add("러시아어");
                this.comboBoxLanguage.Items.Add("스페인어");
                this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

                this.buttonLogin.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonLogin.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonRFIDSpeedwayR420.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonRFIDSpeedwayR420.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonAverageTracking.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonAverageTracking.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engOFF));
                this.buttonStartStopLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonStartStopLog.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));
                this.buttonBarcodeLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engON));
                this.buttonBarcodeLog.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("Deutsch");
            this.comboBoxLanguage.Items.Add("中文");
            this.comboBoxLanguage.Items.Add("Русский");
            this.comboBoxLanguage.Items.Add("español");
            this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged);

            if (this.ParentForm.ParentForm.SystemConfig2.Barcode > 0)
                this.DisplayRFID(false);
            else
                this.DisplayRFID(true);
        }

        public void DisplayRFID(bool bValue)
        {
            this.labelTitleRFIDSpeedwayR420.Visible = bValue;
            this.buttonRFIDSpeedwayR420.Visible = bValue;
        }
        public void DisplayHiddenMenu(bool bValue)
        {
            this.buttonCapture.Visible = bValue;
        }
        private void UpdateParameterDisplay(SystemConfigurationItem1 item, SystemConfigurationItem2 item2, SystemConfigurationItem3 item3, 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 = item3.SensorErrorDetectingTime.ToString();
            if (this.labelSensorErrorDetectingTime.Text != value)
                this.labelSensorErrorDetectingTime.Text = value;

            // 기준치 갱신
            if (item.IsAverageTracking == true)
                this.buttonAverageTracking.ButtonDown();
            else
                this.buttonAverageTracking.ButtonUp();

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

            // RFID Speedway R420
            if (item2.IsRFIDSpeedwayR420 == false)
                this.buttonRFIDSpeedwayR420.ButtonUp();
            else
                this.buttonRFIDSpeedwayR420.ButtonDown();

            if (this.ParentForm.ParentForm.IsCommunicationLogOpen == false)
                this.buttonCommunicationLog.ButtonUp();
            else
                this.buttonCommunicationLog.ButtonDown();

            // Start/Stop Log 사용
            if (this.ParentForm.ParentForm.SystemConfig3.IsStartStopLog == true)
                this.buttonStartStopLog.ButtonDown();
            else
                this.buttonStartStopLog.ButtonUp();

            // 바코드 로그
            if (this.ParentForm.ParentForm.IsBarcodeLogOpen == false)
                this.buttonBarcodeLog.ButtonUp();
            else
                this.buttonBarcodeLog.ButtonDown();
        }
        
        private void UpdateDisplayUser(UserItem user)
        {
            if (user.Group == DataStore.UserGroup.Level4Developer && this.ParentForm.ParentForm.SystemConfig1.IsLogin == true)
                this.DisplayHiddenMenu(true);
            else
                this.DisplayHiddenMenu(false);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.EquipFuctionSetting;
            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.SystemConfig3, this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.UpdateDisplayUser(status.CurrentUser);
        }
        #endregion

        #region Event Handler
        private void labelEquipmentID_Click(object sender, EventArgs e)
        {
            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();
                        this.labelEquipmentID.Text = myKeyPad.StringValue;

                        this.ParentForm.ParentForm.SystemConfig1.EquipmentID = myKeyPad.IntValue;
                        this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
                    }
                }
            }
        }
        private void labelBuzzerOnTime_Click(object sender, EventArgs e)
        {
            string value = "";
            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
                {
                    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);
                }
            }
        }
        private void labelRelayOnTime_Click(object sender, EventArgs e)
        {
            string value = "";
            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
                {
                    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);
                }
            }
        }
        private void labelChattering_Click(object sender, EventArgs e)
        {
            string value = "";
            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
                {
                    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);
                }
            }
        }
        private void labelSensorErrorDetectingTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelSensorErrorDetectingTime.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

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

                    this.ParentForm.ParentForm.SaveSystemConfigurationFile3(this.ParentForm.ParentForm.SystemConfig3);
              }
            }
        }

        private void buttonAverageTracking_Click(object sender, EventArgs e)
        {
            DialogFormYesNo myDlg;

            if (this.buttonAverageTracking.ButtonStatus == SmartButton.BUTSTATUS.UP)
            {
                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 26); // 사용을 중지하시겠습니까?

                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    this.ParentForm.ParentForm.SystemConfig1.IsAverageTracking = false;
                    this.ParentForm.ParentForm.DeleteAverageTrackingFile();

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

                    this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightBigScreen.UpdateDisplay();
                    this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightSmallScreen.UpdateDisplay();
                }
                else
                {
                    if (this.ParentForm.ParentForm.SystemConfig1.IsAverageTracking == false)
                        this.buttonAverageTracking.ButtonUp();
                    else
                        this.buttonAverageTracking.ButtonDown();
                }
            }
            else
            {
                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 25); // 사용하시겠습니까?

                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    this.ParentForm.ParentForm.SystemConfig1.IsAverageTracking = true;
                    this.ParentForm.ParentForm.SetAverageTrackingInit();

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

                    this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightBigScreen.UpdateDisplay();
                    this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightSmallScreen.UpdateDisplay();
                }
                else
                {
                    if (this.ParentForm.ParentForm.SystemConfig1.IsAverageTracking == false)
                        this.buttonAverageTracking.ButtonUp();
                    else
                        this.buttonAverageTracking.ButtonDown();
                }
            }
        }
        private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.comboBoxLanguage.SelectedIndex == 0)
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.Korean;
            else if (this.comboBoxLanguage.SelectedIndex == 1)
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.English;
            else if (this.comboBoxLanguage.SelectedIndex == 2)
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.German;
            else if (this.comboBoxLanguage.SelectedIndex == 3)
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.Chinese;
            else if (this.comboBoxLanguage.SelectedIndex == 4)
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.Russian;
            else if (this.comboBoxLanguage.SelectedIndex == 5)
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.Spanish;
            else
                this.ParentForm.ParentForm.SystemConfig1.Language = DataStore.LanguageID.Korean;

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

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

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

            this.ParentForm.ParentForm.ChildFormMainDisplay.MainSpotCheck.InitializeDesign();
            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.MainWeightSmallScreen.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainFeedback.InitializeDesign();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainModbus.InitializeDesign();
            Thread.Sleep(50);

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

            this.ParentForm.CenterConfiCountingOutput.InitializeDesign();
            this.ParentForm.CenterConfiEthernet.InitializeDesign();
            this.ParentForm.CenterConfiHelp.InitializeDesign();
            this.ParentForm.CenterConfiOptionBoard.InitializeDesign();
            this.ParentForm.CenterConfiSerial.InitializeDesign();
            this.ParentForm.CenterConfiEthernet.ControlEthernetLocalIP.InitializeDesign();
            this.ParentForm.CenterConfiEthernet.ControlModbusTCP.InitializeDesign();
            this.ParentForm.CenterConfiEthernet.ControlMultiJet.InitializeDesign();
            this.ParentForm.CenterConfiSerial.ControlBarcode.InitializeDesign();
            this.ParentForm.CenterConfiSerial.ControlHitachi.InitializeDesign();
            this.ParentForm.CenterConfiSerial.ControlMarkoprint.InitializeDesign();
            this.ParentForm.CenterConfiSerial.ControlUserDefine.InitializeDesign();
            this.ParentForm.CenterConfiSerial.ControlModbusRTU.InitializeDesign();
            this.ParentForm.CenterConfiSerial.ControlMultiJet.InitializeDesign();
            Thread.Sleep(50);

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

            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.CenterSystemAutoZero.InitializeDesign();
            this.ParentForm.CenterSystemCalibration.InitializeDesign();
            this.ParentForm.CenterSystemExternalInput.InitializeDesign();
            this.ParentForm.CenterSystemExternalOutput.InitializeDesign();
            this.ParentForm.CenterSystemHelp.InitializeDesign();
            this.ParentForm.CenterSystemIOTest.InitializeDesign();
            this.ParentForm.CenterSystemJudgmentManual.InitializeDesign();
            this.ParentForm.CenterSystemJudgmentUpdown.InitializeDesign();
            this.ParentForm.CenterSystemSorterSetting.InitializeDesign();
            this.ParentForm.CenterSystemJudgmentSelect.InitializeDesign();
            this.ParentForm.CenterSystemJudgmentAuto.InitializeDesign();
            this.ParentForm.CenterSystemExternalInput.InitializeDesign();
            Thread.Sleep(50);

            this.ParentForm.CenterInforAS.DefaultSetting();
            this.ParentForm.CenterEquipUserGroupEditor.UpdateAllMenu(this.ParentForm.ParentForm.CurrentSystemStatus);

            splash.Finish();
        }
        private void buttonRFIDSpeedwayR420_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormYesNo myDlg;

            if (this.buttonRFIDSpeedwayR420.ButtonStatus == SmartButton.BUTSTATUS.UP)
            {
                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 26); // 사용을 중지하시겠습니까?

                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    this.ParentForm.ParentForm.SystemConfig2.IsRFIDSpeedwayR420 = false;

                    // 통신모드 옵션 변경
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == true)
                        this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption = false;
                    this.ParentForm.ParentForm.ChildFormMenu.CenterConfiSerial.ChangeCommunicationMode();
                    this.ParentForm.ParentForm.ChildFormMenu.CenterConfiEthernet.ChangeCommunicationMode();

                    // Serial
                    if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f21_Impinj_Speedway_R420)
                    {
                        this.ParentForm.ParentForm.CloseSerialCOM3();
                        this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = 0;
                        this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = 0;
                        this.ParentForm.ParentForm.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.NONEFRAME_READTIMEOUT);
                    }

                    // 외부 입력
                    this.ParentForm.ParentForm.CurrentSystemParameter1.PI8 = 0;
                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter1.PI8.ToString());
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI8, value);

                    // 외부 출력
                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode = "0";
                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut4Mode, value);

                    // Ethernet
                    this.ParentForm.CenterConfiEthernet.timerServer.Enabled = false;
                    this.ParentForm.ParentForm.EthernetServerStop();
                    this.ParentForm.ParentForm.EthernetClientDisconnect();
                    this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode = 0;
                    this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode = 0;
                }
                else
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsRFIDSpeedwayR420 == false)
                        this.buttonRFIDSpeedwayR420.ButtonUp();
                    else
                        this.buttonRFIDSpeedwayR420.ButtonDown();
                }
            }
            else
            {
                myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 25); // 사용하시겠습니까?

                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    this.ParentForm.ParentForm.SystemConfig2.IsRFIDSpeedwayR420 = true;

                    this.ParentForm.ParentForm.SetRFIDInit();

                    // 통신모드 옵션 변경
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
                        this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption = true;
                    this.ParentForm.ParentForm.ChildFormMenu.CenterConfiSerial.ChangeCommunicationMode();
                    this.ParentForm.ParentForm.ChildFormMenu.CenterConfiEthernet.ChangeCommunicationMode();

                    // Serial
                    this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = 4;
                    this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = (int)DataStore.SerialMode.f21_Impinj_Speedway_R420;
                    this.ParentForm.ParentForm.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.ETXONLY);
                    this.ParentForm.ParentForm.OpenSerialCOM3();

                    // Ethernet
                    this.ParentForm.CenterConfiEthernet.timerServer.Enabled = false;
                    this.ParentForm.ParentForm.EthernetServerStop();
                    this.ParentForm.ParentForm.EthernetClientDisconnect();
                    this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode = 1;
                    this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode = (int)DataStore.EthernetMode.f21_Impinj_Speedway_R420;
                    if (string.Compare(this.ParentForm.ParentForm.smartConfigs.IPSettings.DeviceIP, "0.0.0.0") != 0)
                    {
                        this.ParentForm.ParentForm.EthernetServerStart();
                        this.ParentForm.CenterConfiEthernet.timerServer.Enabled = true;
                    }

                    // 외부 입력
                    this.ParentForm.ParentForm.CurrentSystemParameter1.PI8 = 15;
                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter1.PI8.ToString());
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PI8, value);

                    // 외부 출력
                    this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode = "12";
                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalOut4Mode, value);

                    // 선별기설정
                    this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2Mode = 3;
                    this.ParentForm.ParentForm.CurrentSystemParameter1.SorterEtcNg = "1";
                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter1.SorterEtcNg.ToString());
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.ExternalNG, value);
                    this.ParentForm.ParentForm.CurrentSystemParameter1.SorterDoubleEntry = "2";
                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter1.SorterDoubleEntry.ToString());
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.DoubleEnter, value);
                }
                else
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsRFIDSpeedwayR420 == false)
                        this.buttonRFIDSpeedwayR420.ButtonUp();
                    else
                        this.buttonRFIDSpeedwayR420.ButtonDown();
                }
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter1Mode.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter1DelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter1RunTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2Mode.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2DelayTime.ToString()));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2RunTime.ToString()));
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.UserDefined1, sb.ToString());

            this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
            this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
            this.ParentForm.ParentForm.SaveSystemParameter1File(this.ParentForm.ParentForm.CurrentSystemParameter1);
            this.ParentForm.ParentForm.SaveSystemParameter3File(this.ParentForm.ParentForm.CurrentSystemParameter3);
            this.ParentForm.ParentForm.SaveJudgmentSetFile(this.ParentForm.ParentForm.CurrentJudgmentSetItem, this.ParentForm.ParentForm.SystemConfig1.ProductNumber - 1);
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightBigScreen.UpdateDisplay();
            this.ParentForm.ParentForm.ChildFormMainDisplay.MainWeightSmallScreen.UpdateDisplay();
        }
        
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            DialogFormYesNo myDlg;

            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;
                else
                    this.ParentForm.ParentForm.SystemConfig1.IsLogin = true;

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

                DialogFormMessage msg = new DialogFormMessage(18, this.ParentForm.ParentForm.SystemConfig1.Language);
                msg.ShowDialog();
            }
            else
            {
                if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == false)
                    this.buttonLogin.ButtonUp();
                else
                    this.buttonLogin.ButtonDown();
            }
        }

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

            bitMap = IntechGraphics.CopyFromScreen();
            filePath = string.Format("{0}{1}_EquipmentSetting.jpg",
                this.ParentForm.ParentForm.PathDataBackupFolder, this.ParentForm.ParentForm.SystemConfig1.SerialNumber);
            bitMap.Save(filePath, ImageFormat.Jpeg);
        }
        private void buttonStartStopLog_Click(object sender, EventArgs e)
        {
            if (this.buttonStartStopLog.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.smartFileStartStopLog.Close();
                this.ParentForm.ParentForm.smartFileStartStopLog.Open(this.ParentForm.ParentForm.BufferSmartUart);
                this.ParentForm.ParentForm.SystemConfig3.IsStartStopLog = true;
            }
            else
            {
                this.ParentForm.ParentForm.smartFileStartStopLog.Close();
                this.ParentForm.ParentForm.SystemConfig3.IsStartStopLog = false;
            }

            this.ParentForm.ParentForm.SaveSystemConfigurationFile3(this.ParentForm.ParentForm.SystemConfig3);
        }
        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 buttonBarcodeLog_Click(object sender, EventArgs e)
        {
            if (this.buttonBarcodeLog.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.smartFileBarcodeLog.Close();
                this.ParentForm.ParentForm.smartFileBarcodeLog.Open(this.ParentForm.ParentForm.BufferSmartUart);
                this.ParentForm.ParentForm.IsBarcodeLogOpen = true;
            }
            else
            {
                this.ParentForm.ParentForm.smartFileBarcodeLog.Close();
                this.ParentForm.ParentForm.IsBarcodeLogOpen = false;
            }
        }
        #endregion
    }
}
