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

using SmartX;
using ITC81DB_2.Forms;
using ITC81DB_2.DialogForms;
using ITC81DB_2_ImageDll;

namespace ITC81DB_2.Controls
{
    public partial class ControlCenterEquipInitialize : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        private Define.E_Step3 InitializeStep;
        private SmartSplash splash;

        private string PathRemoveFolder = "";
        private int FlagTimeout;
        #endregion

        #region Constructor
        public ControlCenterEquipInitialize(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
        }
        #endregion

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

        #region Method
        public void InitializeDesign()
        {
            Class1 images = new Class1();

            if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.English)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Chinese)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
            }
            else
            {
            }
        }
        private void DefaultSetting()
        {
            this.FlagTimeout = 0;
            this.timer.Interval = 500;
            this.progressBarInitialize.Value = 0;
            this.PathRemoveFolder = this.ParentForm.ParentForm.PathLaunchFolder + "RemoveSystemFile2\\";

            this.InitializeStep = Define.E_Step3.Step1;
            this.UpdateLabelStatus(this.InitializeStep, this.ParentForm.ParentForm.SystemConfig.Language);
        }

        private void TransmissionRemoveFile()
        {
            bool removeFolderCheck = false;
            FileInfo[] oldFiles, removeOldFiles;
            DirectoryInfo directoryFolderSystem2 = new DirectoryInfo(this.ParentForm.ParentForm.PathSystemFileFolder2);
            DirectoryInfo directoryFolderRemove = new DirectoryInfo(this.PathRemoveFolder);

            removeFolderCheck = directoryFolderRemove.Exists;
            oldFiles = directoryFolderSystem2.GetFiles();

            if (removeFolderCheck == false)
                directoryFolderRemove.Create();
            else
            {
                removeOldFiles = directoryFolderRemove.GetFiles();

                foreach (FileInfo subFile in removeOldFiles)
                    subFile.Delete();
            }

            foreach (FileInfo subFile in oldFiles)
                subFile.MoveTo(this.PathRemoveFolder + DateTime.Now.ToString("yyyyMMddHHmmss") + subFile.Name.ToString());
        }
        private void ResetProductFile1()
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structItem;

            fullFilePath = this.ParentForm.ParentForm.PathSystemFileFolder2 + "ProductItem1.int";
            this.ParentForm.ParentForm.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            this.ParentForm.ParentForm.CurrentProductItem1.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Number = i + 1;
                structItem.Name = string.Format("Product {0}", i + 1);
                structItem.LotNo = string.Format("Lot {0}", i + 1);
                structItem.OverRange = this.ParentForm.ParentForm.CurrentProductItem1.OverRange;
                structItem.PassRange = this.ParentForm.ParentForm.CurrentProductItem1.PassRange;
                structItem.UnderRange = this.ParentForm.ParentForm.CurrentProductItem1.UnderRange;
                structItem.TareRange = this.ParentForm.ParentForm.CurrentProductItem1.TareRange;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";

                this.ParentForm.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);

                if (i % 100 == 0)
                    this.progressBarInitialize.Value += 1;
            }
            this.ParentForm.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.ParentForm.smartFileIO.Close();
        }
        private void ResetProductFile2()
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructProductItem structItem;

            fullFilePath = this.ParentForm.ParentForm.PathSystemFileFolder2 + "ProductItem2.int";
            this.ParentForm.ParentForm.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            this.ParentForm.ParentForm.CurrentProductItem2.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Number = i + 1;
                structItem.Name = string.Format("Product {0}", i + 1);
                structItem.LotNo = string.Format("Lot {0}", i + 1);
                structItem.OverRange = this.ParentForm.ParentForm.CurrentProductItem2.OverRange;
                structItem.PassRange = this.ParentForm.ParentForm.CurrentProductItem2.PassRange;
                structItem.UnderRange = this.ParentForm.ParentForm.CurrentProductItem2.UnderRange;
                structItem.TareRange = this.ParentForm.ParentForm.CurrentProductItem2.TareRange;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";

                this.ParentForm.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);

                if (i % 100 == 0)
                    this.progressBarInitialize.Value += 1;
            }
            this.ParentForm.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.ParentForm.smartFileIO.Close();
        }
        private void ResetJudgmentSetFile1()
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructJudgmentSetItem structItem;

            fullFilePath = this.ParentForm.ParentForm.PathSystemFileFolder2 + "JudgmentSetItem1.int";
            this.ParentForm.ParentForm.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Filter;
                structItem.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DoubleDelayTime;
                structItem.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.JudgmentCount;
                structItem.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed1;
                structItem.FeedSpeed2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed2;
                structItem.FeedSpeed3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.FeedSpeed3;
                structItem.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.DynamicCorrection;

                structItem.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode;
                structItem.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime;
                structItem.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime;
                structItem.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode;
                structItem.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2DelayTime;
                structItem.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2RunTime;

                structItem.AutoJudgmentLength = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgmentLength;
                structItem.AutoJudgment1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgment1;
                structItem.AutoJudgment2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgment2;
                structItem.AutoJudgment3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem1.AutoJudgment3;

                structItem.DescendDelayTime = 0;
                structItem.AscendDelayTime = 0;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";

                this.ParentForm.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);

                if (i % 100 == 0)
                    this.progressBarInitialize.Value += 1;
            }
            this.ParentForm.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.ParentForm.smartFileIO.Close();
        }
        private void ResetJudgmentSetFile2()
        {
            bool fileCheck = false;
            string fullFilePath = "";
            StructJudgmentSetItem structItem;

            fullFilePath = this.ParentForm.ParentForm.PathSystemFileFolder2 + "JudgmentSetItem2.int";
            this.ParentForm.ParentForm.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Initialization();

            for (int i = 0; i < 1000; i++)
            {
                structItem.Filter = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Filter;
                structItem.JudgmentDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentDelayTime;
                structItem.DoubleDelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DoubleDelayTime;
                structItem.JudgmentCount = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.JudgmentCount;
                structItem.FeedSpeed1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed1;
                structItem.FeedSpeed2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed2;
                structItem.FeedSpeed3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.FeedSpeed3;
                structItem.DynamicCorrection = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.DynamicCorrection;

                structItem.Sorter1Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1Mode;
                structItem.Sorter1DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime;
                structItem.Sorter1RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime;
                structItem.Sorter2Mode = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2Mode;
                structItem.Sorter2DelayTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2DelayTime;
                structItem.Sorter2RunTime = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter2RunTime;

                structItem.AutoJudgmentLength = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgmentLength;
                structItem.AutoJudgment1 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgment1;
                structItem.AutoJudgment2 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgment2;
                structItem.AutoJudgment3 = this.ParentForm.ParentForm.CurrentJudgmentSetItem2.AutoJudgment3;

                structItem.DescendDelayTime = 0;
                structItem.AscendDelayTime = 0;
                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyString1 = "";
                structItem.DummyString2 = "";
                structItem.DummyString3 = "";
                structItem.DummyString4 = "";
                structItem.DummyString5 = "";

                this.ParentForm.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);

                if (i % 100 == 0)
                    this.progressBarInitialize.Value += 1;
            }
            this.ParentForm.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.ParentForm.smartFileIO.Close();
        }
        private void ResetCountFile1()
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounterItem structItem;
            WeightData item = new WeightData();

            fullFilePath = this.ParentForm.ParentForm.PathSystemFileFolder2 + "counterItem1.int";
            this.ParentForm.ParentForm.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            item.ClearCount();

            for (int i = 0; i < 1000; i++)
            {
                structItem.OverCount = item.OverCount;
                structItem.OverSumWeight = item.OverSumWeight;
                structItem.PassCount = item.PassCount;
                structItem.PassSumWeight = item.PassSumWeight;
                structItem.UnderCount = item.UnderCount;
                structItem.UnderSumWeight = item.UnderSumWeight;
                structItem.ExNGCount = item.ETCExNGCount;

                structItem.NormalDistribution1 = item.CollectionNormalDistributionCount[0];
                structItem.NormalDistribution2 = item.CollectionNormalDistributionCount[1];
                structItem.NormalDistribution3 = item.CollectionNormalDistributionCount[2];
                structItem.NormalDistribution4 = item.CollectionNormalDistributionCount[3];
                structItem.NormalDistribution5 = item.CollectionNormalDistributionCount[4];
                structItem.NormalDistribution6 = item.CollectionNormalDistributionCount[5];
                structItem.NormalDistribution7 = item.CollectionNormalDistributionCount[6];
                structItem.NormalDistribution8 = item.CollectionNormalDistributionCount[7];
                structItem.NormalDistribution9 = item.CollectionNormalDistributionCount[8];
                structItem.NormalDistribution10 = item.CollectionNormalDistributionCount[9];

                structItem.StartTime = item.StartTime;
                structItem.StopTime = item.StopTime;

                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.DummyInt5 = 0;

                this.ParentForm.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);

                if (i % 100 == 0)
                    this.progressBarInitialize.Value += 1;
            }
            this.ParentForm.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.ParentForm.smartFileIO.Close();
        }
        private void ResetCountFile2()
        {
            string fullFilePath = "";
            bool fileCheck = false;
            StructCounterItem structItem;
            WeightData item = new WeightData();

            fullFilePath = this.ParentForm.ParentForm.PathSystemFileFolder2 + "counterItem2.int";
            this.ParentForm.ParentForm.smartFileIO.FilePathName = fullFilePath;

            FileInfo fileInfo = new FileInfo(fullFilePath);
            fileCheck = fileInfo.Exists;

            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            item.ClearCount();

            for (int i = 0; i < 1000; i++)
            {
                structItem.OverCount = item.OverCount;
                structItem.OverSumWeight = item.OverSumWeight;
                structItem.PassCount = item.PassCount;
                structItem.PassSumWeight = item.PassSumWeight;
                structItem.UnderCount = item.UnderCount;
                structItem.UnderSumWeight = item.UnderSumWeight;
                structItem.ExNGCount = item.ETCExNGCount;

                structItem.NormalDistribution1 = item.CollectionNormalDistributionCount[0];
                structItem.NormalDistribution2 = item.CollectionNormalDistributionCount[1];
                structItem.NormalDistribution3 = item.CollectionNormalDistributionCount[2];
                structItem.NormalDistribution4 = item.CollectionNormalDistributionCount[3];
                structItem.NormalDistribution5 = item.CollectionNormalDistributionCount[4];
                structItem.NormalDistribution6 = item.CollectionNormalDistributionCount[5];
                structItem.NormalDistribution7 = item.CollectionNormalDistributionCount[6];
                structItem.NormalDistribution8 = item.CollectionNormalDistributionCount[7];
                structItem.NormalDistribution9 = item.CollectionNormalDistributionCount[8];
                structItem.NormalDistribution10 = item.CollectionNormalDistributionCount[9];

                structItem.StartTime = item.StartTime;
                structItem.StopTime = item.StopTime;

                structItem.DummyInt1 = 0;
                structItem.DummyInt2 = 0;
                structItem.DummyInt3 = 0;
                structItem.DummyInt4 = 0;
                structItem.DummyInt5 = 0;

                this.ParentForm.ParentForm.smartFileIO.WriteStructure_Begin(structItem, i);

                if (i % 100 == 0)
                    this.progressBarInitialize.Value += 1;
            }
            this.ParentForm.ParentForm.smartFileIO.WriteStructure_End();
            this.ParentForm.ParentForm.smartFileIO.Close();
        }

        private void InitializeMainBoard(DialogResult result)
        {
            if (result == DialogResult.Yes)
            {
                this.splash = new SmartX.SmartSplash();
                this.splash.CenterPosition = false;
                this.splash.AnimationInterval = 100;
                this.splash.LoadingImagePathname = "SmartLoading3";
                this.splash.Left = 300;
                this.splash.Top = 230;
                this.splash.Start();

                this.timer.Enabled = true;
                this.progressBarInitialize.Value = 0;

                this.InitializeStep = Define.E_Step3.Step2;
                this.UpdateLabelStatus(this.InitializeStep, this.ParentForm.ParentForm.SystemConfig.Language);

                this.ParentForm.ParentForm.TransferData(CommunicationCommand.Initialization, CommunicationID.MainBoard);
            }
        }
        private void InitializeLcd(DialogResult result)
        {
            if (result == DialogResult.Yes)
            {
                this.splash = new SmartX.SmartSplash();
                this.splash.CenterPosition = false;
                this.splash.AnimationInterval = 100;
                this.splash.LoadingImagePathname = "SmartLoading3";
                this.splash.Left = 300;
                this.splash.Top = 230;
                this.splash.Start();

                this.InitializeStep = Define.E_Step3.Step2;
                this.UpdateLabelStatus(this.InitializeStep, this.ParentForm.ParentForm.SystemConfig.Language);

                this.ParentForm.ParentForm.CloseSmartUartLink();
                this.progressBarInitialize.Value = 0;
                this.TransmissionRemoveFile();
                this.progressBarInitialize.Value += 5;
                this.ResetProductFile1();
                this.progressBarInitialize.Value += 5;
                this.ResetProductFile2();
                this.progressBarInitialize.Value += 5;
                this.ResetJudgmentSetFile1();
                this.progressBarInitialize.Value += 5;
                this.ResetJudgmentSetFile2();
                this.progressBarInitialize.Value += 5;
                this.ResetCountFile1();
                this.progressBarInitialize.Value += 5;
                this.ResetCountFile2();
                this.progressBarInitialize.Value = 100;
                this.ParentForm.ParentForm.OpenSmartUartLink();

                this.splash.Finish();

                this.InitializeStep = Define.E_Step3.Step3;
                this.UpdateLabelStatus(this.InitializeStep, this.ParentForm.ParentForm.SystemConfig.Language);

                this.ParentForm.Enabled = false;
            }
        }
        private void InitializeMainBoardLcd(DialogResult result)
        {
            if (result == DialogResult.Yes)
            {
                this.splash = new SmartX.SmartSplash();
                this.splash.CenterPosition = false;
                this.splash.AnimationInterval = 100;
                this.splash.LoadingImagePathname = "SmartLoading3";
                this.splash.Left = 300;
                this.splash.Top = 230;
                this.splash.Start();

                this.InitializeStep = Define.E_Step3.Step2;
                this.UpdateLabelStatus(this.InitializeStep, this.ParentForm.ParentForm.SystemConfig.Language);

                this.ParentForm.ParentForm.CloseSmartUartLink();
                this.progressBarInitialize.Value = 0;
                this.TransmissionRemoveFile();
                this.ResetProductFile1();
                this.ResetProductFile2();
                this.progressBarInitialize.Value += 10;
                this.ResetJudgmentSetFile1();
                this.ResetJudgmentSetFile2();
                this.progressBarInitialize.Value += 10;
                this.ResetCountFile1();
                this.ResetCountFile2();
                this.progressBarInitialize.Value += 10;
                this.ParentForm.ParentForm.OpenSmartUartLink();

                this.timer.Enabled = true;
                this.ParentForm.ParentForm.TransferData(CommunicationCommand.Initialization, CommunicationID.MainBoard);
            }
        }

        private void UpdateLabelStatus(Define.E_Step3 step, Define.E_LanguageID language)
        {
            switch (step)
            {
                case Define.E_Step3.Step1:
                    #region Step1
                    switch (language)
                    {
                        case Define.E_LanguageID.Korean:
                            this.labelMessage1.Text = "초기화를 원하는 항목을 선택해주십시오";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.English:
                            this.labelMessage1.Text = "Please select the item you want to initialize";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.Chinese:
                            this.labelMessage1.Text = "请选择要初始化的项目";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.Spanish:
                            this.labelMessage1.Text = "Por favor, seleccione el elemento que desea inicializar";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.Czech:
                            break;
                        default:
                            break;
                    }
                    #endregion
                    break;
                case Define.E_Step3.Step2:
                    #region Step2
                    switch (language)
                    {
                        case Define.E_LanguageID.Korean:
                            this.labelMessage1.Text = "초기화 중...";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.English:
                            this.labelMessage1.Text = "Initializing...";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.Chinese:
                            this.labelMessage1.Text = "初期化进行中...";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.Spanish:
                            this.labelMessage1.Text = "Inicializando...";
                            this.labelMessage2.Text = "";
                            break;
                        case Define.E_LanguageID.Czech:
                            break;
                        default:
                            break;
                    }
                    #endregion
                    break;
                case Define.E_Step3.Step3:
                    #region Step3
                    switch (language)
                    {
                        case Define.E_LanguageID.Korean:
                            this.labelMessage1.Text = "초기화 완료";
                            this.labelMessage2.Text = "전원을 끄고 다시 켜주세요.";
                            break;
                        case Define.E_LanguageID.English:
                            this.labelMessage1.Text = "Initialization complete";
                            this.labelMessage2.Text = "Reset the power.";
                            break;
                        case Define.E_LanguageID.Chinese:
                            this.labelMessage1.Text = "初始化完成";
                            this.labelMessage2.Text = "关掉电源，然后在打开电源";
                            break;
                        case Define.E_LanguageID.Spanish:
                            this.labelMessage1.Text = "Inicialización completa. Apague la alimentación";
                            this.labelMessage2.Text = "y luego encienda la alimentación.";
                            break;
                        case Define.E_LanguageID.Czech:
                            break;
                        default:
                            break;
                    }
                    #endregion
                    break;
                default:
                    break;
            }

            this.Refresh();
        }
        public void UpdateDisplayMainBoardInitialization()
        {
            this.timer.Enabled = false;
            this.splash.Finish();

            this.progressBarInitialize.Value = 100;

            this.InitializeStep = Define.E_Step3.Step3;
            this.UpdateLabelStatus(this.InitializeStep, this.ParentForm.ParentForm.SystemConfig.Language);

            this.ParentForm.Enabled = false;
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.EquipInitialize;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.DefaultSetting();

            if (status.CurrentUser.Group == Define.E_UserGroup.Developer && this.ParentForm.ParentForm.SystemConfig.IsLogin == true)
            {
                this.buttonBackup.Visible = true;
            }
            else
            {
                this.buttonBackup.Visible = false;
            }
        }
        #endregion

        #region Event Handler
        private void buttonBackup_Click(object sender, EventArgs e)
        {
            bool directoryCheck = false;
            string filePathSystemFileBackup = "", filePathSystemFile = "";
            FileInfo[] files;

            filePathSystemFile = this.ParentForm.ParentForm.PathSystemFileFolder1;
            filePathSystemFileBackup = this.ParentForm.ParentForm.PathSystemFileBackupFolder;

            DirectoryInfo dirSystemFileFolder = new DirectoryInfo(filePathSystemFile);
            DirectoryInfo dirSystemFileBackupFolder = new DirectoryInfo(filePathSystemFileBackup);

            // SystemFileBackup 폴더 체크
            directoryCheck = dirSystemFileBackupFolder.Exists;
            if (directoryCheck == false)
                dirSystemFileBackupFolder.Create();
            else
            {
                files = dirSystemFileBackupFolder.GetFiles();

                foreach (FileInfo file in files)
                    file.Delete();
            }

            files = dirSystemFileFolder.GetFiles();

            foreach (FileInfo file in files)
            {
                file.CopyTo(filePathSystemFileBackup + file.Name, true);
            }
        }
        private void buttonMainBoardLcd_Click(object sender, EventArgs e)
        {
            // 설정된 모든 데이터가 초기화됩니다.
            DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig.Language, 5);
            DialogResult dr = myDlg.ShowDialog();
            myDlg.Close();
            
            this.Refresh();
            this.InitializeMainBoardLcd(dr);
        }
        private void buttonMainBoard_Click(object sender, EventArgs e)
        {
            // 메인보드에 설정된 데이터가 초기화됩니다.
            DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig.Language, 7);
            DialogResult dr = myDlg.ShowDialog();
            myDlg.Close();

            this.Refresh();
            this.InitializeMainBoard(dr);
        }
        private void buttonLcd_Click(object sender, EventArgs e)
        {
            // LCD에 설정된 데이터가 초기화됩니다.
            DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig.Language, 6);
            DialogResult dr = myDlg.ShowDialog();
            myDlg.Close();

            this.Refresh();
            this.InitializeLcd(dr);
        }    

        private void timer_Tick(object sender, EventArgs e)
        {
            this.FlagTimeout++;
            if (this.FlagTimeout == 10)
            {
                this.timer.Enabled = false;
                this.splash.Finish();

                // 메인보드 통신 상태 확인해주세요
                DialogFormMessage message = new DialogFormMessage(22, this.ParentForm.ParentForm.SystemConfig.Language);
                message.ShowDialog();
                this.ParentForm.Enabled = false;
            }

            this.progressBarInitialize.Value += 2;
        }
        #endregion
    }
}
