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

namespace ITC81DB_0H
{
    public partial class ControlCenterInforSystem2 : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;        
        #endregion

        #region Constructor
        public ControlCenterInforSystem2(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()
        {
            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {

                this.groupBoxCalibration.Text = "중량조정/판정설정";
                this.groupBoxCountingOutput.Text = "카운터출력";
                this.groupBoxSorter.Text = "선별기설정";
                this.groupBoxExternalOutput.Text = "외부출력";
                this.groupBoxAutoZero.Text = "자동영점";
                this.groupBoxValue.Text = "중량설정값";

                this.labelTitleMaxWeight.Text = "최대중량";
                this.labelTitleBalanceWeight.Text = "분동중량";
                this.labelTitleDecimalPoint.Text = "소수점";
                this.labelTitleDigit.Text = "한눈의 값";

                this.labelTitleFilter.Text = "필터";
                if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType) == 4)
                {
                    this.labelTitleJudgmentDelay.Text = "하강지연";
                    this.labelTitleDoubleDelay.Text = "상승지연";
                }
                else
                {
                    this.labelTitleJudgmentDelay.Text = "판정지연";
                    this.labelTitleDoubleDelay.Text = "이중지연";
                }

                this.labelTitleJudgmentNumeber.Text = "판정개수";
                this.labelTitleSpeed.Text = "이송속도";
                this.labelTitleDynamic.Text = "동보정";

                this.labelTitleSorterA.Text = "선별부A";
                this.labelTitleSorterB.Text = "선별부B";
                this.labelTitleModeSorter.Text = "모드";
                this.labelTitleDelaySorter.Text = "지연";
                this.labelTitleOperationSorter.Text = "동작";
                this.labelTitleDoubleEntry.Text = "이중진입";
                this.labelTitleExternalInput.Text = "외부입력";
                this.labelTitleETCNG.Text = "기타NG";

                this.labelTitleExternalOutput1.Text = "외부출력1";
                this.labelTitleExternalOutput2.Text = "외부출력2";
                this.labelTitleExternalOutput3.Text = "외부출력3";
                this.labelTitleExternalOutput4.Text = "외부출력4";
                this.labelTitleExternalOutput9.Text = "외부출력9";
                this.labelTitleExternalOutput10.Text = "외부출력10";
                this.labelTitleModeExOutput.Text = "모드";
                this.labelTitleDelayExOutput.Text = "지연";
                this.labelTitleOperationExOutput.Text = "동작";

                this.labelTitleMode1AutoZero.Text = "모드1";
                this.labelTitleMode2AutoZero.Text = "모드2";
                this.labelTitleMode1Time.Text = this.labelTitleMode2Time.Text = "시간";
                this.labelTitleMode1Range.Text = this.labelTitleMode2Range.Text = "범위";
                this.labelTitleMode1Variate.Text = this.labelTitleMode2Variate.Text = "변량";

                this.labelTitleModeCountingOutput.Text = "모드";
                this.labelTitleCountCountingOutput.Text = "개수";
                this.labelTitleAddonCountingOutput.Text = "부가기능";

                this.labelTitleUnder.Text = "하한값";
                this.labelTitlePass.Text = "기준값";
                this.labelTitleOver.Text = "상한값";
                this.labelTitleTare.Text = "용기값";
            }
            else
            {
                this.groupBoxCalibration.Text = "Calibration/Judgment";
                this.groupBoxCountingOutput.Text = "Counting output";
                this.groupBoxSorter.Text = "Sorter";
                this.groupBoxExternalOutput.Text = "External output";
                this.groupBoxAutoZero.Text = "Auto zero";
                this.groupBoxValue.Text = "Weight";

                this.labelTitleMaxWeight.Text = "Max W.";
                this.labelTitleBalanceWeight.Text = "Balance W.";
                this.labelTitleDecimalPoint.Text = "Dec point";
                this.labelTitleDigit.Text = "Digit";

                this.labelTitleFilter.Text = "Filter";
                if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType) == 4)
                {
                    this.labelTitleJudgmentDelay.Text = "D.Delay";
                    this.labelTitleDoubleDelay.Text = "A.Delay";
                }
                else
                {
                    this.labelTitleJudgmentDelay.Text = "J.Delay";
                    this.labelTitleDoubleDelay.Text = "Gap";
                }

                this.labelTitleJudgmentNumeber.Text = "J.Number";
                this.labelTitleSpeed.Text = "Speed";
                this.labelTitleDynamic.Text = "Dynamic";

                this.labelTitleSorterA.Text = "Sorter A";
                this.labelTitleSorterB.Text = "Sorter B";
                this.labelTitleModeSorter.Text = "Mode";
                this.labelTitleDelaySorter.Text = "Delay";
                this.labelTitleOperationSorter.Text = "Run";
                this.labelTitleDoubleEntry.Text = "Double entry";
                this.labelTitleExternalInput.Text = "External Input";
                this.labelTitleETCNG.Text = "Etc NG";

                this.labelTitleExternalOutput1.Text = "Ex.Output1";
                this.labelTitleExternalOutput2.Text = "Ex.Output2";
                this.labelTitleExternalOutput3.Text = "Ex.Output3";
                this.labelTitleExternalOutput4.Text = "Ex.Output4";
                this.labelTitleExternalOutput9.Text = "Ex.Output9";
                this.labelTitleExternalOutput10.Text = "Ex.Output10";
                this.labelTitleModeExOutput.Text = "Mode";
                this.labelTitleDelayExOutput.Text = "Delay";
                this.labelTitleOperationExOutput.Text = "Run";

                this.labelTitleMode1AutoZero.Text = "Mode1";
                this.labelTitleMode2AutoZero.Text = "Mode2";
                this.labelTitleMode1Time.Text = this.labelTitleMode2Time.Text = "Time";
                this.labelTitleMode1Range.Text = this.labelTitleMode2Range.Text = "Range";
                this.labelTitleMode1Variate.Text = this.labelTitleMode2Variate.Text = "Variate";

                this.labelTitleModeCountingOutput.Text = "Mode";
                this.labelTitleCountCountingOutput.Text = "Number";
                this.labelTitleAddonCountingOutput.Text = "Add-On";

                this.labelTitleUnder.Text = "Under";
                this.labelTitlePass.Text = "Pass";
                this.labelTitleOver.Text = "Over";
                this.labelTitleTare.Text = "Tare";
            }
        }
        private void DefaultSetting()
        {

        }
        public void ReInitializeDesign()
        {
            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {
                if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType) == 4)
                {
                    this.labelTitleJudgmentDelay.Text = "하강지연";
                    this.labelTitleDoubleDelay.Text = "상승지연";
                }
                else
                {
                    this.labelTitleJudgmentDelay.Text = "판정지연";
                    this.labelTitleDoubleDelay.Text = "이중지연";
                }
            }
            else
            {
                if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType) == 4)
                {
                    this.labelTitleJudgmentDelay.Text = "D.Delay";
                    this.labelTitleDoubleDelay.Text = "A.Delay";
                }
                else
                {
                    this.labelTitleJudgmentDelay.Text = "J.Delay";
                    this.labelTitleDoubleDelay.Text = "Gap";
                }
            }
        }

        private string ReturnCountingOutputAddOnName(int num)
        {
            string tempString = "";

            if (num == 1)
            {
                if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                        tempString += "장비정지 | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                        tempString += "부저울림 | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                        tempString += "외부출력 | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1Continuous == true)
                        tempString += "자동리셋";
                }
                else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                        tempString += "Ausrüstung stoppt | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                        tempString += "Summer-Einschalt | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                        tempString += "Externer Ausgang | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1Continuous == true)
                        tempString += "Automatisches Zurücksetzen";
                }
                else
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ConveyorStop == true)
                        tempString += "Equipment stop | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1BuzzerOn == true)
                        tempString += "Buzzering | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1ExternalOutput == true)
                        tempString += "External output | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput1Continuous == true)
                        tempString += "Auto reset";
                }
            }
            else
            {
                if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                        tempString += "장비정지 | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                        tempString += "부저울림 | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                        tempString += "외부출력 | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2Continuous == true)
                        tempString += "자동리셋";
                }
                else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                        tempString += "Ausrüstung stoppt | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                        tempString += "Summer-Einschalt | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                        tempString += "Externer Ausgang | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2Continuous == true)
                        tempString += "Automatisches Zurücksetzen";
                }
                else
                {
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ConveyorStop == true)
                        tempString += "Equipment stop | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2BuzzerOn == true)
                        tempString += "Buzzering | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2ExternalOutput == true)
                        tempString += "External output | ";
                    if (this.ParentForm.ParentForm.SystemConfig2.IsCountingOutput2Continuous == true)
                        tempString += "Auto reset";
                }
            }

            return tempString;
        }
        private string ReturnCountingOutputModeName(int num)
        {
            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {
                switch (num)
                {
                    case 0:
                        return "사용안함";
                    case 1:
                        return "정량";
                    case 2:
                        return "불량";
                    case 3:
                        return "과량";
                    case 4:
                        return "경량";
                    default:
                        return "사용안함";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                switch (num)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "Bestehen";
                    case 2:
                        return "Schlecht";
                    case 3:
                        return "Max.";
                    case 4:
                        return "Min.";
                    default:
                        return "Keiner";
                }
            }
            else
            {
                switch (num)
                {
                    case 0:
                        return "None";
                    case 1:
                        return "Pass";
                    case 2:
                        return "NG";
                    case 3:
                        return "Over";
                    case 4:
                        return "Under";
                    default:
                        return "None";
                }
            }
        }
        private string ReturnSorterOptionName(string num)
        {
            int numInt = int.Parse(num);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {
                switch (numInt)
                {
                    case 0:
                        return "사용안함";
                    case 1:
                        return "선별기 A";
                    case 2:
                        return "선별기 B";
                    default:
                        return "사용안함";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                switch (numInt)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "SortiererA";
                    case 2:
                        return "SortiererB";
                    default:
                        return "Keiner";
                }
            }
            else
            {
                switch (numInt)
                {
                    case 0:
                        return "None";
                    case 1:
                        return "Sorter A";
                    case 2:
                        return "Sorter B";
                    default:
                        return "None";
                }
            }
        }
        private string ReturnSorterModeName(string num)
        {
            int numInt = int.Parse(num);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {
                switch (numInt)
                {
                    case 0:
                        return "사용안함";
                    case 1:
                        return "과량";
                    case 2:
                        return "경량";
                    case 3:
                        return "NG";
                    default:
                        return "사용안함";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                switch (numInt)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "Max.";
                    case 2:
                        return "Min.";
                    case 3:
                        return "Schlecht";
                     default:
                        return "Keiner";
                }
            }
            else
            {
                switch (numInt)
                {
                    case 0:
                        return "None";
                    case 1:
                        return "Over";
                    case 2:
                        return "Under";
                    case 3:
                        return "NG";
                    default:
                        return "None";
                }
            }
        }
        private string ReturnExternalOutputModeName(string num)
        {
            int numInt = int.Parse(num);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
            {
                switch (numInt)
                {
                    case 0:
                        return "사용안함";
                    case 1:
                        return "과량";
                    case 2:
                        return "경량";
                    case 3:
                        return "불량";
                    case 4:
                        return "정량";
                    case 5:
                        return "운전";
                    case 6:
                        return "개수";
                    case 7:
                        return "카운터출력1";
                    case 8:
                        return "카운터출력2";
                    case 9:
                        return "ExNG";
                    default:
                        return "사용안함";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                switch (numInt)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "Max.";
                    case 2:
                        return "Min.";
                    case 3:
                        return "Schlecht";
                    case 4:
                        return "Bestehen";
                    case 5:
                        return "Lauf";
                    case 6:
                        return "Einstellen";
                    case 7:
                        return "Zählen der Ausgabe1";
                    case 8:
                        return "Zählen der Ausgabe2";
                    case 9:
                        return "Ex.Schlecht";
                    default:
                        return "Keiner";
                }
            }
            else
            {
                switch (numInt)
                {
                    case 0:
                        return "None";
                    case 1:
                        return "Over";
                    case 2:
                        return "Under";
                    case 3:
                        return "NG";
                    case 4:
                        return "Pass";
                    case 5:
                        return "Run";
                    case 6:
                        return "Count";
                    case 7:
                        return "Counting output1";
                    case 8:
                        return "Counting output2";
                    case 9:
                        return "ExNG";
                    default:
                        return "None";
                }
            }
        }
        private void InitialLabel()
        {
            #region Initial Label
            this.labelMaxWeight.Text = "-";
            this.labelBalanceWeight.Text = "-";
            this.labelDigit.Text = "-";
            this.labelCALc.Text = "-";

            this.labelFilter.Text = "-";
            this.labelJudgmentDelay.Text = "-";
            this.labelDoubleDelay.Text = "-";
            this.labelJudgmentNumeber.Text = "-";
            this.labelSpeed.Text = "-";
            this.labelDynamic.Text = "-";

            this.labelSorterAMode.Text = "-";
            this.labelSorterADelay.Text = "-";
            this.labelSorterAOperation.Text = "-";
            this.labelSorterBMode.Text = "-";
            this.labelSorterBDelay.Text = "-";
            this.labelSorterBOperation.Text = "-";
            this.labelDoubleEntry.Text = "-";
            this.labelExternalInput.Text = "-";
            this.labelETCNG.Text = "-";

            this.labelExternalOutput1Mode.Text = "-";
            this.labelExternalOutput1Delay.Text = "-";
            this.labelExternalOutput1Operation.Text = "-";
            this.labelExternalOutput2Mode.Text = "-";
            this.labelExternalOutput2Delay.Text = "-";
            this.labelExternalOutput2Operation.Text = "-";
            this.labelExternalOutput3Mode.Text = "-";
            this.labelExternalOutput3Delay.Text = "-";
            this.labelExternalOutput3Operation.Text = "-";
            this.labelExternalOutput4Mode.Text = "-";
            this.labelExternalOutput4Delay.Text = "-";
            this.labelExternalOutput4Operation.Text = "-";
            this.labelExternalOutput9Mode.Text = "-";
            this.labelExternalOutput9Delay.Text = "-";
            this.labelExternalOutput9Operation.Text = "-";
            this.labelExternalOutput10Mode.Text = "-";
            this.labelExternalOutput10Delay.Text = "-";
            this.labelExternalOutput10Operation.Text = "-";

            this.labelMode1.Text = "-";
            this.labelMode1Time.Text = "-";
            this.labelMode1Range.Text = "-";
            this.labelMode1Variate.Text = "-";
            this.labelMode2.Text = "-";
            this.labelMode2Time.Text = "-";
            this.labelMode2Range.Text = "-";
            this.labelMode2Variate.Text = "-";

            this.label1Mode.Text = "-";
            this.label1Number.Text = "-";
            this.label1Addon.Text = "-";
            this.label2Mode.Text = "-";
            this.label2Number.Text = "-";
            this.label2Addon.Text = "-";

            this.labelUnder.Text = "-";
            this.labelPass.Text = "-";
            this.labelOver.Text = "-";
            this.labelTare.Text = "-"; 
            #endregion

            #region ForeColor
            this.labelMaxWeight.ForeColor = Color.White;
            this.labelBalanceWeight.ForeColor = Color.White;
            this.labelDigit.ForeColor = Color.White;
            this.labelCALc.ForeColor = Color.White;

            this.labelFilter.ForeColor = Color.White;
            this.labelJudgmentDelay.ForeColor = Color.White;
            this.labelDoubleDelay.ForeColor = Color.White;
            this.labelJudgmentNumeber.ForeColor = Color.White;
            this.labelSpeed.ForeColor = Color.White;
            this.labelDynamic.ForeColor = Color.White;

            this.labelSorterAMode.ForeColor = Color.White;
            this.labelSorterADelay.ForeColor = Color.White;
            this.labelSorterAOperation.ForeColor = Color.White;
            this.labelSorterBMode.ForeColor = Color.White;
            this.labelSorterBDelay.ForeColor = Color.White;
            this.labelSorterBOperation.ForeColor = Color.White;
            this.labelDoubleEntry.ForeColor = Color.White;
            this.labelExternalInput.ForeColor = Color.White;
            this.labelETCNG.ForeColor = Color.White;

            this.labelExternalOutput1Mode.ForeColor = Color.White;
            this.labelExternalOutput1Delay.ForeColor = Color.White;
            this.labelExternalOutput1Operation.ForeColor = Color.White;
            this.labelExternalOutput2Mode.ForeColor = Color.White;
            this.labelExternalOutput2Delay.ForeColor = Color.White;
            this.labelExternalOutput2Operation.ForeColor = Color.White;
            this.labelExternalOutput3Mode.ForeColor = Color.White;
            this.labelExternalOutput3Delay.ForeColor = Color.White;
            this.labelExternalOutput3Operation.ForeColor = Color.White;
            this.labelExternalOutput4Mode.ForeColor = Color.White;
            this.labelExternalOutput4Delay.ForeColor = Color.White;
            this.labelExternalOutput4Operation.ForeColor = Color.White;
            this.labelExternalOutput9Mode.ForeColor = Color.White;
            this.labelExternalOutput9Delay.ForeColor = Color.White;
            this.labelExternalOutput9Operation.ForeColor = Color.White;
            this.labelExternalOutput10Mode.ForeColor = Color.White;
            this.labelExternalOutput10Delay.ForeColor = Color.White;
            this.labelExternalOutput10Operation.ForeColor = Color.White;

            this.labelMode1.ForeColor = Color.White;
            this.labelMode1Time.ForeColor = Color.White;
            this.labelMode1Range.ForeColor = Color.White;
            this.labelMode1Variate.ForeColor = Color.White;
            this.labelMode2.ForeColor = Color.White;
            this.labelMode2Time.ForeColor = Color.White;
            this.labelMode2Range.ForeColor = Color.White;
            this.labelMode2Variate.ForeColor = Color.White;

            this.label1Mode.ForeColor = Color.White;
            this.label1Number.ForeColor = Color.White;
            this.label1Addon.ForeColor = Color.White;
            this.label2Mode.ForeColor = Color.White;
            this.label2Number.ForeColor = Color.White;
            this.label2Addon.ForeColor = Color.White;

            this.labelUnder.ForeColor = Color.White;
            this.labelPass.ForeColor = Color.White;
            this.labelOver.ForeColor = Color.White;
            this.labelTare.ForeColor = Color.White;
            #endregion
        }
        private void CheckCompareBoardLCDValue(SystemInformation2 item)
        {
            if (this.ParentForm.ParentForm.CurrentCalibrationItem.MaxWeight != item.MaxWeight)
                this.labelMaxWeight.ForeColor = Color.Red;
            if(this.ParentForm.ParentForm.CurrentCalibrationItem.BalanceWeight != item.BalanceWeight)
                this.labelBalanceWeight.ForeColor = Color.Red;
            if(this.ParentForm.ParentForm.CurrentCalibrationItem.Digit != item.Digit)
                this.labelDigit.ForeColor = Color.Red;
            if(this.ParentForm.ParentForm.CurrentCalibrationItem.Constant != item.Calc)
                this.labelCALc.ForeColor = Color.Red;

            if(this.ParentForm.ParentForm.CurrentJudgmentSetItem.Filter != int.Parse(item.Filter))
                this.labelFilter.ForeColor = Color.Red;

            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType) == 4)
            {
                if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.DescendDelayTime != int.Parse(item.DescendDelay))
                    this.labelJudgmentDelay.ForeColor = Color.Red;
                if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.AscendDelayTime != int.Parse(item.AscendDelay))
                    this.labelDoubleDelay.ForeColor = Color.Red;
            }
            else
            {
                if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.JudgmentDelayTime != int.Parse(item.JudgmentDelay))
                    this.labelJudgmentDelay.ForeColor = Color.Red;
                if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.DoubleDelayTime != int.Parse(item.DoubleDelay))
                    this.labelDoubleDelay.ForeColor = Color.Red;
            }
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.JudgmentCount != int.Parse(item.JudgmentNumber))
                this.labelJudgmentNumeber.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.FeedSpeed1 != int.Parse(item.Speed))
                this.labelSpeed.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.DynamicCorrection != double.Parse(Helper.StringToDecimalPlaces(item.Dynamic, 6)))
                this.labelDynamic.ForeColor = Color.Red;

            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter1Mode != int.Parse(item.SorterAMode))
                this.labelSorterAMode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter1DelayTime != int.Parse(item.SorterADelay))
                this.labelSorterADelay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter1RunTime != int.Parse(item.SorterAOperation))
                this.labelSorterAOperation.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2Mode != int.Parse(item.SorterBMode))
                this.labelSorterBMode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2DelayTime != int.Parse(item.SorterBDelay))
                this.labelSorterBDelay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Sorter2RunTime != int.Parse(item.SorterBOperation))
                this.labelSorterBOperation.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.SorterDoubleEntry) != int.Parse(item.DoubleEntry))
                this.labelDoubleEntry.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.SorterExternalNgInput) != int.Parse(item.ExternalInput))
                this.labelExternalInput.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.SorterEtcNg) != int.Parse(item.ETCNG))
                this.labelETCNG.ForeColor = Color.Red;

            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1Mode != item.ExternalOutput1Mode)
                this.labelExternalOutput1Mode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1DelayTime != item.ExternalOutput1Delay)
                this.labelExternalOutput1Delay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1RunTime != item.ExternalOutput1Operation)
                this.labelExternalOutput1Operation.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2Mode != item.ExternalOutput2Mode)
                this.labelExternalOutput2Mode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2DelayTime != item.ExternalOutput2Delay)
                this.labelExternalOutput2Delay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2RunTime != item.ExternalOutput2Operation)
                this.labelExternalOutput2Operation.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3Mode != item.ExternalOutput3Mode)
                this.labelExternalOutput3Mode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3DelayTime != item.ExternalOutput3Delay)
                this.labelExternalOutput3Delay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3RunTime != item.ExternalOutput3Operation)
                this.labelExternalOutput3Operation.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode != item.ExternalOutput4Mode)
                this.labelExternalOutput4Mode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4DelayTime != item.ExternalOutput4Delay)
                this.labelExternalOutput4Delay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4RunTime != item.ExternalOutput4Operation)
                this.labelExternalOutput4Operation.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut5Mode != item.ExternalOutput9Mode)
                this.labelExternalOutput9Mode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut5DelayTime != item.ExternalOutput9Delay)
                this.labelExternalOutput9Delay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut5RunTime != item.ExternalOutput9Operation)
                this.labelExternalOutput9Operation.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut6Mode != item.ExternalOutput10Mode)
                this.labelExternalOutput10Mode.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut6DelayTime != item.ExternalOutput10Delay)
                this.labelExternalOutput10Delay.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut6RunTime != item.ExternalOutput10Operation)
                this.labelExternalOutput10Operation.ForeColor = Color.Red;

            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero1Mode) != int.Parse(item.AutoZero1Mode))
                this.labelMode1.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero1Mode) == 4)
            {
                if (this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero1Time != item.AutoZero1Time)
                    this.labelMode1Time.ForeColor = Color.Red;
                if (this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero1Range != item.AutoZero1Range)
                    this.labelMode1Range.ForeColor = Color.Red;
                if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero1Variate) != int.Parse(item.AutoZero1Variate))
                    this.labelMode1Variate.ForeColor = Color.Red;
            }
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero2Mode) != int.Parse(item.AutoZero2Mode))
                this.labelMode2.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero2Mode) == 4)
            {
                if (this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero2Time != item.AutoZero2Time)
                    this.labelMode2Time.ForeColor = Color.Red;
                if (this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero2Range != item.AutoZero2Range)
                    this.labelMode2Range.ForeColor = Color.Red;
                if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZero2Variate) != int.Parse(item.AutoZero2Variate))
                    this.labelMode2Variate.ForeColor = Color.Red;
            }

            if (int.Parse(this.ParentForm.ParentForm.CurrentProductItem.UnderRange) != int.Parse(item.UnderRange))
                this.labelUnder.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentProductItem.PassRange) != int.Parse(item.PassRange))
                this.labelPass.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentProductItem.OverRange) != int.Parse(item.OverRange))
                this.labelOver.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentProductItem.TareRange) != int.Parse(item.TareRange))
                this.labelTare.ForeColor = Color.Red;
        }
        public void UpdateParameter1Display(SystemInformation2 item)
        {
            int temp = 0;

            #region Calibration
            this.labelMaxWeight.Text = Helper.CommunicationWeightValueToString(item.MaxWeight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.labelBalanceWeight.Text = Helper.CommunicationWeightValueToString(item.BalanceWeight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.Digit);
            if(temp == 1)
                this.labelDigit.Text = "1";
            else if(temp == 2)
                this.labelDigit.Text = "2";
            else if (temp == 5)
                this.labelDigit.Text = "5";
            else
                this.labelDigit.Text = "-";
            this.labelCALc.Text = Helper.StringToDecimalPlaces(item.Calc, 6);
            #endregion

            #region Judgment
            this.labelFilter.Text = item.Filter;
            this.labelJudgmentNumeber.Text = item.JudgmentNumber;
            this.labelSpeed.Text = item.Speed;
            this.labelDynamic.Text = Helper.StringToDecimalPlaces(item.Dynamic, 6);
            #endregion

            #region Sorter
            this.labelSorterAMode.Text = this.ReturnSorterModeName(item.SorterAMode);
            this.labelSorterADelay.Text = item.SorterADelay;
            this.labelSorterAOperation.Text = item.SorterAOperation;
            this.labelSorterBMode.Text = this.ReturnSorterModeName(item.SorterBMode);
            this.labelSorterBDelay.Text = item.SorterBDelay;
            this.labelSorterBOperation.Text = item.SorterBOperation;
            this.labelDoubleEntry.Text = this.ReturnSorterOptionName(item.DoubleEntry);
            this.labelExternalInput.Text = this.ReturnSorterOptionName(item.ExternalInput);
            this.labelETCNG.Text = this.ReturnSorterOptionName(item.ETCNG);
            #endregion

            #region Auto zero
            temp = int.Parse(item.AutoZero1Mode);
            switch (temp)
            {
                case 1:
                    this.labelMode1.Text = "Low";
                    break;
                case 2:
                    this.labelMode1.Text = "Middle";
                    break;
                case 3:
                    this.labelMode1.Text = "High";
                    break;
                case 4:
                    this.labelMode1.Text = "User";
                    break;
                default:
                    this.labelMode1.Text = "User";
                    break;
            }
            this.labelMode1Time.Text = item.AutoZero1Time;
            this.labelMode1Range.Text = item.AutoZero1Range;
            temp = int.Parse(item.AutoZero1Variate);
            switch (temp)
            {
                case 0:
                    this.labelMode1Variate.Text = "0.1";
                    break;
                case 1:
                    this.labelMode1Variate.Text = "0.2";
                    break;
                case 2:
                    this.labelMode1Variate.Text = "0.5";
                    break;
                case 3:
                    this.labelMode1Variate.Text = "1";
                    break;
                default:
                    this.labelMode1Variate.Text = "-";
                    break;
            }
            temp = int.Parse(item.AutoZero2Mode);
            switch (temp)
            {
                case 0:
                    this.labelMode2.Text = "None";
                    break;
                case 1:
                    this.labelMode2.Text = "Low";
                    break;
                case 2:
                    this.labelMode2.Text = "Middle";
                    break;
                case 3:
                    this.labelMode2.Text = "High";
                    break;
                case 4:
                    this.labelMode2.Text = "User";
                    break;
                default:
                    this.labelMode2.Text = "User";
                    break;
            }
            this.labelMode2Time.Text = item.AutoZero2Time;
            this.labelMode2Range.Text = item.AutoZero2Range;
            temp = int.Parse(item.AutoZero2Variate);
            switch (temp)
            {
                case 0:
                    this.labelMode2Variate.Text = "0.1";
                    break;
                case 1:
                    this.labelMode2Variate.Text = "0.2";
                    break;
                case 2:
                    this.labelMode2Variate.Text = "0.5";
                    break;
                case 3:
                    this.labelMode2Variate.Text = "1";
                    break;
                default:
                    this.labelMode2Variate.Text = "-";
                    break;
            }
            #endregion

            #region Setting value
            this.labelUnder.Text = Helper.StringToDecimalPlaces(item.UnderRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.labelPass.Text = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.labelOver.Text = Helper.StringToDecimalPlaces(item.OverRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.labelTare.Text = Helper.StringToDecimalPlaces(item.TareRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            #endregion
        }
        public void UpdateParameter2Display(SystemInformation2 item)
        {
            #region External output
            this.labelExternalOutput1Mode.Text = this.ReturnExternalOutputModeName(item.ExternalOutput1Mode);
            this.labelExternalOutput1Delay.Text = item.ExternalOutput1Delay;
            this.labelExternalOutput1Operation.Text = item.ExternalOutput1Operation;

            this.labelExternalOutput2Mode.Text = this.ReturnExternalOutputModeName(item.ExternalOutput2Mode);
            this.labelExternalOutput2Delay.Text = item.ExternalOutput2Delay;
            this.labelExternalOutput2Operation.Text = item.ExternalOutput2Operation;

            this.labelExternalOutput3Mode.Text = this.ReturnExternalOutputModeName(item.ExternalOutput3Mode);
            this.labelExternalOutput3Delay.Text = item.ExternalOutput3Delay;
            this.labelExternalOutput3Operation.Text = item.ExternalOutput3Operation;

            this.labelExternalOutput4Mode.Text = this.ReturnExternalOutputModeName(item.ExternalOutput4Mode);
            this.labelExternalOutput4Delay.Text = item.ExternalOutput4Delay;
            this.labelExternalOutput4Operation.Text = item.ExternalOutput4Operation;

            this.labelExternalOutput9Mode.Text = this.ReturnExternalOutputModeName(item.ExternalOutput9Mode);
            this.labelExternalOutput9Delay.Text = item.ExternalOutput9Delay;
            this.labelExternalOutput9Operation.Text = item.ExternalOutput9Operation;

            this.labelExternalOutput10Mode.Text = this.ReturnExternalOutputModeName(item.ExternalOutput10Mode);
            this.labelExternalOutput10Delay.Text = item.ExternalOutput10Delay;
            this.labelExternalOutput10Operation.Text = item.ExternalOutput10Operation;
            #endregion

            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.EquipmentType) == 4)
            {
                this.labelJudgmentDelay.Text = item.DescendDelay;
                this.labelDoubleDelay.Text = item.AscendDelay;
            }
            else
            {
                this.labelJudgmentDelay.Text = item.JudgmentDelay;
                this.labelDoubleDelay.Text = item.DoubleDelay;
            }

            this.CheckCompareBoardLCDValue(item);
        }

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

            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead3901, "");
            this.InitialLabel();
        }
        #endregion

        #region Event Handler
        private void buttonPrevious_Click(object sender, EventArgs e)
        {
            this.ParentForm.CenterInforSystem.DisplayRefresh(this.ParentForm.ParentForm.CurrentSystemStatus);
            this.ParentForm.CenterInforSystem.BringToFront();
        }

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

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

        private void buttonLoad_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.SystemInformationRead1, "");

            if (this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces == 1)
                this.labelDecimalPoint.Text = "0.0";
            else if (this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces == 2)
                this.labelDecimalPoint.Text = "0.00";
            else
                this.labelDecimalPoint.Text = "0";

            #region Counting output
            this.label1Mode.Text = this.ReturnCountingOutputModeName(this.ParentForm.ParentForm.SystemConfig2.CountingOutput1Mode);
            this.label1Number.Text = this.ParentForm.ParentForm.SystemConfig2.CountingOutput1Number.ToString();
            this.label1Addon.Text = this.ReturnCountingOutputAddOnName(1);

            this.label2Mode.Text = this.ReturnCountingOutputModeName(this.ParentForm.ParentForm.SystemConfig2.CountingOutput2Mode);
            this.label2Number.Text = this.ParentForm.ParentForm.SystemConfig2.CountingOutput2Number.ToString();
            this.label2Addon.Text = this.ReturnCountingOutputAddOnName(2);
            #endregion
        }

        private void buttonNext_Click(object sender, EventArgs e)
        {
            this.ParentForm.CenterInforSystem3.DisplayRefresh(this.ParentForm.ParentForm.CurrentSystemStatus);
            this.ParentForm.CenterInforSystem3.BringToFront();
        }
        #endregion

    }
}