using System;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;

using SmartX;
using INT99DC_ImageDll;
using INT99DC_7C.Controls;
using INT99DC_7C.DialogForms;
using INT99DC_7C.Part11_UserManager;
using INT99DC_7C.Int_Modbus;

namespace INT99DC_7C.Forms
{
    public partial class FormMainDisplay : Form
    {
        #region Field
        private int FlagTimeoutCount;
        private int SubmenuIndex;
        public string ChangeID;
        public bool FlagModbusDec;

        private FormMain m_ParentForm;

        private Color ColorButtonAccessTrue;
        private Color ColorButtonAccessFalse;

        private DataStore.FormMainDisplayStore MainDisplay;
        private DataStore.E_ModbusDisplay ModbusDisplay;

        private ControlMainDisplayAlarm MainDisplayAlarmList;

        private ControlMainDisplayEachBarGraph7 MainDisplayEachBarGraph7;
        private ControlMainDisplayEachBarGraph8 MainDisplayEachBarGraph8;
        private ControlMainDisplayEachBarGraph10 MainDisplayEachBarGraph10;
        private ControlMainDisplayEachBarGraph12 MainDisplayEachBarGraph12;
        private ControlMainDisplayEachBarGraph15 MainDisplayEachBarGraph15;
        private ControlMainDisplayDotGraph7 MainDisplayDotGraph7;
        private ControlMainDisplayDotGraph8 MainDisplayDotGraph8;
        private ControlMainDisplayDotGraph10 MainDisplayDotGraph10;
        private ControlMainDisplayDotGraph12 MainDisplayDotGraph12;
        private ControlMainDisplayDotGraph15 MainDisplayDotGraph15;
        private ControlMainDisplayTable7 MainDisplayTable7;
        private ControlMainDisplayTable8 MainDisplayTable8;
        private ControlMainDisplayTable10 MainDisplayTable10;
        private ControlMainDisplayTable12 MainDisplayTable12;
        //private ControlMainDisplayTable15_1 MainDisplayTable15_1;
        private ControlMainDisplayTable15 MainDisplayTable15;

        private ControlModbusDisplayCommonData MainDisplayModbusCom;
        private ControlModbusDisplay1to6 MainDisplayModbus1;
        private ControlModbusDisplay7to12 MainDisplayModbus7;
        private ControlModbusDisplay13to15 MainDisplayModbus13;
        #endregion

        #region Constructor
        public FormMainDisplay(FormMain parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
            this.InitializeControl();
            this.DefaultSetting();
        }
        #endregion

        #region Property
        public FormMain ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }
        #endregion

