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_2H.DialogForms;
using ITC81DB_2H.Forms;
using ITC81DB_2H.Datastore;

namespace ITC81DB_2H
{
    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 == Define.E_LanguageID.Korean)
            {

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

                this.labelTitleBalanceWeight.Text = "분동중량";
                this.labelTitleDecimalPoint.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.labelTitleExternalOutput5.Text = "외부출력9";
                this.labelTitleExternalOutput6.Text = "외부출력10";
                this.labelTitleModeExOutput.Text = "모드";
                this.labelTitleDelayExOutput.Text = "지연";
                this.labelTitleOperationExOutput.Text = "동작";

                this.labelTitleIsAutoZeroUsing.Text = "모드1";
                this.labelTitlePlusRange.Text = "+ 시간";
                this.labelTitleMinusRange.Text = "- 범위";
                this.labelTitleVariate.Text = "변량";

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

                this.labelTitleBalanceWeight.Text = "Balance W.";
                this.labelTitleDecimalPoint.Text = "Dec point";

                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.labelTitleExternalOutput5.Text = "Ex.Output9";
                this.labelTitleExternalOutput6.Text = "Ex.Output10";
                this.labelTitleModeExOutput.Text = "Mode";
                this.labelTitleDelayExOutput.Text = "Delay";
                this.labelTitleOperationExOutput.Text = "Run";

                this.labelTitleIsAutoZeroUsing.Text = "Mode1";
                this.labelTitlePlusRange.Text = "Time";
                this.labelTitleMinusRange.Text = "Range";
                this.labelTitleVariate.Text = "Variate";

                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 == Define.E_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 ReturnExternalOutputName(string num)
        {
            int numInt = int.Parse(num);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_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 "시건장치 제어";
                    default:
                        return "사용안함";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_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 "Verriegelungssteuerung";
                    default:
                        return "Keiner";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {
                switch (numInt)
                {
                    default:
                        return "";
                }
            }
            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 "Latch control";
                    default:
                        return "None";
                }
            }
        }
        private string ReturnSorterOptionName(string num)
        {
            int numInt = int.Parse(num);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Korean)
            {
                switch (numInt)
                {
                    case 0:
                        return "사용안함";
                    case 1:
                        return "선별기 A";
                    case 2:
                        return "선별기 B";
                    default:
                        return "사용안함";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.German)
            {
                switch (numInt)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "SortiererA";
                    case 2:
                        return "SortiererB";
                    default:
                        return "Keiner";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {
                switch (numInt)
                {
                    default:
                        return "";
                }
            }
            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 == Define.E_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 == Define.E_LanguageID.German)
            {
                switch (numInt)
                {
                    case 0:
                        return "Keiner";
                    case 1:
                        return "Max.";
                    case 2:
                        return "Min.";
                    case 3:
                        return "Schlecht";
                     default:
                        return "Keiner";
                }
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {
                switch (numInt)
                {
                    default:
                        return "";
                }
            }
            else
            {
                switch (numInt)
                {
                    case 0:
                        return "None";
                    case 1:
                        return "Over";
                    case 2:
                        return "Under";
                    case 3:
                        return "NG";
                    default:
                        return "None";
                }
            }
        }
        private void InitialLabel()
        {
            #region Initial Label
            this.labelBalanceWeight.Text = "-";

            this.labelPIN6.Text = "-";
            this.labelPIN5.Text = "-";
            this.labelPIN4.Text = "-";
            this.labelPIN3.Text = "-";
            this.labelPhotoB.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.labelExternalOutput5Mode.Text = "-";
            this.labelExternalOutput5Delay.Text = "-";
            this.labelExternalOutput5Operation.Text = "-";
            this.labelExternalOutput6Mode.Text = "-";
            this.labelExternalOutput6Delay.Text = "-";
            this.labelExternalOutput6Operation.Text = "-";

            this.labelIsAutoZeroUsing.Text = "-";
            this.labelPlusRange.Text = "-";
            this.labelMinusRange.Text = "-";
            this.labelVariate.Text = "-";

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

            #region ForeColor
            this.labelBalanceWeight.ForeColor = Color.White;

            this.labelPIN6.ForeColor = Color.White;
            this.labelPIN5.ForeColor = Color.White;
            this.labelPIN4.ForeColor = Color.White;
            this.labelPIN3.ForeColor = Color.White;
            this.labelPhotoB.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.labelExternalOutput5Mode.ForeColor = Color.White;
            this.labelExternalOutput5Delay.ForeColor = Color.White;
            this.labelExternalOutput5Operation.ForeColor = Color.White;
            this.labelExternalOutput6Mode.ForeColor = Color.White;
            this.labelExternalOutput6Delay.ForeColor = Color.White;
            this.labelExternalOutput6Operation.ForeColor = Color.White;

            this.labelIsAutoZeroUsing.ForeColor = Color.White;
            this.labelPlusRange.ForeColor = Color.White;
            this.labelMinusRange.ForeColor = Color.White;
            this.labelVariate.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 CheckCompareBoardLCD9518Value(SystemInformation2 item)
        {
            if (this.ParentForm.ParentForm.CurrentCalibrationItem.BalanceWeight != item.BalanceWeight)
                this.labelBalanceWeight.ForeColor = Color.Red;

            if (this.ParentForm.ParentForm.CurrentJudgmentSetItem.Filter != int.Parse(item.Filter))
                this.labelFilter.ForeColor = Color.Red;
            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 (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;

            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.CurrentSystemParameter1.PI6 != int.Parse(item.PI6))
                this.labelPIN6.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI5 != int.Parse(item.PI5))
                this.labelPIN5.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI4 != int.Parse(item.PI4))
                this.labelPIN4.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI3 != int.Parse(item.PI3))
                this.labelPIN3.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI2 != int.Parse(item.PhotoB))
                this.labelPhotoB.ForeColor = Color.Red;
        }
        private void CheckCompareBoardLCD9519Value(SystemInformation2 item)
        {
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1Mode) != int.Parse(item.ExternalOutput1Mode))
                this.labelExternalOutput1Mode.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1DelayTime) != int.Parse(item.ExternalOutput1Delay))
                this.labelExternalOutput1Delay.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut1RunTime) != int.Parse(item.ExternalOutput1Operation))
                this.labelExternalOutput1Operation.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2Mode) != int.Parse(item.ExternalOutput2Mode))
                this.labelExternalOutput2Mode.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2DelayTime) != int.Parse(item.ExternalOutput2Delay))
                this.labelExternalOutput2Delay.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut2RunTime) != int.Parse(item.ExternalOutput2Operation))
                this.labelExternalOutput2Operation.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3Mode) != int.Parse(item.ExternalOutput3Mode))
                this.labelExternalOutput3Mode.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3DelayTime) != int.Parse(item.ExternalOutput3Delay))
                this.labelExternalOutput3Delay.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut3RunTime) != int.Parse(item.ExternalOutput3Operation))
                this.labelExternalOutput3Operation.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4Mode) != int.Parse(item.ExternalOutput4Mode))
                this.labelExternalOutput4Mode.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4DelayTime) != int.Parse(item.ExternalOutput4Delay))
                this.labelExternalOutput4Delay.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut4RunTime) != int.Parse(item.ExternalOutput4Operation))
                this.labelExternalOutput4Operation.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut5Mode) != int.Parse(item.ExternalOutput5Mode))
                this.labelExternalOutput5Mode.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut5DelayTime) != int.Parse(item.ExternalOutput5Delay))
                this.labelExternalOutput5Delay.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut5RunTime) != int.Parse(item.ExternalOutput5Operation))
                this.labelExternalOutput5Operation.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut6Mode) != int.Parse(item.ExternalOutput6Mode))
                this.labelExternalOutput6Mode.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut6DelayTime) != int.Parse(item.ExternalOutput6Delay))
                this.labelExternalOutput6Delay.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter3.ExternalOut6RunTime) != int.Parse(item.ExternalOutput6Operation))
                this.labelExternalOutput6Operation.ForeColor = Color.Red;

            if (Convert.ToInt16(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroIsAutoZeroUsing) != int.Parse(item.IsAutoZeroUsing))
                this.labelIsAutoZeroUsing.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroPlusRange) != int.Parse(item.AutoZeroPlusRange))
                this.labelPlusRange.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroMinusRange) != int.Parse(item.AutoZeroMinusRange))
                this.labelMinusRange.ForeColor = Color.Red;
            if (int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroVariate) != int.Parse(item.AutoZeroVariate))
                this.labelVariate.ForeColor = Color.Red;
        }
        private void CheckCompareBoardLCD9520Value(SystemInformation2 item)
        {
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI6 != int.Parse(item.PI6))
                this.labelPIN6.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI5 != int.Parse(item.PI5))
                this.labelPIN5.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI4 != int.Parse(item.PI4))
                this.labelPIN4.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI3 != int.Parse(item.PI3))
                this.labelPIN3.ForeColor = Color.Red;
            if (this.ParentForm.ParentForm.CurrentSystemParameter1.PI2 != int.Parse(item.PhotoB))
                this.labelPhotoB.ForeColor = Color.Red;
        }
        private string ExternalInput(int num)
        {
            string ret = "";

            switch (num)
            {
                case 0:
                    ret = "None";
                    break;
                case 1:
                    ret = "NG";
                    break;
                case 2:
                    ret = "START";
                    break;
                case 3:
                    ret = "STOP";
                    break;
                case 4:
                    ret = "Air";
                    break;
                default:
                    ret = "";
                    break;
            }

            return ret;
        }
        public void UpdateParameter9518Display(SystemInformation2 item)
        {
            int temp = 0;
            
            #region Calibration
            this.labelBalanceWeight.Text = Helper.StringToDecimalPlaces(item.BalanceWeight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            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";
            #endregion

            #region Judgment
            this.labelFilter.Text = Helper.RemoveZeroNumberString(item.Filter);
            this.labelJudgmentDelay.Text = Helper.RemoveZeroNumberString(item.JudgmentDelay);
            this.labelDoubleDelay.Text = Helper.RemoveZeroNumberString(item.DoubleDelay);
            this.labelJudgmentNumeber.Text = Helper.RemoveZeroNumberString(item.JudgmentNumber);
            this.labelSpeed.Text = Helper.RemoveZeroNumberString(item.Speed);
            this.labelDynamic.Text = Helper.StringToDecimalPlaces(item.Dynamic, 6);
            #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

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

            this.CheckCompareBoardLCD9518Value(item);
        }
        public void UpdateParameter9519Display(SystemInformation2 item)
        {
            int temp = 0;

            #region 외부출력
            this.labelExternalOutput1Mode.Text = this.ReturnExternalOutputName(item.ExternalOutput1Mode);
            this.labelExternalOutput1Delay.Text = Helper.RemoveZeroNumberString(item.ExternalOutput1Delay);
            this.labelExternalOutput1Operation.Text = Helper.RemoveZeroNumberString(item.ExternalOutput1Operation);
            this.labelExternalOutput2Mode.Text = this.ReturnExternalOutputName(item.ExternalOutput2Mode);
            this.labelExternalOutput2Delay.Text = Helper.RemoveZeroNumberString(item.ExternalOutput2Delay);
            this.labelExternalOutput2Operation.Text = Helper.RemoveZeroNumberString(item.ExternalOutput2Operation);
            this.labelExternalOutput3Mode.Text = this.ReturnExternalOutputName(item.ExternalOutput3Mode);
            this.labelExternalOutput3Delay.Text = Helper.RemoveZeroNumberString(item.ExternalOutput3Delay);
            this.labelExternalOutput3Operation.Text = Helper.RemoveZeroNumberString(item.ExternalOutput3Operation);
            this.labelExternalOutput4Mode.Text = this.ReturnExternalOutputName(item.ExternalOutput4Mode);
            this.labelExternalOutput4Delay.Text = Helper.RemoveZeroNumberString(item.ExternalOutput4Delay);
            this.labelExternalOutput4Operation.Text = Helper.RemoveZeroNumberString(item.ExternalOutput4Operation);
            this.labelExternalOutput5Mode.Text = this.ReturnExternalOutputName(item.ExternalOutput5Mode);
            this.labelExternalOutput5Delay.Text = Helper.RemoveZeroNumberString(item.ExternalOutput5Delay);
            this.labelExternalOutput5Operation.Text = Helper.RemoveZeroNumberString(item.ExternalOutput5Operation);
            this.labelExternalOutput6Mode.Text = this.ReturnExternalOutputName(item.ExternalOutput6Mode);
            this.labelExternalOutput6Delay.Text = Helper.RemoveZeroNumberString(item.ExternalOutput6Delay);
            this.labelExternalOutput6Operation.Text = Helper.RemoveZeroNumberString(item.ExternalOutput6Operation);
            #endregion

            #region Auto zero
            temp = int.Parse(item.IsAutoZeroUsing);
            switch (temp)
            {
                case 0:
                    this.labelIsAutoZeroUsing.Text = "OFF";
                    break;
                case 1:
                    this.labelIsAutoZeroUsing.Text = "ON";
                    break;
                default:
                    this.labelIsAutoZeroUsing.Text = "OFF";
                    break;
            }
            this.labelPlusRange.Text = Helper.StringToDecimalPlaces(int.Parse(item.AutoZeroPlusRange).ToString(), 
                this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            this.labelMinusRange.Text = Helper.StringToDecimalPlaces(int.Parse(item.AutoZeroMinusRange).ToString(), 
                this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces);
            temp = int.Parse(item.AutoZeroVariate);
            switch (temp)
            {
                case 0:
                    this.labelVariate.Text = "0.1";
                    break;
                case 1:
                    this.labelVariate.Text = "0.2";
                    break;
                case 2:
                    this.labelVariate.Text = "0.5";
                    break;
                case 3:
                    this.labelVariate.Text = "1";
                    break;
                default:
                    this.labelVariate.Text = "-";
                    break;
            }
            #endregion

            this.CheckCompareBoardLCD9519Value(item);
        }
        public void UpdateParameter9520Display(SystemInformation2 item)
        {
            #region 외부입력
            this.labelPIN6.Text = this.ExternalInput(int.Parse(item.PI6));
            this.labelPIN5.Text = this.ExternalInput(int.Parse(item.PI5));
            this.labelPIN4.Text = this.ExternalInput(int.Parse(item.PI4));
            this.labelPIN3.Text = this.ExternalInput(int.Parse(item.PI3));
            this.labelPhotoB.Text = this.ExternalInput(int.Parse(item.PhotoB));
            #endregion

            this.CheckCompareBoardLCD9520Value(item);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.InforSystem2;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_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, "");
        }

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

    }
}