        #region Method
        /// <summary>
        /// 언어별 화면 디자인
        /// </summary>
        private void InitializeDesign()
        {
            ImageDll images = new ImageDll();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
            {
                #region Korean
                if (this.ParentForm.SystemConfig.IsLogin == true)
                {
                    this.buttonMenu.Location = new Point(929, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.korFormMainMenuSmallDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.korFormMainMenuSmallDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.korFormMainMenuSmallUp));
                }
                else
                {
                    this.buttonMenu.Location = new Point(839, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.korFormMainMenuDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.korFormMainMenuDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.korFormMainMenuUp));
                } 
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                #region English
                this.buttonOver.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainOverDisable));
                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainOverUp));
                this.buttonPass.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainPassDisable));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainPassUp));
                this.buttonUnder.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainUnderDisable));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainUnderUp));
                this.buttonTare.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainTareDisable));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainTareUp));

                this.buttonZero.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainZeroDown));
                this.buttonZero.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainZeroUp));
                this.buttonClear.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainClearDisable));
                this.buttonClear.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainClearDown));
                this.buttonClear.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainClearUp));
               
                this.buttonSubMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainSubMenuDisable));
                this.buttonSubMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainSubMenuDown));
                this.buttonSubMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainSubMenuUp));
                this.buttonBypassDirection.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuNGUp));
                this.buttonBypassDirection.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuPassUp));
                this.buttonBypassOnce.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuContinueUp));
                this.buttonBypassOnce.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuOnceUp));
                
                if (this.ParentForm.SystemConfig.IsLogin == true)
                {
                    this.buttonMenu.Location = new Point(929, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainMenuSmallDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainMenuSmallDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainMenuSmallUp));
                }
                else
                {
                    this.buttonMenu.Location = new Point(839, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainMenuDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainMenuDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engFormMainMenuUp));
                }

                this.groupBoxSorter.Text = "Sorter settings";
                this.labelStaticSorter1DelayTime.Text = "Sorter1 Delay";
                this.labelStaticSorter1RunTime.Text = "Sorter1 Run";
                this.labelStaticSorter2DelayTime.Text = "Sorter2 Delay";
                this.labelStaticSorter2RunTime.Text = "Sorter2 Run";

                this.groupBoxConveyor.Text = "Conveyor settings";
                this.labelStaticRejectConveyor.Text = "Reject conveyor";
                this.labelStaticRejectConveyorDelayTime.Text = "Delay";
                this.labelStaticRejectConveyorRunTime.Text = "Run";
                this.labelStaticFeedingConveyor.Text = "Feeding conveyor";
                this.labelStaticFeedingDelayTime.Text = "Delay";
                this.labelStaticFeedingRunTime.Text = "Run";

                this.labelMessage1.Text = "Alarm - Double Entry";
                this.labelStaticAlarmContinuousNG.Text = "Continuous NG";
                this.labelMessage3.Text = "Continuous NG Occurs!";

                this.labelStaticATPC.Text = "Pass alarm";
                this.labelStaticATPC_Count.Text = "Count";
                this.labelStaticATPC_Pass.Text = "Pass";
                this.labelStaticATPC_Lack.Text = "Lack";
                this.buttonATPC_Reset.Text = "Reset";
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                #region Chinese
                this.buttonOver.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainOverDisable));
                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainOverUp));
                this.buttonPass.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainPassDisable));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainPassUp));
                this.buttonUnder.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainUnderDisable));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainUnderUp));
                this.buttonTare.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainTareDisable));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainTareUp));

                this.buttonZero.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainZeroDown));
                this.buttonZero.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainZeroUp));
                this.buttonClear.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainClearDisable));
                this.buttonClear.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainClearDown));
                this.buttonClear.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainClearUp));
              
                this.buttonSubMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainSubMenuDisable));
                this.buttonSubMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainSubMenuDown));
                this.buttonSubMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainSubMenuUp));
                this.buttonBypassDirection.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSubMenuNGUp));
                this.buttonBypassDirection.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSubMenuPassUp));
                this.buttonBypassOnce.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSubMenuContinueUp));
                this.buttonBypassOnce.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSubMenuOnceUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainLoginDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainLogOutDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainLoginUp));

                this.buttonAlarmContinuousNG.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnEnable));
                this.buttonAlarmContinuousNG.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnDisable));
                this.buttonATPC_Enable.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnEnable));
                this.buttonATPC_Enable.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnDisable));

                if (this.ParentForm.SystemConfig.IsLogin == true)
                {
                    this.buttonMenu.Location = new Point(929, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainMenuSmallDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainMenuSmallDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainMenuSmallUp));
                }
                else
                {
                    this.buttonMenu.Location = new Point(839, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainMenuDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainMenuDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnFormMainMenuUp));
                }

                this.groupBoxSorter.Text = "筛选设定";
                this.labelStaticSorter1DelayTime.Text = "分类机1 延迟时间";
                this.labelStaticSorter1RunTime.Text = "分类机1 运行时间";
                this.labelStaticSorter2DelayTime.Text = "分类机2 延迟时间";
                this.labelStaticSorter2RunTime.Text = "分类机2 运行时间";

                this.groupBoxConveyor.Text = "输送带设置";
                this.labelStaticRejectConveyor.Text = "筛选输送带";
                this.labelStaticRejectConveyorDelayTime.Text = "延迟时间";
                this.labelStaticRejectConveyorRunTime.Text = "运行时间";
                this.labelStaticFeedingConveyor.Text = "进料输送带";
                this.labelStaticFeedingDelayTime.Text = "延迟时间";
                this.labelStaticFeedingRunTime.Text = "运行时间";

                this.labelMessage1.Text = "报警 - 双倍";
                this.buttonClose.Text = "关闭";

                this.labelTitleTotalCount.Text = "计数";
                this.labelTitleNG.Text = "不良";
                this.labelTitleBypass.Text = "旁路";
                this.labelTitleScreen.Text = "屏幕";

                this.labelStaticAlarmContinuousNG.Text = "连续不好";
                this.labelMessage3.Text = "连续出现 NG!";

                this.labelStaticATPC.Text = "通过报警";
                this.labelStaticATPC_Count.Text = "当前";
                this.labelStaticATPC_Pass.Text = "排放";
                this.labelStaticATPC_Lack.Text = "缺少";
                this.buttonATPC_Reset.Text = "重置";
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
                #region Czech
                this.buttonOver.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainOverDisable));
                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainOverUp));
                this.buttonPass.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainPassDisable));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainPassUp));
                this.buttonUnder.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainUnderDisable));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainUnderUp));
                this.buttonTare.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainTareDisable));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainTareUp));

                this.buttonZero.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainZeroDown));
                this.buttonZero.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainZeroUp));
                this.buttonClear.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainClearDisable));
                this.buttonClear.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainClearDown));
                this.buttonClear.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainClearUp));
               
                this.buttonSubMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainSubMenuDisable));
                this.buttonSubMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainSubMenuDown));
                this.buttonSubMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainSubMenuUp));
                this.buttonBypassDirection.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuNGUp));
                this.buttonBypassDirection.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuPassUp));
                this.buttonBypassOnce.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuContinueUp));
                this.buttonBypassOnce.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSubMenuOnceUp));

                if (this.ParentForm.SystemConfig.IsLogin == true)
                {
                    this.buttonMenu.Location = new Point(929, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainMenuSmallDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainMenuSmallDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainMenuSmallUp));
                }
                else
                {
                    this.buttonMenu.Location = new Point(839, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainMenuDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainMenuDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeFormMainMenuUp));
                }

                this.groupBoxSorter.Text = "Nastavení třídiče";
                this.labelStaticSorter1DelayTime.Text = "Vyřazovač1 Zpoždění";
                this.labelStaticSorter1RunTime.Text = "Vyřazovač1 Čas chodu";
                this.labelStaticSorter2DelayTime.Text = "Vyřazovač2 Zpoždění";
                this.labelStaticSorter2RunTime.Text = "Vyřazovač2 Čas chodu";

                this.groupBoxConveyor.Text = "Nastavení dopravníku";
                this.labelStaticRejectConveyor.Text = "Vyřazení dopravníku";
                this.labelStaticRejectConveyorDelayTime.Text = "Doba zpoždění";
                this.labelStaticRejectConveyorRunTime.Text = "Doba chodu";
                this.labelStaticFeedingConveyor.Text = "Podávací dopravník";
                this.labelStaticFeedingDelayTime.Text = "Doba zpoždění";
                this.labelStaticFeedingRunTime.Text = "Doba chodu";

                this.labelMessage1.Text = "poplach - Zdvojení";

                this.labelStaticAlarmContinuousNG.Text = "Trvalá chyba";
                this.labelMessage3.Text = "Vyskytuje se kontinuální NG!";

                this.labelStaticATPC.Text = "Přeposlání alarmu";
                this.labelStaticATPC_Count.Text = "Počítat";
                this.labelStaticATPC_Pass.Text = "Váha";
                this.labelStaticATPC_Lack.Text = "nedostatek";
                this.buttonATPC_Reset.Text = "RST";
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                #region German
                this.buttonOver.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainOverDisable));
                this.buttonOver.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainOverDown));
                this.buttonOver.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainOverUp));
                this.buttonPass.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainPassDisable));
                this.buttonPass.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainPassDown));
                this.buttonPass.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainPassUp));
                this.buttonUnder.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainUnderDisable));
                this.buttonUnder.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainUnderDown));
                this.buttonUnder.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainUnderUp));
                this.buttonTare.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainTareDisable));
                this.buttonTare.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainTareDown));
                this.buttonTare.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainTareUp));

                this.buttonZero.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainZeroDown));
                this.buttonZero.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainZeroUp));
                this.buttonClear.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainClearDisable));
                this.buttonClear.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainClearDown));
                this.buttonClear.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainClearUp));
               
                this.buttonSubMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainSubMenuDisable));
                this.buttonSubMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainSubMenuDown));
                this.buttonSubMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainSubMenuUp));
                this.buttonBypassDirection.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSubMenuNGUp));
                this.buttonBypassDirection.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSubMenuPassUp));
                this.buttonBypassOnce.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSubMenuContinueUp));
                this.buttonBypassOnce.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSubMenuOnceUp));

                if (this.ParentForm.SystemConfig.IsLogin == true)
                {
                    this.buttonMenu.Location = new Point(929, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainMenuSmallDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainMenuSmallDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainMenuSmallUp));
                }
                else
                {
                    this.buttonMenu.Location = new Point(839, 666);

                    this.buttonMenu.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainMenuDisable));
                    this.buttonMenu.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainMenuDown));
                    this.buttonMenu.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerFormMainMenuUp));
                }

                this.groupBoxSorter.Text = "Sortierereinstellung";
                this.labelStaticSorter1DelayTime.Text = "Sortierer1 Vezögerung";
                this.labelStaticSorter1RunTime.Text = "Sortierer1 Laufzeit";
                this.labelStaticSorter2DelayTime.Text = "Sortierer2 Vezögerung";
                this.labelStaticSorter2RunTime.Text = "Sortierer2 Laufzeit";

                this.groupBoxConveyor.Text = "Förderereinstellung";
                this.labelStaticRejectConveyor.Text = "Aussortierförderer";
                this.labelStaticRejectConveyorDelayTime.Text = "Vezögerung";
                this.labelStaticRejectConveyorRunTime.Text = "Laufzeit";
                this.labelStaticFeedingConveyor.Text = "Zuführfördererr";
                this.labelStaticFeedingDelayTime.Text = "Vezögerung";
                this.labelStaticFeedingRunTime.Text = "Laufzeit";

                this.labelMessage1.Text = "Alarm - doppelte Eingabe";

                this.labelStaticAlarmContinuousNG.Text = "Dauerhafter Fehler";
                this.labelMessage3.Text = "Kontinuierliches NG tritt auf!";

                this.labelStaticATPC.Text = "Alarm übergeben";
                this.labelStaticATPC_Count.Text = "Zählen";
                this.labelStaticATPC_Pass.Text = "Bestehen";
                this.labelStaticATPC_Lack.Text = "Mangel";
                this.buttonATPC_Reset.Text = "RST";
                #endregion
            }
            else
            {

            }
        }
        private void InitializeControl()
        {
            if (this.ParentForm.IsBootingComplete == false)
                this.buttonProductNo.Text = "**";
            else
                this.buttonProductNo.Text = this.ParentForm.SystemConfig.ProductNumber.ToString();

            this.buttonUnder.Text = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonPass.Text = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.PassRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonOver.Text = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.OverRange, this.ParentForm.SystemConfig.DecimalPlaces);
            this.buttonTare.Text = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.TareRange, this.ParentForm.SystemConfig.DecimalPlaces);

            this.labelProductName.Text = this.ParentForm.CurrentProductItem.Name;
            this.labelLotNo.Text = this.ParentForm.CurrentProductItem.LotNo;
            this.labelProductionSpeed.Text = "0";

            // Alarm ContinuousNG CNT
            this.labelAlarmContinuousNG.Text = this.ParentForm.SystemConfig.AlarmContinuousNG.ToString();
            // Alarm ContinuousNG Enable
            if (this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable == true)
                this.buttonAlarmContinuousNG.ButtonDown();
            else
                this.buttonAlarmContinuousNG.ButtonUp();

            // Alarm TotalCount 
            this.labelATPC_SetCNT.Text = this.ParentForm.SystemConfig.AlarmTotalPassCnt.ToString();
            // Alarm TotalCount Enable
            if (this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable == true)
                this.buttonATPC_Enable.ButtonDown();
            else
                this.buttonATPC_Enable.ButtonUp();
            // Alarm Totalcount Display
            this.UpdateAlarmTotalPassCountDisplay(this.ParentForm.CurrentAlarmTotalPassCnt);

            if (this.ParentForm.SystemConfig.IsBypassDirectionPass == true)
                this.buttonBypassDirection.ButtonUp();
            else
                this.buttonBypassDirection.ButtonDown();

            if (this.ParentForm.SystemConfig.IsBypassOnce == true)
            {
                this.buttonBypassOnce.ButtonUp();
                this.buttonBypassRun.Mode = SmartButton.BUTTONMODE.NORMAL;
            }
            else
            {
                this.buttonBypassOnce.ButtonDown();
                this.buttonBypassRun.Mode = SmartButton.BUTTONMODE.PUSH;
            }

            // Panel SubMenu1
            this.panelSubMenu1.Location = new Point(4, 573);
            this.panelSubMenu1.Visible = false;
            this.panelSubMenu1.BringToFront();
            // Panel SubMenu2
            this.panelSubMenu2.Location = new Point(4, 573);
            this.panelSubMenu2.Visible = false;
            this.panelSubMenu2.BringToFront();

            // Alarm
            this.MainDisplayAlarmList = new ControlMainDisplayAlarm();
            this.Controls.Add(this.MainDisplayAlarmList);
            this.MainDisplayAlarmList.Location = new Point(658, 74);
            this.MainDisplayAlarmList.Visible = false;

            // Modbus Common
            this.MainDisplayModbusCom = new ControlModbusDisplayCommonData(this);
            this.Controls.Add(this.MainDisplayModbusCom);
            this.MainDisplayModbusCom.Location = new Point(0, 75);
            this.MainDisplayModbusCom.BringToFront();
            // Modbus 1 to 6 Data
            this.MainDisplayModbus1 = new ControlModbusDisplay1to6(this);
            this.Controls.Add(this.MainDisplayModbus1);
            this.MainDisplayModbus1.Location = new Point(0, 75);
            this.MainDisplayModbus1.BringToFront();
            // Modbus 7 to 12 Data
            this.MainDisplayModbus7 = new ControlModbusDisplay7to12(this);
            this.Controls.Add(this.MainDisplayModbus7);
            this.MainDisplayModbus7.Location = new Point(0, 75);
            this.MainDisplayModbus7.BringToFront();
            // Modbus 13 to 15 Data
            if (this.ParentForm.SystemConfig.EquipmentColumns == 15)
            {
                this.MainDisplayModbus13 = new ControlModbusDisplay13to15(this);
                this.Controls.Add(this.MainDisplayModbus13);
                this.MainDisplayModbus13.Location = new Point(0, 75);
                this.MainDisplayModbus13.BringToFront();
            }

            // ICON 
            this.pictureBoxUSBBackOn.Visible = this.ParentForm.SystemConfig.IsDataBackup;
            this.pictureBoxBypass.Visible = this.ParentForm.SystemConfig.IsBypassMode;
            
            if (this.ParentForm.SystemConfig.Serial3Mode != 0)
                this.pictureBoxCH3.Visible = true;
            else
                this.pictureBoxCH3.Visible = false;

            this.buttonBarGraphForm.ButtonDown();

            this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    this.MainDisplayEachBarGraph7 = new ControlMainDisplayEachBarGraph7(this);
                    this.Controls.Add(this.MainDisplayEachBarGraph7);
                    this.MainDisplayEachBarGraph7.BringToFront();
                    this.MainDisplayEachBarGraph7.Location = new Point(0, 75);
                    this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

                    this.MainDisplayDotGraph7 = new ControlMainDisplayDotGraph7(this);
                    this.Controls.Add(this.MainDisplayDotGraph7);
                    this.MainDisplayDotGraph7.BringToFront();
                    this.MainDisplayDotGraph7.Location = new Point(0, 75);

                    this.MainDisplayTable7 = new ControlMainDisplayTable7(this);
                    this.Controls.Add(this.MainDisplayTable7);
                    this.MainDisplayTable7.BringToFront();
                    this.MainDisplayTable7.Location = new Point(0, 75);
                    break;
                case 8:
                    this.MainDisplayEachBarGraph8 = new ControlMainDisplayEachBarGraph8(this);
                    this.Controls.Add(this.MainDisplayEachBarGraph8);
                    this.MainDisplayEachBarGraph8.BringToFront();
                    this.MainDisplayEachBarGraph8.Location = new Point(0, 75);
                    this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

                    this.MainDisplayDotGraph8 = new ControlMainDisplayDotGraph8(this);
                    this.Controls.Add(this.MainDisplayDotGraph8);
                    this.MainDisplayDotGraph8.BringToFront();
                    this.MainDisplayDotGraph8.Location = new Point(0, 75);

                    this.MainDisplayTable8 = new ControlMainDisplayTable8(this);
                    this.Controls.Add(this.MainDisplayTable8);
                    this.MainDisplayTable8.BringToFront();
                    this.MainDisplayTable8.Location = new Point(0, 75);
                    break;
                case 10:
                    this.MainDisplayEachBarGraph10 = new ControlMainDisplayEachBarGraph10(this);
                    this.Controls.Add(this.MainDisplayEachBarGraph10);
                    this.MainDisplayEachBarGraph10.BringToFront();
                    this.MainDisplayEachBarGraph10.Location = new Point(0, 75);
                    this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

                    this.MainDisplayDotGraph10 = new ControlMainDisplayDotGraph10(this);
                    this.Controls.Add(this.MainDisplayDotGraph10);
                    this.MainDisplayDotGraph10.BringToFront();
                    this.MainDisplayDotGraph10.Location = new Point(0, 75);

                    this.MainDisplayTable10 = new ControlMainDisplayTable10(this);
                    this.Controls.Add(this.MainDisplayTable10);
                    this.MainDisplayTable10.BringToFront();
                    this.MainDisplayTable10.Location = new Point(0, 75);
                    break;
                case 12:
                    this.MainDisplayEachBarGraph12 = new ControlMainDisplayEachBarGraph12(this);
                    this.Controls.Add(this.MainDisplayEachBarGraph12);
                    this.MainDisplayEachBarGraph12.BringToFront();
                    this.MainDisplayEachBarGraph12.Location = new Point(0, 75);
                    this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

                    this.MainDisplayDotGraph12 = new ControlMainDisplayDotGraph12(this);
                    this.Controls.Add(this.MainDisplayDotGraph12);
                    this.MainDisplayDotGraph12.BringToFront();
                    this.MainDisplayDotGraph12.Location = new Point(0, 75);

                    this.MainDisplayTable12 = new ControlMainDisplayTable12(this);
                    this.Controls.Add(this.MainDisplayTable12);
                    this.MainDisplayTable12.BringToFront();
                    this.MainDisplayTable12.Location = new Point(0, 75);
                    break;
                case 15:
                    this.MainDisplayEachBarGraph15 = new ControlMainDisplayEachBarGraph15(this);
                    this.Controls.Add(this.MainDisplayEachBarGraph15);
                    this.MainDisplayEachBarGraph15.BringToFront();
                    this.MainDisplayEachBarGraph15.Location = new Point(0, 75);
                    this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

                    this.MainDisplayDotGraph15 = new ControlMainDisplayDotGraph15(this);
                    this.Controls.Add(this.MainDisplayDotGraph15);
                    this.MainDisplayDotGraph15.BringToFront();
                    this.MainDisplayDotGraph15.Location = new Point(0, 75);

                    this.MainDisplayTable15 = new ControlMainDisplayTable15(this);
                    this.Controls.Add(this.MainDisplayTable15);
                    this.MainDisplayTable15.BringToFront();
                    this.MainDisplayTable15.Location = new Point(0, 75);
                    break;
                default:
                    break;
            }
            this.UpdateDisplay(this.MainDisplay);
        }
        private void DefaultSetting()
        {
            int x = 0, y = 0;

            this.FlagTimeoutCount = 0;
            this.SubmenuIndex = 0;
            this.ChangeID = "";
            this.FlagModbusDec = true;

            this.ColorButtonAccessTrue = Color.Black;
            this.ColorButtonAccessFalse = Color.DimGray;

            this.ModbusDisplay = DataStore.E_ModbusDisplay.Common;

            this.RescaleControl();

            this.panelSetting.Location = new Point(513, 77);
            this.panelSetting.Visible = false;
            this.panelSetting.BringToFront();

            // AlarmMessageBox
            x = Screen.PrimaryScreen.Bounds.Width / 2 - this.panelAlarmMessageBox1.Size.Width / 2;
            y = Screen.PrimaryScreen.Bounds.Height / 2 - this.panelAlarmMessageBox1.Size.Height / 2;
            this.panelAlarmMessageBox1.Location = new Point(x, y);
            this.panelAlarmMessageBox1.Visible = false;
            this.panelAlarmMessageBox1.BringToFront();

            this.panelAlarmMessageBox3.Location = new Point(x, y);
            this.panelAlarmMessageBox3.Visible = false;
            this.panelAlarmMessageBox3.BringToFront();

            if (this.ParentForm.SystemConfig.IsLogin == true)
                this.UpdateDisplayUser(this.ParentForm.SystemConfig.CurrentUser);
            else
            {
                this.buttonUser.Visible = false;
                this.labelUserID.Visible = false;
                this.labelUserLevel.Visible = false;
                this.labelExpireOfPassword.Visible = false;
            }

            // Ethernet 
            this.pictureBoxEthernetConnection.Visible = this.ParentForm.SystemConfig.IsEthernetEnable;
            this.pictureBoxEthernetDisconnection.Visible = this.ParentForm.SystemConfig.IsEthernetEnable;

            // Modbus Button
            this.UpdateDisplayModbusButton();
        }

        private void ClearAlarmTotalPassCount()
        {
            this.ParentForm.CurrentAlarmTotalPassCnt.Clear();
            this.UpdateAlarmTotalPassCountDisplay(this.ParentForm.CurrentAlarmTotalPassCnt);
        }
        private bool UI_Invoke(ThreadStart invoker)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    if (this.IsDisposed)
                        return true;

                    this.Invoke(invoker);
                }
                else
                {
                    invoker();
                }

                return true;

            }
            catch (Exception e)
            {
                return false;
            }

        }
        private void PasswordExpirationCheck(UserItem user)
        {
            int expiryDay = 0;

            // 만료일 -10 일때 메시지 띄우기
            expiryDay = user.GetPasswordExpiryDday();
            if (expiryDay >= -10)
            {
                //Console.WriteLine("password : " + expiryDay.ToString());
                DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 2, expiryDay.ToString());
                if (myDlg.ShowDialog() == DialogResult.Yes)
                {
                    // 비밀 번호 변경 띄우기
                    DialogFormLogOn logOn = new DialogFormLogOn(this.ParentForm, true, true);
                    if (logOn.ShowDialog() == DialogResult.OK)
                    {

                    }
                }
            }
        }
        private void DirectLogin(string id, string pass)
        {
            UserManager.UserMgr_user_info_t userInfo = new UserManager.UserMgr_user_info_t();

            UserManager.UserManager_UserLoginDirect(id, pass, ref userInfo);
            //Console.WriteLine(string.Format("status : {0}", userInfo.status));
            //Console.WriteLine("ID : " + id);
            //Console.WriteLine("pass : " + pass);

            if (userInfo.status == 0)
            {
                #region 로그인 성공
                if (userInfo.active_level == 1)
                    this.ParentForm.SystemConfig.CurrentUser.Group = DataStore.UserGroup.Level1;
                else if (userInfo.active_level == 2)
                    this.ParentForm.SystemConfig.CurrentUser.Group = DataStore.UserGroup.Level2;
                else if (userInfo.active_level == 3)
                    this.ParentForm.SystemConfig.CurrentUser.Group = DataStore.UserGroup.Level3;
                else if (userInfo.active_level == 9)
                    this.ParentForm.SystemConfig.CurrentUser.Group = DataStore.UserGroup.Admin;
                else if (userInfo.active_level == 10)
                    this.ParentForm.SystemConfig.CurrentUser.Group = DataStore.UserGroup.Developer;

                this.ParentForm.SystemConfig.CurrentUser.ID = userInfo.user_id;
                this.ParentForm.SystemConfig.CurrentUser.Password = userInfo.user_pw;

                this.ParentForm.SystemConfig.CurrentUser.ExpireId = userInfo.id_expire_period;
                this.ParentForm.SystemConfig.CurrentUser.ExpirePassword = userInfo.password_expire_period;

                //Console.WriteLine(userInfo.password_register_date.GetDateTime());
                //Console.WriteLine(userInfo.id_login_date.GetDateTime());
                //Console.WriteLine(userInfo.id_expire_date.GetDateTime());
                //Console.WriteLine(userInfo.password_expire_date.GetDateTime());

                DateTime time = DateTime.ParseExact(userInfo.password_register_date.GetDateTime(), "yyyyMMddHHmmss", null);
                this.ParentForm.SystemConfig.CurrentUser.DatePasswordRegister = time;
                time = DateTime.ParseExact(userInfo.id_login_date.GetDateTime(), "yyyyMMddHHmmss", null);
                this.ParentForm.SystemConfig.CurrentUser.DateIdLogin = time;
                time = DateTime.ParseExact(userInfo.id_expire_date.GetDateTime(), "yyyyMMddHHmmss", null);
                this.ParentForm.SystemConfig.CurrentUser.DateIdExpire = time;
                time = DateTime.ParseExact(userInfo.password_expire_date.GetDateTime(), "yyyyMMddHHmmss", null);
                this.ParentForm.SystemConfig.CurrentUser.DatePasswordExpire = time;

                this.ParentForm.SystemConfig.CurrentUser.IsLockAccount = userInfo.id_flock_status == 0 ? false : true;
                this.ParentForm.SystemConfig.CurrentUser.IsLockPassword = userInfo.password_flock_status == 0 ? false : true;

                this.ParentForm.SystemConfig.CurrentUser.IsAdmin = userInfo.fadmin == 0 ? false : true;

                this.ParentForm.SystemConfig.CurrentUser.ActiveLevel = userInfo.active_level;
                this.ParentForm.SystemConfig.CurrentUser.IsFirstPassword = userInfo.fFirstPW;
                #endregion

                this.UI_Invoke(delegate
                {
                    this.UpdateDisplayUser(this.ParentForm.SystemConfig.CurrentUser);
                });
            }
        }

        private void Login()
        {
            DialogResult result;

            DialogFormLogOn logOn = new DialogFormLogOn(this.ParentForm, false, false);
            result = logOn.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (this.ParentForm.SystemConfig.CurrentUser.Group == DataStore.UserGroup.Level1 ||
                    this.ParentForm.SystemConfig.CurrentUser.Group == DataStore.UserGroup.Level2 ||
                    this.ParentForm.SystemConfig.CurrentUser.Group == DataStore.UserGroup.Level3)
                {
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                    {
                        // 비밀번호 만료일 10일 미만 체크 후 비밀번호 변경
                        this.PasswordExpirationCheck(this.ParentForm.SystemConfig.CurrentUser);
                    }
                }

                this.buttonUser.ButtonDown();
                this.UpdateDisplayUser(this.ParentForm.SystemConfig.CurrentUser);
            }
            else if (result == DialogResult.Abort)
            {
                // 비밀 번호 변경 띄우기
                DialogFormLogOn logOn1 = new DialogFormLogOn(this.ParentForm, false, true);
                if (logOn1.ShowDialog() == DialogResult.OK)
                {
                    this.buttonUser.ButtonDown();
                    this.UpdateDisplayUser(this.ParentForm.SystemConfig.CurrentUser);
                }
                else
                    this.buttonUser.ButtonUp();
            }
            else
            {
                this.buttonUser.ButtonUp();
            }
        }
        public void Logout()
        {
            this.ParentForm.SystemConfig.CurrentUser.Group = DataStore.UserGroup.LogOut;
            this.buttonUser.ButtonUp();
            this.DisplayRefresh();
            this.ChangeID = "";

            // Part 11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.Logout, "");
        }
        public void Part11AutomaticLogoutReset()
        {
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                UserManager.UserManager_AutoLogoutTimeoutReset();
        }

        private void UpdateDisplayUser(UserItem user)
        {
            string id = "", group = "", expirePW = "";
            int expireDate = 0;
            Color colorExpirePW = this.ParentForm.ColorLogOff;

            switch (user.Group)
            {
                case DataStore.UserGroup.None:
                    break;
                case DataStore.UserGroup.Level1:
                    id = user.ID;
                    group = this.ParentForm.SystemConfig.User_Level1_Name;

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.labelUserID.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonProductNo.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayProductNo;
                    this.buttonSubMenu.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplaySubMenu;
                    this.buttonClear.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayClear;
                    this.buttonUnder.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayWeightSetting;
                    this.buttonPass.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayWeightSetting;
                    this.buttonOver.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayWeightSetting;
                    this.buttonTare.Enabled = this.ParentForm.CurrentUserGroup.Level1.IsMainDisplayWeightSetting;

                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Level2:
                    id = user.ID;
                    group = this.ParentForm.SystemConfig.User_Level2_Name;

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.labelUserID.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonProductNo.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayProductNo;
                    this.buttonSubMenu.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplaySubMenu;
                    this.buttonClear.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayClear;
                    this.buttonUnder.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayWeightSetting;
                    this.buttonPass.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayWeightSetting;
                    this.buttonOver.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayWeightSetting;
                    this.buttonTare.Enabled = this.ParentForm.CurrentUserGroup.Level2.IsMainDisplayWeightSetting;

                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Level3:
                    id = user.ID;
                    group = this.ParentForm.SystemConfig.User_Level3_Name;

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.labelUserID.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonProductNo.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayProductNo;
                    this.buttonSubMenu.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplaySubMenu;
                    this.buttonClear.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayClear;
                    this.buttonUnder.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayWeightSetting;
                    this.buttonPass.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayWeightSetting;
                    this.buttonOver.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayWeightSetting;
                    this.buttonTare.Enabled = this.ParentForm.CurrentUserGroup.Level3.IsMainDisplayWeightSetting;

                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Admin:
                    id = user.ID;
                    if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
                        group = "Administrator";
                    else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
                        group = "行政";
                    else
                        group = "Administrator";

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.labelUserID.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonProductNo.Enabled = true;
                    this.buttonSubMenu.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonUnder.Enabled = true;
                    this.buttonPass.Enabled = true;
                    this.buttonOver.Enabled = true;
                    this.buttonTare.Enabled = true;

                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Developer:
                    id = user.ID;
                    if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
                        group = "Entwickler";
                    else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
                        group = "开发商";
                    else
                        group = "Developer";

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.labelExpireOfPassword.Visible = true;

                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.labelUserID.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonUser.ButtonDown();
                    this.buttonProductNo.Enabled = true;
                    this.buttonSubMenu.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonUnder.Enabled = true;
                    this.buttonPass.Enabled = true;
                    this.buttonOver.Enabled = true;
                    this.buttonTare.Enabled = true;

                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.NotLogin:
                    break;
                case DataStore.UserGroup.LogOut:
                    id = "";
                    if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
                        group = "Ausloggen";
                    else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
                        group = "登出";
                    else
                        group = "Log out";

                    this.labelExpireOfPassword.Visible = false;

                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.labelUserID.ForeColor = this.ParentForm.ColorLogOff;

                    this.buttonUser.ButtonUp();
                    this.buttonProductNo.Enabled = false;
                    this.buttonSubMenu.Enabled = false;
                    this.buttonClear.Enabled = false;
                    this.buttonUnder.Enabled = false;
                    this.buttonPass.Enabled = false;
                    this.buttonOver.Enabled = false;
                    this.buttonTare.Enabled = false;

                    this.buttonMenu.Enabled = false;
                    break;
                default:
                    break;
            }

            if (this.ParentForm.SystemConfig.IsLogin == true)
            {
                if (this.ParentForm.SystemConfig.IsPart11 == true)
                {
                    if (user.ExpirePassword != 0)
                    {
                        expireDate = user.GetPasswordExpiryDday();
                        if (expireDate == 9999)
                        {
                            // Administrator or Developer
                            colorExpirePW = this.ParentForm.ColorLogOn;
                            expirePW = "-";
                        }
                        else
                        {
                            if (expireDate >= -10)
                            {
                                colorExpirePW = this.ParentForm.ColorLogOff;
                                if (expireDate > 0)
                                    expirePW = string.Format("D+{0}", expireDate);
                                else
                                    expirePW = string.Format("D{0}", expireDate);
                            }
                            else
                            {
                                colorExpirePW = this.ParentForm.ColorLogOn;
                                expirePW = string.Format("D{0}", expireDate);
                            }
                        }
                    }
                    else
                    {
                        colorExpirePW = this.ParentForm.ColorLogOn;
                        expirePW = "-";
                    }
                }
                else
                {
                    // Part11 미사용
                    colorExpirePW = this.ParentForm.ColorLogOn;
                    expirePW = "-";
                }
            }

            if (this.labelUserLevel.Text != group)
                this.labelUserLevel.Text = group;
            if (this.labelUserID.Text != id)
                this.labelUserID.Text = id;
            if (this.labelExpireOfPassword.ForeColor != colorExpirePW)
                this.labelExpireOfPassword.ForeColor = colorExpirePW;
            if (this.labelExpireOfPassword.Text != expirePW)
                this.labelExpireOfPassword.Text = expirePW;
        }
        private void UpdateDisplay(DataStore.FormMainDisplayStore displayForm)
        {
            this.MainDisplayModbusCom.Visible = false;
            this.MainDisplayModbus1.Visible = false;
            this.MainDisplayModbus7.Visible = false;

            if (displayForm == DataStore.FormMainDisplayStore.FormMainDisplayBarGraph)
            {
                #region BarGraph
                switch (this.ParentForm.SystemConfig.EquipmentColumns)
                {
                    case 7:
                        if (this.MainDisplayEachBarGraph7 != null)
                            this.MainDisplayEachBarGraph7.Visible = true;
                        if (this.MainDisplayDotGraph7 != null)
                            this.MainDisplayDotGraph7.Visible = false;
                        if (this.MainDisplayTable7 != null)
                            this.MainDisplayTable7.Visible = false;
                        break;
                    case 8:
                        if (this.MainDisplayEachBarGraph8 != null)
                            this.MainDisplayEachBarGraph8.Visible = true;
                        if (this.MainDisplayDotGraph8 != null)
                            this.MainDisplayDotGraph8.Visible = false;
                        if (this.MainDisplayTable8 != null)
                            this.MainDisplayTable8.Visible = false;
                        break;
                    case 10:
                        if (this.MainDisplayEachBarGraph10 != null)
                            this.MainDisplayEachBarGraph10.Visible = true;
                        if (this.MainDisplayDotGraph10 != null)
                            this.MainDisplayDotGraph10.Visible = false;
                        if (this.MainDisplayTable10 != null)
                            this.MainDisplayTable10.Visible = false;
                        break;
                    case 12:
                        if (this.MainDisplayEachBarGraph12 != null)
                            this.MainDisplayEachBarGraph12.Visible = true;
                        if (this.MainDisplayDotGraph12 != null)
                            this.MainDisplayDotGraph12.Visible = false;
                        if (this.MainDisplayTable12 != null)
                            this.MainDisplayTable12.Visible = false;
                        break;
                    case 15:
                        if (this.MainDisplayEachBarGraph15 != null)
                            this.MainDisplayEachBarGraph15.Visible = true;
                        if (this.MainDisplayDotGraph15 != null)
                            this.MainDisplayDotGraph15.Visible = false;
                        if (this.MainDisplayTable15 != null)
                            this.MainDisplayTable15.Visible = false;
                        break;
                    default:
                        break;
                }

                this.UpdateDisplayButton(SmartButton.BUTSTATUS.DOWN, SmartButton.BUTSTATUS.UP, SmartButton.BUTSTATUS.UP);
                #endregion
            }
            else if (displayForm == DataStore.FormMainDisplayStore.FormMainDisplayDotGraph)
            {
                #region DotGraph
                switch (this.ParentForm.SystemConfig.EquipmentColumns)
                {
                    case 7:
                        if (this.MainDisplayEachBarGraph7 != null)
                            this.MainDisplayEachBarGraph7.Visible = false;
                        if (this.MainDisplayDotGraph7 != null)
                            this.MainDisplayDotGraph7.Visible = true;
                        if (this.MainDisplayTable7 != null)
                            this.MainDisplayTable7.Visible = false;
                        break;
                    case 8:
                        if (this.MainDisplayEachBarGraph8 != null)
                            this.MainDisplayEachBarGraph8.Visible = false;
                        if (this.MainDisplayDotGraph8 != null)
                            this.MainDisplayDotGraph8.Visible = true;
                        if (this.MainDisplayTable8 != null)
                            this.MainDisplayTable8.Visible = false;
                        break;
                    case 10:
                        if (this.MainDisplayEachBarGraph10 != null)
                            this.MainDisplayEachBarGraph10.Visible = false;
                        if (this.MainDisplayDotGraph10 != null)
                            this.MainDisplayDotGraph10.Visible = true;
                        if (this.MainDisplayTable10 != null)
                            this.MainDisplayTable10.Visible = false;
                        break;
                    case 12:
                        if (this.MainDisplayEachBarGraph12 != null)
                            this.MainDisplayEachBarGraph12.Visible = false;
                        if (this.MainDisplayDotGraph12 != null)
                            this.MainDisplayDotGraph12.Visible = true;
                        if (this.MainDisplayTable12 != null)
                            this.MainDisplayTable12.Visible = false;
                        break;
                    case 15:
                        if (this.MainDisplayEachBarGraph15 != null)
                            this.MainDisplayEachBarGraph15.Visible = false;
                        if (this.MainDisplayDotGraph15 != null)
                            this.MainDisplayDotGraph15.Visible = true;
                        if (this.MainDisplayTable15 != null)
                            this.MainDisplayTable15.Visible = false;
                        break;
                    default:
                        break;
                }

                this.UpdateDisplayButton(SmartButton.BUTSTATUS.UP, SmartButton.BUTSTATUS.DOWN, SmartButton.BUTSTATUS.UP);
                #endregion
            }
            else if (displayForm == DataStore.FormMainDisplayStore.FormMainDisplayTable)
            {
                #region Table
                switch (this.ParentForm.SystemConfig.EquipmentColumns)
                {
                    case 7:
                        if (this.MainDisplayEachBarGraph7 != null)
                            this.MainDisplayEachBarGraph7.Visible = false;
                        if (this.MainDisplayDotGraph7 != null)
                            this.MainDisplayDotGraph7.Visible = false;
                        if (this.MainDisplayTable7 != null)
                            this.MainDisplayTable7.Visible = true;
                        break;
                    case 8:
                        if (this.MainDisplayEachBarGraph8 != null)
                            this.MainDisplayEachBarGraph8.Visible = false;
                        if (this.MainDisplayDotGraph8 != null)
                            this.MainDisplayDotGraph8.Visible = false;
                        if (this.MainDisplayTable8 != null)
                            this.MainDisplayTable8.Visible = true;
                        break;
                    case 10:
                        if (this.MainDisplayEachBarGraph10 != null)
                            this.MainDisplayEachBarGraph10.Visible = false;
                        if (this.MainDisplayDotGraph10 != null)
                            this.MainDisplayDotGraph10.Visible = false;
                        if (this.MainDisplayTable10 != null)
                            this.MainDisplayTable10.Visible = true;
                        break;
                    case 12:
                        if (this.MainDisplayEachBarGraph12 != null)
                            this.MainDisplayEachBarGraph12.Visible = false;
                        if (this.MainDisplayDotGraph12 != null)
                            this.MainDisplayDotGraph12.Visible = false;
                        if (this.MainDisplayTable12 != null)
                            this.MainDisplayTable12.Visible = true;
                        break;
                    case 15:
                        if (this.MainDisplayEachBarGraph15 != null)
                            this.MainDisplayEachBarGraph15.Visible = false;
                        if (this.MainDisplayDotGraph15 != null)
                            this.MainDisplayDotGraph15.Visible = false;
                        if (this.MainDisplayTable15 != null)
                            this.MainDisplayTable15.Visible = true;
                        break;
                    default:
                        break;
                }

                this.UpdateDisplayButton(SmartButton.BUTSTATUS.UP, SmartButton.BUTSTATUS.UP, SmartButton.BUTSTATUS.DOWN);
                #endregion
            }
        }
        private void UpdateDisplayButton(SmartButton.BUTSTATUS buttonBar, SmartButton.BUTSTATUS buttonDot, SmartButton.BUTSTATUS buttonTable)
        {
            if(buttonBar == SmartButton.BUTSTATUS.DOWN)
                this.buttonBarGraphForm.ButtonDown();
            else
                this.buttonBarGraphForm.ButtonUp();

            if (buttonDot == SmartButton.BUTSTATUS.DOWN)
                this.buttonDotGraphForm.ButtonDown();
            else
                this.buttonDotGraphForm.ButtonUp();

            if (buttonTable == SmartButton.BUTSTATUS.DOWN)
                this.buttonTableForm.ButtonDown();
            else
                this.buttonTableForm.ButtonUp();
        }
        private void UpdateDisplayModbusButton()
        {
            if (this.ParentForm.SystemConfig.IsModbusEnable == true)
                this.buttonModbus.Visible = true;
            else
                this.buttonModbus.Visible = false;
        }

        public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, ProductItem pItem,JudgmentSetItem jItem, Collection<WeightData> weightDatas)
        {
            string value = "";

            this.timerTimeout.Enabled = false;
            this.labelTimeroutCount.Visible = false;

            value = pItem.Number.ToString();
            if (this.buttonProductNo.Text != value)
                this.buttonProductNo.Text = value;

            value = pItem.Name;
            if (this.labelProductName.Text != value)
                this.labelProductName.Text = value;

            value = pItem.LotNo;
            if (this.labelLotNo.Text != value)
                this.labelLotNo.Text = value;

            value = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.buttonUnder.Text != value)
                this.buttonUnder.Text = value;

            value = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.PassRange, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.buttonPass.Text != value)
                this.buttonPass.Text = value;

            value = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.OverRange, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.buttonOver.Text != value)
                this.buttonOver.Text = value;

            value = Helper.StringToDecimalPlaces(this.ParentForm.CurrentProductItem.TareRange, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.buttonTare.Text != value)
                this.buttonTare.Text = value;

            value = jItem.Sorter1DelayTime.ToString();
            if (this.labelSorter1DelayTime.Text != value)
                this.labelSorter1DelayTime.Text = value;

            value = jItem.Sorter1RunTime.ToString();
            if (this.labelSorter1RunTime.Text != value)
                this.labelSorter1RunTime.Text = value;

            value = jItem.Sorter2DelayTime.ToString();
            if (this.labelSorter2DelayTime.Text != value)
                this.labelSorter2DelayTime.Text = value;

            value = jItem.Sorter2RunTime.ToString();
            if (this.labelSorter2RunTime.Text != value)
                this.labelSorter2RunTime.Text = value;

            value = jItem.RejectConveyorDelayTime.ToString();
            if (this.labelRejectConveyorDelayTime.Text != value)
                this.labelRejectConveyorDelayTime.Text = value;

            value = jItem.RejectConveyorRunTime.ToString();
            if (this.labelRejectConveyorRunTime.Text != value)
                this.labelRejectConveyorRunTime.Text = value;

            value = jItem.FeedingConveyorDelayTime.ToString();
            if (this.labelFeedingConveyorDelayTime.Text != value)
                this.labelFeedingConveyorDelayTime.Text = value;

            value = jItem.FeedingConveyorRunTime.ToString();
            if (this.labelFeedingConveyorRunTime.Text != value)
                this.labelFeedingConveyorRunTime.Text = value;

            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayTable7 != null)
                        this.MainDisplayTable7.UpdateCurrentProductDisplay(status, weightDatas);
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayTable8 != null)
                        this.MainDisplayTable8.UpdateCurrentProductDisplay(status, weightDatas);
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayTable10 != null)
                        this.MainDisplayTable10.UpdateCurrentProductDisplay(status, weightDatas);
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayTable12 != null)
                        this.MainDisplayTable12.UpdateCurrentProductDisplay(status, weightDatas);
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.UpdateCurrentProductDisplay(status, weightDatas);
                    if (this.MainDisplayTable15 != null)
                        this.MainDisplayTable15.UpdateCurrentProductDisplay(status, weightDatas);
                    break;
                default:
                    break;
            }

            this.RescaleControl();
        }
        public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
        {
            StringBuilder sb = new StringBuilder();

            if (status == DataStore.EquipmentStatus.Start)
            {
                #region Start
                this.pictureBoxStart.Visible = true;
                this.pictureBoxStop.Visible = false;
                this.buttonProductNo.Enabled = false;
                this.labelProductName.Enabled = false;
                #endregion
            }
            else
            {
                #region Stop
                this.ParentForm.SaveCounterFile(this.ParentForm.CollectionWeightData, this.ParentForm.SystemConfig.ProductNumber - 1);

                this.pictureBoxStart.Visible = false;
                this.pictureBoxStop.Visible = true;
                this.buttonProductNo.Enabled = true;
                this.labelProductName.Enabled = true;

                if (this.panelSetting.Visible == true)
                    this.panelSetting.Visible = false;

                this.buttonCut.ButtonUp();
                this.timerCutSignalInterval.Enabled = false;
                #endregion
            }

            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayTable7 != null)
                        this.MainDisplayTable7.UpdateEquipmentStatusDisplay(status);
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayTable8 != null)
                        this.MainDisplayTable8.UpdateEquipmentStatusDisplay(status);
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayTable10 != null)
                        this.MainDisplayTable10.UpdateEquipmentStatusDisplay(status);
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayTable12 != null)
                        this.MainDisplayTable12.UpdateEquipmentStatusDisplay(status);
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.UpdateEquipmentStatusDisplay(status);
                    if (this.MainDisplayTable15 != null)
                        this.MainDisplayTable15.UpdateEquipmentStatusDisplay(status);
                    break;
                default:
                    break;
            }
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable7 != null)
                        this.MainDisplayTable7.UpdateStopWeightDisplay(status, weightDatas);
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable8 != null)
                        this.MainDisplayTable8.UpdateStopWeightDisplay(status, weightDatas);
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable10 != null)
                        this.MainDisplayTable10.UpdateStopWeightDisplay(status, weightDatas);
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable12 != null)
                        this.MainDisplayTable12.UpdateStopWeightDisplay(status, weightDatas);
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.UpdateStopWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable15 != null)
                        this.MainDisplayTable15.UpdateStopWeightDisplay(status, weightDatas);
                    break;
                default:
                    break;
            }
        }
        public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";

            value = weightDatas[0].ProductionSpeed.ToString();
            if (this.labelProductionSpeed.Text != value)
                this.labelProductionSpeed.Text = value;

            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable7 != null)
                        this.MainDisplayTable7.UpdateStartWeightDisplay(status, weightDatas);
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable8 != null)
                        this.MainDisplayTable8.UpdateStartWeightDisplay(status, weightDatas);
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable10 != null)
                        this.MainDisplayTable10.UpdateStartWeightDisplay(status, weightDatas);
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable12 != null)
                        this.MainDisplayTable12.UpdateStartWeightDisplay(status, weightDatas);
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.UpdateStartWeightDisplay(status, weightDatas);
                    if (this.MainDisplayTable15 != null)
                        this.MainDisplayTable15.UpdateStartWeightDisplay(status, weightDatas);
                    break;
                default:
                    break;
            }

            this.SetTotalCount();

            // Modbus
            if (this.ParentForm.SystemConfig.IsModbusEnable == true)
            {
                this.MainDisplayModbusCom.UpdateData(this.ParentForm.Current30000ModbusData);
                this.MainDisplayModbus1.UpdateData(this.ParentForm.Current30000ModbusData);

                if (this.ParentForm.SystemConfig.EquipmentColumns >= 7)
                    this.MainDisplayModbus7.UpdateData(this.ParentForm.Current30000ModbusData);

                if (this.ParentForm.SystemConfig.EquipmentColumns >= 13)
                    this.MainDisplayModbus13.UpdateData(this.ParentForm.Current30000ModbusData);
            }
        }
        public void UpdateAlarmMessageDisplay()
        {
            if (this.panelAlarmMessageBox1.Visible == false)
                this.panelAlarmMessageBox1.Visible = true;
        }
        public void UpdateAlarmMessage3Display(bool status)
        {
            this.panelAlarmMessageBox3.Visible = status;
        }
        public void UpdateDisplayAlarmView(AlarmList alarm)
        {
            if (alarm.IsEntrySensorError == true || alarm.IsLoadcellError == true || alarm.IsPressureError == true ||
                alarm.IsServoOff == true || alarm.IsServoAlarm == true || alarm.IsServoTorqueAlarmTorque == true)
                this.pictureBoxAlarm.Visible = true;
            else
            {
                this.pictureBoxAlarm.Visible = false;
                this.MainDisplayAlarmList.Visible = false;
            }

            this.MainDisplayAlarmList.listBoxMessage.Items.Clear();

            if (alarm.IsEntrySensorError == true)
                this.MainDisplayAlarmList.listBoxMessage.Items.Add("Entry Sensor Error");
            if (alarm.IsLoadcellError == true)
                this.MainDisplayAlarmList.listBoxMessage.Items.Add("LoadCell Error");
            if (alarm.IsPressureError == true)
                this.MainDisplayAlarmList.listBoxMessage.Items.Add("Pressure Error");
            if (alarm.IsServoOff == true)
                this.MainDisplayAlarmList.listBoxMessage.Items.Add("Servo OFF");
            if (alarm.IsServoAlarm == true)
                this.MainDisplayAlarmList.listBoxMessage.Items.Add("Servo Alarm");
            if (alarm.IsServoTorqueAlarmTorque == true)
                this.MainDisplayAlarmList.listBoxMessage.Items.Add("Servo Torque Alarm");
        }
        public void UpdateDisplayTime()
        {
            this.labelTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
        public void SetTotalCount()
        {
            int toTalAll = 0, toTalPass = 0, toTalNG = 0;

            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
            {
                toTalAll += this.ParentForm.CollectionWeightData[i].TotalCount;
                toTalPass += this.ParentForm.CollectionWeightData[i].PassCount;
                toTalNG += this.ParentForm.CollectionWeightData[i].TotalNGCount;
            }

            // Total All Count
            // Total Pass Count
            if (this.labelTitleTotalCount.Text == "Pass")
            {
                if (this.labelTotalCount.Text != toTalPass.ToString())
                    this.labelTotalCount.Text = toTalPass.ToString();
            }
            else
            {
                if (this.labelTotalCount.Text != toTalAll.ToString())
                    this.labelTotalCount.Text = toTalAll.ToString();
            }

            // Total NG Count
            if (this.labelNGCount.Text != toTalNG.ToString())
                this.labelNGCount.Text = toTalNG.ToString();
        }
        public void ProductChange(int productNumber)
        {
            this.buttonProductNo.Text = "**";

            this.ParentForm.TransferProductParameter(productNumber);

            this.FlagTimeoutCount = 0;
            this.timerTimeout.Enabled = true;
        }
        public void RescaleControl()
        {
            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.RescaleControl();
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.RescaleControl();
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.RescaleControl();
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.RescaleControl();
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.RescaleControl();
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.RescaleControl();
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.RescaleControl();
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.RescaleControl();
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.RescaleControl();
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.RescaleControl();
                    break;
                default:
                    break;
            }
        }
        public void UpdateEthernetStatusDisplay(bool status)
        {
            if (status == true)
            {
                this.pictureBoxEthernetConnection.Visible = true;
                this.pictureBoxEthernetDisconnection.Visible = false;
            }
            else
            {
                this.pictureBoxEthernetConnection.Visible = false;
                this.pictureBoxEthernetDisconnection.Visible = true;
            }
        }
        public void UpdateAlarmTotalPassCountDisplay(Counter cnt)
        {
            string value = "";

            value = cnt.CurrentTotalPass.ToString();
            if (this.labelATPC_counting.Text != value)
                this.labelATPC_counting.Text = value;

            value = cnt.BeforeTotalPass.ToString();
            if (this.labelATPC_Pass.Text != value)
                this.labelATPC_Pass.Text = value;

            value = cnt.BeforeLackCNT.ToString();
            if (this.labelATPC_Lack.Text != value)
                this.labelATPC_Lack.Text = value;
        }
        public void UpdateModbusDisplay(DataStore.E_ModbusDisplay display)
        {
            if (display == DataStore.E_ModbusDisplay.Common)
            {
                this.MainDisplayModbusCom.DisplayRefresh();
                
                this.MainDisplayModbusCom.Visible = true;
                this.MainDisplayModbus1.Visible = false;
                this.MainDisplayModbus7.Visible = false;

                if (this.ParentForm.SystemConfig.EquipmentColumns == 15)
                    this.MainDisplayDotGraph15.Visible = false;

                this.MainDisplayModbusCom.BringToFront();
            }
            else if (display == DataStore.E_ModbusDisplay.Display1)
            {
                this.MainDisplayModbus1.DisplayRefresh();

                this.MainDisplayModbusCom.Visible = false;
                this.MainDisplayModbus1.Visible = true;
                this.MainDisplayModbus7.Visible = false;

                if (this.ParentForm.SystemConfig.EquipmentColumns == 15)
                    this.MainDisplayDotGraph15.Visible = false;

                this.MainDisplayModbus1.BringToFront();
            }
            else if (display == DataStore.E_ModbusDisplay.Display2)
            {
                this.MainDisplayModbus7.DisplayRefresh();

                this.MainDisplayModbusCom.Visible = false;
                this.MainDisplayModbus1.Visible = false;
                this.MainDisplayModbus7.Visible = true;

                if (this.ParentForm.SystemConfig.EquipmentColumns == 15)
                    this.MainDisplayDotGraph15.Visible = false;

                this.MainDisplayModbus7.BringToFront();
            }
            else if(display == DataStore.E_ModbusDisplay.Display3)
            {
                this.MainDisplayModbus13.DisplayRefresh();
                
                this.MainDisplayModbusCom.Visible = false;
                this.MainDisplayModbus1.Visible = false;
                this.MainDisplayModbus7.Visible = false;
                this.MainDisplayModbus13.Visible = true;

                this.MainDisplayModbus13.BringToFront();
            }
        }
        public void UpdateModbusData(Modbus_30000_Data data)
        {
            this.MainDisplayModbusCom.UpdateData(data);
            this.MainDisplayModbus1.UpdateData(data);
            this.MainDisplayModbus7.UpdateData(data);

            if (this.ParentForm.SystemConfig.EquipmentColumns == 15)
                this.MainDisplayModbus13.UpdateData(data);

        }
        public void UpdateModbusReceiveCount()
        {
            this.MainDisplayModbusCom.UpdateReceiveCount();
        }

        public void CallBackUserListLoginTimeoutDataEvent(UserManager.UserMgr_login_timeout_t user)
        {
            string code = "", message1 = "", message2 = "";
            int warningTime = 0;

            if (user.remainder_time != 0)
            {
                switch (this.ParentForm.SystemConfig.Language)
                {
                    case DataStore.LanguageID.Korean:
                        code = "로그인";
                        message1 = "잠시 후에 로그아웃 됩니다";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.English:
                        code = "Login";
                        message1 = "You will be logged out after a while";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.Chinese:
                        code = "Login";
                        message1 = "You will be logged out after a while";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.Czech:
                        code = "Login";
                        message1 = "You will be logged out after a while";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.German:
                        code = "Login";
                        message1 = "You will be logged out after a while";
                        message2 = "";
                        break;
                    default:
                        break;
                }

                warningTime = this.ParentForm.FlagAutomaticLogoutWarningTime - 2;

                this.UI_Invoke(delegate
                {
                    DialogFormMessage msg = new DialogFormMessage(DataStore.MessageBoxIcon.Asterisk, code, message1, message2, warningTime);
                    msg.ShowDialog();
                });
            }
            else
            {
                switch (this.ParentForm.SystemConfig.Language)
                {
                    case DataStore.LanguageID.Korean:
                        code = "Login";
                        message1 = "자동 로그아웃 되었습니다";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.English:
                        code = "Login";
                        message1 = "automatically logged out";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.Chinese:
                        code = "Login";
                        message1 = "automatically logged out";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.Czech:
                        code = "Login";
                        message1 = "automatically logged out";
                        message2 = "";
                        break;
                    case DataStore.LanguageID.German:
                        code = "Login";
                        message1 = "automatically logged out";
                        message2 = "";
                        break;
                    default:
                        break;
                }

                // User Logout
                UserManager.UserManager_UserLogout();
                
                this.UI_Invoke(delegate
                {
                    this.Logout();
                });

                this.UI_Invoke(delegate
                {
                    DialogFormMessage msg = new DialogFormMessage(DataStore.MessageBoxIcon.Asterisk, code, message1, message2, 0);
                    msg.ShowDialog();
                });
            }
        }
        public void Clear()
        {
            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.Clear();
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.Clear();
                    if (this.MainDisplayTable7 != null)
                        this.MainDisplayTable7.Clear();
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.Clear();
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.Clear();
                    if (this.MainDisplayTable8 != null)
                        this.MainDisplayTable8.Clear();
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.Clear();
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.Clear();
                    if (this.MainDisplayTable10 != null)
                        this.MainDisplayTable10.Clear();
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.Clear();
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.Clear();
                    if (this.MainDisplayTable12 != null)
                        this.MainDisplayTable12.Clear();
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.Clear();
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.Clear();
                    if (this.MainDisplayTable15 != null)
                        this.MainDisplayTable15.Clear();
                    break;
                default:
                    break;
            }

            // 연속 NG 수량 Clear
            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
            {
                this.ParentForm.CollectionWeightData[i].ContinuousNG = 0;
                this.ParentForm.CollectionWeightData[i].IsContinuousNG = false;
            }

            // Alarm Total Pass Count
            this.ClearAlarmTotalPassCount();

            // Modbus Data Update
            if (this.ParentForm.SystemConfig.IsModbusEnable == true)
            {
                this.ParentForm.Update30000ModbusData();
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                    this.ParentForm.Update30000ModbusData(i);

                this.MainDisplayModbusCom.UpdateData(this.ParentForm.Current30000ModbusData);
                this.MainDisplayModbus1.UpdateData(this.ParentForm.Current30000ModbusData);
                this.MainDisplayModbus7.UpdateData(this.ParentForm.Current30000ModbusData);
            }
        }
        public void TimerServer(bool value)
        {
            if (value == false)
            {
                if (this.timerServer.Enabled == true)
                    this.timerServer.Enabled = false;
            }
            else
            {
                if (this.timerServer.Enabled == false)
                    this.timerServer.Enabled = true;
            }
        }

        public void DisplayRefresh()
        {
            this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormMainDisplay;

            this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;
            this.UpdateDisplay(this.MainDisplay);

            if (this.ParentForm.SystemConfig.IsLogin == true)
                this.UpdateDisplayUser(this.ParentForm.SystemConfig.CurrentUser);

            if (this.ParentForm.EquipmentStatus == DataStore.EquipmentStatus.Stop)
            {
                this.ProductChange(this.ParentForm.SystemConfig.ProductNumber);
            }

            this.pictureBoxUSBBackOn.Visible = this.ParentForm.SystemConfig.IsDataBackup;
            this.pictureBoxBypass.Visible = this.ParentForm.SystemConfig.IsBypassMode;
            this.pictureBoxEthernetConnection.Visible = this.ParentForm.SystemConfig.IsEthernetEnable;
            this.pictureBoxEthernetDisconnection.Visible = this.ParentForm.SystemConfig.IsEthernetEnable;

            // Alarm ContinuousNG CNT
            this.labelAlarmContinuousNG.Text = this.ParentForm.SystemConfig.AlarmContinuousNG.ToString();
            // Alarm ContinuousNG Enable
            if (this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable == true)
                this.buttonAlarmContinuousNG.ButtonDown();
            else
                this.buttonAlarmContinuousNG.ButtonUp();

            // Alarm TotalCount 
            this.labelATPC_SetCNT.Text = this.ParentForm.SystemConfig.AlarmTotalPassCnt.ToString();
            // Alarm TotalCount Enable
            if (this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable == true)
                this.buttonATPC_Enable.ButtonDown();
            else
                this.buttonATPC_Enable.ButtonUp();
            
            if (this.ParentForm.SystemConfig.Serial3Mode != 0)
                this.pictureBoxCH3.Visible = true;
            else
                this.pictureBoxCH3.Visible = false;

            if (this.ParentForm.SystemConfig.IsBypassDirectionPass == true)
                this.buttonBypassDirection.ButtonUp();
            else
                this.buttonBypassDirection.ButtonDown();

            if (this.ParentForm.SystemConfig.IsBypassOnce == true)
            {
                this.buttonBypassOnce.ButtonUp();
                this.buttonBypassRun.Mode = SmartButton.BUTTONMODE.NORMAL;
            }
            else
            {
                this.buttonBypassOnce.ButtonDown();
                this.buttonBypassRun.Mode = SmartButton.BUTTONMODE.PUSH;
            }

            // SubMenu
            this.panelSubMenu1.Visible = false;
            this.panelSubMenu2.Visible = false;
            this.SubmenuIndex = 0;

            // CUT 
            if (this.ParentForm.SystemConfig.IsCutView == true)
            {
                this.labelCutSignalInterval.Visible = true;
                this.buttonCut.Visible = true;
            }
            else
            {
                this.labelCutSignalInterval.Visible = false;
                this.buttonCut.Visible = false;
            }

            // Modbus Button
            this.UpdateDisplayModbusButton();

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();
          
            switch (this.ParentForm.SystemConfig.EquipmentColumns)
            {
                case 7:
                    if (this.MainDisplayEachBarGraph7 != null)
                        this.MainDisplayEachBarGraph7.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayDotGraph7 != null)
                        this.MainDisplayDotGraph7.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayTable7 != null)
                        this.MainDisplayTable7.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    break;
                case 8:
                    if (this.MainDisplayEachBarGraph8 != null)
                        this.MainDisplayEachBarGraph8.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayDotGraph8 != null)
                        this.MainDisplayDotGraph8.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayTable8 != null)
                        this.MainDisplayTable8.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    break;
                case 10:
                    if (this.MainDisplayEachBarGraph10 != null)
                        this.MainDisplayEachBarGraph10.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayDotGraph10 != null)
                        this.MainDisplayDotGraph10.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayTable10 != null)
                        this.MainDisplayTable10.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    break;
                case 12:
                    if (this.MainDisplayEachBarGraph12 != null)
                        this.MainDisplayEachBarGraph12.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayDotGraph12 != null)
                        this.MainDisplayDotGraph12.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayTable12 != null)
                        this.MainDisplayTable12.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    break;
                case 15:
                    if (this.MainDisplayEachBarGraph15 != null)
                        this.MainDisplayEachBarGraph15.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayDotGraph15 != null)
                        this.MainDisplayDotGraph15.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    if (this.MainDisplayTable15 != null)
                        this.MainDisplayTable15.UpdateBypassDisplay(this.ParentForm.CollectionWeightData);
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region Event Handler
        private void pictureBoxStart_Click(object sender, EventArgs e)
        {

        }
        private void pictureBoxStop_Click(object sender, EventArgs e)
        {

        }
        private void pictureBoxAlarm_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.MainDisplayAlarmList.Visible == true)
                this.MainDisplayAlarmList.Visible = false;
            else
            {
                this.MainDisplayAlarmList.BringToFront();
                this.MainDisplayAlarmList.Visible = true;
            }
        }

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

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.buttonProductNo.Text;

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

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 1000)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.ProductChange(myKeyPad.IntValue);

                    after = myKeyPad.StringValue;

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ProductNumber, "", before, after);
                }
            }
        }
        private void buttonUnder_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.buttonUnder.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonUnder.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue > Helper.StringToWeight(this.ParentForm.CurrentProductItem.PassRange, this.ParentForm.SystemConfig.DecimalPlaces))
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.ParentForm.CurrentProductItem.UnderRange = myKeyPad.StringValue.Replace(".", "");
                    this.buttonUnder.Text = myKeyPad.StringValue;
                    after = this.buttonUnder.Text;

                    this.RescaleControl();

                    this.ParentForm.SaveProductFile(this.ParentForm.CurrentProductItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits7(this.ParentForm.CurrentProductItem.UnderRange);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.UnderRange, value);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightUnderRange, "", before, after);

                    // Modbus
                    if (this.ParentForm.SystemConfig.IsModbusEnable == true)
                    {
                        this.ParentForm.Update30000ModbusData();
                        this.ParentForm.ModbusCommonDataSend();
                        
                        this.MainDisplayModbusCom.UpdateData(this.ParentForm.Current30000ModbusData);
                    }
                }
            }
        }
        private void buttonPass_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.buttonPass.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonPass.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if ((myKeyPad.doubleValue > Helper.StringToWeight(this.ParentForm.CurrentProductItem.OverRange, this.ParentForm.SystemConfig.DecimalPlaces))
                    || (myKeyPad.doubleValue < Helper.StringToWeight(this.ParentForm.CurrentProductItem.UnderRange, this.ParentForm.SystemConfig.DecimalPlaces)))
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.ParentForm.CurrentProductItem.PassRange = myKeyPad.StringValue.Replace(".", "");
                    this.buttonPass.Text = myKeyPad.StringValue;
                    after = this.buttonPass.Text;

                    this.RescaleControl();

                    this.ParentForm.SaveProductFile(this.ParentForm.CurrentProductItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits7(this.ParentForm.CurrentProductItem.PassRange);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.PassRange, value);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightPassRange, "", before, after);

                    // Modbus
                    if (this.ParentForm.SystemConfig.IsModbusEnable == true)
                    {
                        this.ParentForm.Update30000ModbusData();
                        this.ParentForm.ModbusCommonDataSend();
                        this.MainDisplayModbusCom.UpdateData(this.ParentForm.Current30000ModbusData);
                    }
                }
            }
        }
        private void buttonOver_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.buttonOver.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonOver.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < Helper.StringToWeight(this.ParentForm.CurrentProductItem.PassRange, this.ParentForm.SystemConfig.DecimalPlaces))
                {
                    this.ParentForm.Refresh();
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.ParentForm.CurrentProductItem.OverRange = myKeyPad.StringValue.Replace(".", "");
                    this.buttonOver.Text = myKeyPad.StringValue;
                    after = this.buttonOver.Text;

                    this.RescaleControl();

                    this.ParentForm.SaveProductFile(this.ParentForm.CurrentProductItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits7(this.ParentForm.CurrentProductItem.OverRange);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OverRange, value);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightOverRange, "", before, after);

                    // Modbus
                    if (this.ParentForm.SystemConfig.IsModbusEnable == true)
                    {
                        this.ParentForm.Update30000ModbusData();
                        this.ParentForm.ModbusCommonDataSend();
                        this.MainDisplayModbusCom.UpdateData(this.ParentForm.Current30000ModbusData);
                    }
                }
            }
        }
        private void buttonTare_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.buttonTare.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonTare.Text, 5, this.ParentForm.SystemConfig.DecimalPlaces, false, this.ParentForm.SystemConfig.Language);

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

                    this.ParentForm.SaveProductFile(this.ParentForm.CurrentProductItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits7(this.ParentForm.CurrentProductItem.TareRange);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.TareRange, value);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.WeightTareRange, "", before, after);

                    // Modbus
                    if (this.ParentForm.SystemConfig.IsModbusEnable == true)
                    {
                        this.ParentForm.Update30000ModbusData();
                        this.ParentForm.ModbusCommonDataSend();
                        this.MainDisplayModbusCom.UpdateData(this.ParentForm.Current30000ModbusData);
                    }
                }
            }
        }
        private void buttonClear_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 8);
            if (myDlg.ShowDialog() == DialogResult.Yes)
            {
                this.Clear();

                // Part 11
                if (this.ParentForm.SystemConfig.IsPart11 == true)
                    this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.Clear, "");
            }
        }
        private void buttonMenu_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.EquipmentStatus == DataStore.EquipmentStatus.Stop)
            {
                // Automatic Logout
                if (this.ParentForm.SystemConfig.IsPart11 == true)
                    UserManager.UserManager_AutoLogoutTimeoutPause();

                this.ParentForm.ChildFormMenu.DisplayRefresh();
                ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
            }
            else
            {
                // Automatic Logout Reset
                if (this.ParentForm.SystemConfig.IsPart11 == true)
                    this.Part11AutomaticLogoutReset();

                this.panelSetting.Visible = true;
            }
        }
        private void buttonDisplay_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button == this.buttonBarGraphForm)
                this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;
            else if (button == this.buttonDotGraphForm)
                this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayDotGraph;
            else if (button == this.buttonTableForm)
                this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayTable;
            else
                this.MainDisplay = DataStore.FormMainDisplayStore.FormMainDisplayBarGraph;

            this.UpdateDisplay(this.MainDisplay);
        }
        private void buttonZero_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoardAll);

            // Part 11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.Zero, "");
        }
        private void buttonClose_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.panelSetting.Visible = false;
        }
        private void buttonAlarm1Ok_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.panelAlarmMessageBox1.Visible = false;
        }
        private void buttonAlarm2OK_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.panelAlarmMessageBox2.Visible = false;
        }
        private void buttonAlarm3OK_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.panelAlarmMessageBox3.Visible = false;
        }
        private void buttonUp_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();
        }
        private void buttonDown_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();
        }
        private void buttonAllNG_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.ParentForm.TransferData(CommunicationCommand.NgSignal, CommunicationID.SubBoardAll);
        }
        private void buttonAllPass_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.ParentForm.TransferData(CommunicationCommand.PassSignal, CommunicationID.SubBoardAll);
        }
        private void buttonUser_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.ParentForm.SystemConfig.CurrentUser.Group == DataStore.UserGroup.LogOut)
            {
                this.Login();
            }
            else
            {
                DialogFormYesNo msg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 12);
                if (msg.ShowDialog() == DialogResult.Yes)
                {
                    this.Logout();
                }
            }
        }
        private void buttonBypassDirection_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.buttonBypassDirection.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.SystemConfig.IsBypassDirectionPass = false;
                before = "PASS";
                after = "NG";
            }
            else
            {
                this.ParentForm.SystemConfig.IsBypassDirectionPass = true;
                before = "NG";
                after = "PASS";
            }

            // Part 11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Direction, "", before, after);
        }
        private void buttonBypassOnce_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.buttonBypassOnce.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.SystemConfig.IsBypassOnce = false;
                this.buttonBypassRun.Mode = SmartButton.BUTTONMODE.PUSH;

                before = "Once";
                after = "Cotinue";
            }
            else
            {
                this.ParentForm.SystemConfig.IsBypassOnce = true;
                this.buttonBypassRun.Mode = SmartButton.BUTTONMODE.NORMAL;

                before = "Cotinue";
                after = "Once";
            }

            // Part 11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Mode, "", before, after);
        }
        private void buttonBypassRun_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.ParentForm.SystemConfig.IsBypassOnce == true)
            {
                if (this.ParentForm.SystemConfig.IsBypassDirectionPass == true)
                {
                    this.ParentForm.TransferData(CommunicationCommand.BypassOnce, CommunicationID.MainBoard);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.BP_PassOnce, "");
                }
                else
                {
                    this.ParentForm.TransferData(CommunicationCommand.ByNGOnce, CommunicationID.MainBoard);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.BP_NgOnce, "");
                }
            }
            else
            {
                if (this.buttonBypassRun.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    this.buttonBypassDirection.Enabled = false;
                    this.buttonBypassOnce.Enabled = false;

                    if (this.ParentForm.SystemConfig.IsBypassDirectionPass == true)
                    {
                        this.ParentForm.TransferData(CommunicationCommand.BypassON, CommunicationID.MainBoard);

                        // Part11
                        if (this.ParentForm.SystemConfig.IsPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.BP_PassON, "");
                    }
                    else
                    {
                        this.ParentForm.TransferData(CommunicationCommand.ByNGON, CommunicationID.MainBoard);

                        // Part11
                        if (this.ParentForm.SystemConfig.IsPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.BP_NgON, "");
                    }
                }
                else
                {
                    this.buttonBypassDirection.Enabled = true;
                    this.buttonBypassOnce.Enabled = true;

                    if (this.ParentForm.SystemConfig.IsBypassDirectionPass == true)
                    {
                        this.ParentForm.TransferData(CommunicationCommand.BypassOFF, CommunicationID.MainBoard);

                        // Part11
                        if (this.ParentForm.SystemConfig.IsPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.BP_PassOFF, "");
                    }
                    else
                    {
                        this.ParentForm.TransferData(CommunicationCommand.ByNGOFF, CommunicationID.MainBoard);

                        // Part11
                        if (this.ParentForm.SystemConfig.IsPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.BP_NgOFF, "");
                    }
                }
            }
        }
        private void buttonSubMenu_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.SubmenuIndex == 0)
            {
                this.panelSubMenu1.BringToFront();
                this.panelSubMenu1.Visible = true;

                this.panelSubMenu2.Visible = false;
                this.SubmenuIndex = 1;
            }
            else if (this.SubmenuIndex == 1)
            {
                this.panelSubMenu1.Visible = false;

                this.panelSubMenu2.BringToFront();
                this.panelSubMenu2.Visible = true;

                this.SubmenuIndex = 2;
            }
            else
            {
                this.panelSubMenu1.Visible = false;
                this.panelSubMenu2.Visible = false;

                this.SubmenuIndex = 0;
            }
        }

        private void labelSorter1DelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelSorter1DelayTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelSorter1DelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.Sorter1DelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter1DelayTime, "", before, after);
                }
            }
        }
        private void labelSorter1RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelSorter1RunTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelSorter1RunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.Sorter1RunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter1RunTime, "", before, after);
                }
            }
        }
        private void labelSorter2DelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelSorter2DelayTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelSorter2DelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.Sorter2DelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter2DelayTime, "", before, after);
                }
            }
        }
        private void labelSorter2RunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelSorter2RunTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelSorter2RunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.Sorter2RunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Sorter2RunTime, "", before, after);
                }
            }
        }
        private void labelRejectConveyorDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelRejectConveyorDelayTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelRejectConveyorDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.DischargeConveyorDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);
                    
                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.RejectCVDelayTime, number, before, after);
                }
            }
        }
        private void labelRejectConveyorRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelRejectConveyorRunTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelRejectConveyorRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.DischargeConveyorRunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.RejectCVRunTime, number, before, after);
                }
            }
        }
        private void labelFeedingConveyorDelayTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelFeedingConveyorDelayTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelFeedingConveyorDelayTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.FeedingConveyorDelayTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FeedingCVDelayTime, number, before, after);
                }
            }
        }
        private void labelFeedingConveyorRunTime_Click(object sender, EventArgs e)
        {
            string value = "", before = "", after = "", number = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelFeedingConveyorRunTime.Text;
            number = this.ParentForm.SystemConfig.ProductNumber.ToString();

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

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

                    value = Helper.StringZeroFillDigits4(this.labelFeedingConveyorRunTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.FeedingConveyorRunTime, value);
                    this.ParentForm.SaveJudgmentSetFile(this.ParentForm.CurrentJudgmentSetItem, this.ParentForm.SystemConfig.ProductNumber - 1);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.FeedingCVRunTime, number, before, after);
                }
            }
        }
        private void labelTotalCount_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                if (this.labelTitleTotalCount.Text != "计数")
                    this.labelTitleTotalCount.Text = "计数";
                else
                    this.labelTitleTotalCount.Text = "通过";
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
                if (this.labelTitleTotalCount.Text != "Celkem")
                    this.labelTitleTotalCount.Text = "Celkem";
                else
                    this.labelTitleTotalCount.Text = "Váha";
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                if (this.labelTitleTotalCount.Text != "Insgesamt")
                    this.labelTitleTotalCount.Text = "Insgesamt";
                else
                    this.labelTitleTotalCount.Text = "Bestehen";
            }
            else
            {
                if (this.labelTitleTotalCount.Text != "Total")
                    this.labelTitleTotalCount.Text = "Total";
                else
                    this.labelTitleTotalCount.Text = "Pass";
            }

            this.SetTotalCount();
        }

        private void timerTimeout_Tick(object sender, EventArgs e)
        {
            this.labelTimeroutCount.Visible = true;
            this.labelTimeroutCount.Text = this.FlagTimeoutCount.ToString();
            this.ParentForm.TransferProductParameter(this.ParentForm.SystemConfig.ProductNumber);

            this.FlagTimeoutCount++;
        }

        private void labelCutSignalInterval_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

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

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelCutSignalInterval.Text = myKeyPad.StringValue;
                    this.timerCutSignalInterval.Interval = myKeyPad.IntValue;
                }
            }
        }
        private void buttonCut_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.buttonCut.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.timerCutSignalInterval.Enabled = true;
            else
                this.timerCutSignalInterval.Enabled = false;
        }
        private void timerCutSignalInterval_Tick(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.ParentForm.TransferData(CommunicationCommand.CutInpupt, CommunicationID.MainBoard);
        }

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

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.buttonAlarmContinuousNG.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable = true;
                before = "OFF";
                after = "ON";
            }
            else
            {
                this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable = false;
                before = "ON";
                after = "OFF";
            }

            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ACNC_Activate, "", before, after);
        }
        private void labelAlarmContinuousNG_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelAlarmContinuousNG.Text;

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

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

                    // 연속 NG 수량 Clear
                    for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                    {
                        this.ParentForm.CollectionWeightData[i].ContinuousNG = 0;
                        this.ParentForm.CollectionWeightData[i].IsContinuousNG = false;
                    }

                    this.ParentForm.SystemConfig.AlarmContinuousNG = myKeyPad.IntValue;
                    this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ACNC_Count, "", before, after);
                }
            }
        }


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

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            before = this.labelATPC_SetCNT.Text;

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

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 20 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelATPC_SetCNT.Text = myKeyPad.StringValue;
                    this.ParentForm.CurrentAlarmTotalPassCnt.SettingCount = myKeyPad.IntValue;
                    after = this.labelATPC_SetCNT.Text;

                    this.ParentForm.SystemConfig.AlarmTotalPassCnt = myKeyPad.IntValue;
                    this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
                    this.ClearAlarmTotalPassCount();

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ATPC_Count, "", before, after);
                }
            }
        }
        private void buttonAlarmTotalCount_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            if (this.buttonATPC_Enable.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable = true;

                before = "OFF";
                after = "ON";
            }
            else
            {
                this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable = false;

                before = "ON";
                after = "OFF";
            }

            this.ClearAlarmTotalPassCount();
            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ATPC_Activate, "", before, after);
        }
        private void labelATPC_counting_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            // Clear Alarm Total Pass Count
            this.ClearAlarmTotalPassCount();

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.ATPC_Reset, "");
        }
        private void buttonATPC_Reset_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            // Clear Alarm Total Pass Count
            this.ClearAlarmTotalPassCount();

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.ATPC_Reset, "");
        }

        private void buttonModbus_Click(object sender, EventArgs e)
        {
            // Automatic Logout Reset
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.Part11AutomaticLogoutReset();

            this.UpdateModbusDisplay(DataStore.E_ModbusDisplay.Common);
        }
        #endregion

        private void buttonExit_Click(object sender, EventArgs e)
        {
            this.ParentForm.ProgramClose();
        }

        private void timerServer_Tick(object sender, EventArgs e)
        {

        }
    }
}