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

using INT51DB.Controls;
using INT51DB.DialogForms;
using INT51DB_ImageDll;
using SmartX;

namespace INT51DB.Forms
{
    public partial class FormMainDisplay : Form
    {
        #region Field
        private FormMain m_ParentForm;

        private DataStore.MainDisplayStore CurrentDisplay;
        private ControlMainDisplayStatistics MainDisplayStatistics;
        private ControlMainDisplayBarGraph MainDisplayBarGraph;
        private ControlMainDisplayLineGraph MainDisplayLineGraph;
        private ControlMainDisplayList MainDisplayList;
        public ControlMainDisplayMenu MainDisplayMenu;
        private ControlMainDisplayAlarm MainDisplayAlarm;
        private ControlMainDisplayFunction1 MainDisplayFunction1;
        public ControlMainDisplayFunction2 MainDisplayFunction2;
        #endregion

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

            this.ParentForm = parent;

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

        #region Property
        public FormMain 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.SystemConfig.Language == DataStore.LanguageID.English)
            {
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
            }
            else
            {
            }
        }
        private void InitializeControl()
        {
            this.MainDisplayStatistics = new ControlMainDisplayStatistics(this);
            this.MainDisplayBarGraph = new ControlMainDisplayBarGraph(this);
            this.MainDisplayLineGraph = new ControlMainDisplayLineGraph(this);
            this.MainDisplayList = new ControlMainDisplayList(this);
            this.MainDisplayMenu = new ControlMainDisplayMenu(this);
            this.MainDisplayAlarm = new ControlMainDisplayAlarm();
            this.MainDisplayFunction1 = new ControlMainDisplayFunction1(this);
            this.MainDisplayFunction2 = new ControlMainDisplayFunction2(this);

            this.MainDisplayStatistics.Location = new Point(0, 313);
            this.MainDisplayBarGraph.Location = new Point(0, 313);
            this.MainDisplayLineGraph.Location = new Point(0, 313);
            this.MainDisplayList.Location = new Point(0, 313);
            this.MainDisplayMenu.Location = new Point(0, 313);
            this.MainDisplayAlarm.Location = new Point(390, 60);
            this.MainDisplayFunction1.Location = new Point(0, 313);
            this.MainDisplayFunction2.Location = new Point(0, 313);

            this.Controls.Add(this.MainDisplayStatistics);
            this.Controls.Add(this.MainDisplayBarGraph);
            this.Controls.Add(this.MainDisplayLineGraph);
            this.Controls.Add(this.MainDisplayList);
            this.Controls.Add(this.MainDisplayMenu);
            this.Controls.Add(this.MainDisplayAlarm);
            this.Controls.Add(this.MainDisplayFunction1);
            this.Controls.Add(this.MainDisplayFunction2);
        }
        private void DefaultSetting()
        {
            if (this.ParentForm.IsBootingComplete == false)
                this.buttonProductNo.Text = "**";
            else
                this.buttonProductNo.Text = this.ParentForm.SystemConfig.ProductNumber.ToString();

            this.labelWeight.Text = "0.0";
            this.labelPassAlarmCount.Text = "0";

            this.pictureBoxStop.Visible = true;
            this.pictureBoxStart.Visible = false;

            this.InitializeControl();

            // 아이콘, 단위 등 화면 갱신
            this.UpdateDisplay();

            // 알람 표시
            this.pictureBoxIconAlarm.Visible = false;
            this.MainDisplayAlarm.Visible = false;
            this.MainDisplayAlarm.BringToFront();

            //this.UpdateDisplayUser(this.ParentForm.CurrentSystemStatus);

            // Ver 1.5.0
            this.MainDisplayFunction2.Visible = false;

            this.CurrentDisplay = DataStore.MainDisplayStore.BarGraph;
            this.MainDisplayBarGraph.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
            this.MainDisplayBarGraph.BringToFront();
            this.DisplayBottomMain(this.CurrentDisplay);
        }
        private void UpdateDisplay()
        {
            // Icon - 데이터 백업
            if (this.ParentForm.SystemConfig.IsDataBackup == true)
            {
                this.pictureBoxIconUsbEnable.Visible = true;
                this.pictureBoxIconUsbDesable.Visible = false;
            }
            else
            {
                this.pictureBoxIconUsbEnable.Visible = false;
                this.pictureBoxIconUsbDesable.Visible = true;
            }

            // 단위
            if (this.labelUnit.Text != this.ParentForm.SystemConfig.Unit)
                this.labelUnit.Text = this.ParentForm.SystemConfig.Unit;

            // Icon - Ch2
            if (this.ParentForm.SystemConfig.COM3Mode == 0)
                this.pictureBoxCh2.Visible = false;
            else
                this.pictureBoxCh2.Visible = true;

            // Icon - Ch3
            if (this.ParentForm.CurrentSystemParameter1.Serial1Mode == "0")
                this.pictureBoxCh3.Visible = false;
            else
                this.pictureBoxCh3.Visible = true;

            // Icon - Communication Log
            if (this.ParentForm.IsCommunicationLogOpen == false)
                this.labelIconLog.Visible = false;
            else
                this.labelIconLog.Visible = true;
        }

        private void UpdateDisplayAlarmView(WeightData data)
        {
            // 입력 센서 에러
            if (data.IsEntrySensor1Error == true || data.IsEntrySensor2Error == true)
                this.pictureBoxEntrySensorStatus.Visible = true;
            else
                this.pictureBoxEntrySensorStatus.Visible = false;

            // 배출 센서 에러
            if (data.IsDrainSensorError == true)
                this.pictureBoxDrainSensorStatus.Visible = true;
            else
                this.pictureBoxDrainSensorStatus.Visible = false;

            if (data.IsServoOff == true || data.IsServoAlarm == true || data.IsLoadCellError == true || data.IsInverterError == true
                || data.IsServoTorqueError == true)
            {
                if (this.pictureBoxIconAlarm.Visible == false)
                    this.pictureBoxIconAlarm.Visible = true;
            }
            else
            {
                this.pictureBoxIconAlarm.Visible = false;
                this.MainDisplayAlarm.Visible = false;
                return;
            }

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

            if (data.IsServoOff == true)
                this.MainDisplayAlarm.listBoxMessage.Items.Add("Servo Off");
            if (data.IsServoAlarm == true)
                this.MainDisplayAlarm.listBoxMessage.Items.Add("Servo Alarm");
            if (data.IsServoTorqueError == true)
                this.MainDisplayAlarm.listBoxMessage.Items.Add("Servo Torque");
            if (data.IsLoadCellError == true)
                this.MainDisplayAlarm.listBoxMessage.Items.Add("LoadCell Error");
            if (data.IsInverterError == true)
                this.MainDisplayAlarm.listBoxMessage.Items.Add("Inverter Error");
        }
        private void ProductChange(int productNumber)
        {
            this.buttonProductNo.Text = "**";

            this.ParentForm.TransferProductParameter(productNumber);
        }
        public void RescaleControl()
        {
            this.MainDisplayBarGraph.RescaleProgressBar();
        }
        public void Clear()
        {
            this.ParentForm.CurrentWeightData.ClearCount();
            this.ParentForm.SaveCounterFile(this.ParentForm.CurrentWeightData, this.ParentForm.SystemConfig.ProductNumber - 1);

            if (this.MainDisplayBarGraph != null)
                this.MainDisplayBarGraph.Clear();

            if (this.MainDisplayLineGraph != null)
                this.MainDisplayLineGraph.Clear();

            if (this.MainDisplayList != null)
                this.MainDisplayList.Clear();

            if (this.MainDisplayStatistics != null)
                this.MainDisplayStatistics.Clear();
        }
        public void SetIconNET(ProductItem item)
        {
            double dValue = 0.0;

            dValue = Helper.StringToWeight(item.TareRange, this.ParentForm.SystemConfig.DecimalPlaces);
            if (dValue != 0.0)
                this.labelIconNET.Visible = true;
            else
                this.labelIconNET.Visible = false;
        }
        public void VisibleMenuButton(bool visible)
        {
            this.buttonMenu.Visible = visible;
        }

        private void UpdateDisplayUser(SystemStatus status)
        {
            string value = "";

            switch (status.CurrentUser.Group)
            {
                case DataStore.UserGroup.LogOff:
                    value = "Off";
                    if (this.labelUserLevel.Text != value)
                        this.labelUserLevel.Text = value;
                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOff)
                        this.labelUserLevel.ForeColor = this.ParentForm.ColorLogOff;

                    this.buttonProductNo.Enabled = false;
                    this.buttonClear.Enabled = false;
                    this.buttonMenu.Enabled = false;
                    break;
                case DataStore.UserGroup.Level1Operator:
                    value = "L1";
                    if (this.labelUserLevel.Text != value)
                        this.labelUserLevel.Text = value;
                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonProductNo.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Level2Engineer:
                    value = "L2";
                    if (this.labelUserLevel.Text != value)
                        this.labelUserLevel.Text = value;
                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonProductNo.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Level3Manager:
                    value = "L3";
                    if (this.labelUserLevel.Text != value)
                        this.labelUserLevel.Text = value;
                    if (this.labelUserLevel.ForeColor != this.ParentForm.ColorLogOn)
                        this.labelUserLevel.ForeColor = this.ParentForm.ColorLogOn;

                    this.buttonProductNo.Enabled = true;
                    this.buttonClear.Enabled = true;
                    this.buttonMenu.Enabled = true;
                    break;
                case DataStore.UserGroup.Level4Developer:
                    break;
                default:
                    break;
            }
        }
        public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
        {
            if (status == DataStore.EquipmentStatus.Start)
            {
                this.pictureBoxStart.Visible = true;
                this.pictureBoxStop.Visible = false;
                this.buttonProductNo.Enabled = false;
                this.MainDisplayFunction2.Visible = false;
                this.labelWeight.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.SystemConfig.DecimalPlaces);

                this.MainDisplayBarGraph.UpdateEquipmentStatusDisplay(status);
                this.MainDisplayLineGraph.UpdateEquipmentStatusDisplay(status);
                this.MainDisplayList.UpdateEquipmentStatusDisplay(status);
            }
            else
            {
                // V5.0.2
                this.labelPassAlarmCount.Text = "0";

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

                this.MainDisplayBarGraph.UpdateEquipmentStatusDisplay(status);
                this.MainDisplayLineGraph.UpdateEquipmentStatusDisplay(status);
                this.MainDisplayList.UpdateEquipmentStatusDisplay(status);
            }
        }
        public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, ProductItem pItem, WeightData wData)
        {
            string value = "";

            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;

            this.SetIconNET(pItem);

            if (this.MainDisplayBarGraph != null)
                this.MainDisplayBarGraph.UpdateCurrentProductDisplay(status, pItem, wData);
            if (this.MainDisplayLineGraph != null)
                this.MainDisplayLineGraph.UpdateCurrentProductDisplay(status, pItem, wData);
            if (this.MainDisplayList != null)
                this.MainDisplayList.UpdateCurrentProductDisplay(status, pItem, wData);
            if (this.MainDisplayStatistics != null)
                this.MainDisplayStatistics.UpdateCurrentProductDisplay(status, pItem, wData);
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, WeightData data)
        {
            string value = "";

            if (status == DataStore.EquipmentStatus.Stop)
            {
                // 중량
                value = Helper.DoubleToString(data.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeight.Text != value)
                    this.labelWeight.Text = value;
            }
            else
            {
               
            }

            // 영점 표시
            if (data.Status == DataStore.WeightStatus.WeightZero)
                this.pictureBoxIconZero.Visible = true;
            else
                this.pictureBoxIconZero.Visible = false;

            // 알람표시
            this.UpdateDisplayAlarmView(data);

            // 정량 알람 카운트 표시
            if (int.Parse(this.ParentForm.CurrentSystemParameter1.PassAlarmCount.Trim()) != 0)
            {
                if (this.labelPassAlarmCount.Visible == false)
                    this.labelPassAlarmCount.Visible = true;
            }
            else
            {
                if (this.labelPassAlarmCount.Visible == true)
                    this.labelPassAlarmCount.Visible = false;
            }
        }
        public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, WeightData data)
        {
            string value = "";

            // 알람표시
            this.UpdateDisplayAlarmView(data);

            if (data.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                return;

            // 중량
            value = Helper.DoubleToString(data.Weight, this.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight.Text != value)
                this.labelWeight.Text = value;

            // 정량알람카운트표시
            if (int.Parse(this.ParentForm.CurrentSystemParameter1.PassAlarmCount.Trim()) != 0)
            {
                if (this.labelPassAlarmCount.Visible == false)
                    this.labelPassAlarmCount.Visible = true;

                if (this.labelPassAlarmCount.Text != data.PassAlarmCount)
                    this.labelPassAlarmCount.Text = data.PassAlarmCount;
            }
            else
            {
                if (this.labelPassAlarmCount.Visible == true)
                    this.labelPassAlarmCount.Visible = false;
            }

            // GAP 아이콘 표시
            if (data.JudgmentStatus == DataStore.JudgmentStatus.Double)
            {
                if (this.pictureBoxIconGap.Visible != false)
                    this.pictureBoxIconGap.Visible = true;
            }
            else
                this.pictureBoxIconGap.Visible = false;

            if (this.MainDisplayBarGraph != null)
                this.MainDisplayBarGraph.UpdateUpdateStartWeightDisplay(status, data);
            if (this.MainDisplayLineGraph != null)
                this.MainDisplayLineGraph.UpdateUpdateStartWeightDisplay(status, data);
            if (this.MainDisplayList != null)
                this.MainDisplayList.UpdateUpdateStartWeightDisplay(status, data);
            if (this.MainDisplayStatistics != null)
                this.MainDisplayStatistics.UpdateUpdateStartWeightDisplay(status, data);
        }
        public void UpdateTimeDisplay()
        {
            this.labelTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");        
        }
        public void UpdateDisplayMenuButton(DataStore.MainDisplayStore main)
        {
            if (this.buttonSubMenu.ButtonStatus != SmartButton.BUTSTATUS.UP)
                this.buttonSubMenu.ButtonUp();
            if (this.buttonBargraph.ButtonStatus != SmartButton.BUTSTATUS.UP)
                this.buttonBargraph.ButtonUp();
            if (this.buttonLinegraph.ButtonStatus != SmartButton.BUTSTATUS.UP)
                this.buttonLinegraph.ButtonUp();
            if (this.buttonList.ButtonStatus != SmartButton.BUTSTATUS.UP)
                this.buttonList.ButtonUp();
            if (this.buttonDataStat.ButtonStatus != SmartButton.BUTSTATUS.UP)
                this.buttonDataStat.ButtonUp();

            switch (main)
            {
                case DataStore.MainDisplayStore.Function1:
                    if (this.buttonSubMenu.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonSubMenu.ButtonDown();
                    break;
                case DataStore.MainDisplayStore.BarGraph:
                    if (this.buttonBargraph.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonBargraph.ButtonDown();
                    break;
                case DataStore.MainDisplayStore.LineGraph:
                    if (this.buttonLinegraph.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonLinegraph.ButtonDown();
                    break;
                case DataStore.MainDisplayStore.List:
                    if (this.buttonList.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonList.ButtonDown();
                    break;
                case DataStore.MainDisplayStore.Statistics:
                    if (this.buttonDataStat.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonDataStat.ButtonDown();
                    break;
                default:
                    break;
            }
        }
        public void DisplayBottomMain(DataStore.MainDisplayStore main)
        {
            this.UpdateDisplayMenuButton(main);

            switch (main)
            {
                case DataStore.MainDisplayStore.Function1:
                    this.MainDisplayFunction1.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
                    this.MainDisplayFunction1.BringToFront();
                    break;
                case DataStore.MainDisplayStore.BarGraph:
                    this.MainDisplayBarGraph.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
                    this.MainDisplayBarGraph.BringToFront();
                    break;
                case DataStore.MainDisplayStore.LineGraph:
                    this.MainDisplayLineGraph.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
                    this.MainDisplayLineGraph.BringToFront();
                    break;
                case DataStore.MainDisplayStore.List:
                    this.MainDisplayList.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
                    this.MainDisplayList.BringToFront();
                    break;
                case DataStore.MainDisplayStore.Statistics:
                    this.MainDisplayStatistics.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
                    this.MainDisplayStatistics.BringToFront();
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            //this.UpdateDisplayUser(status);

            this.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.MainDisplay;
            this.ParentForm.SetDisplayMode(DataStore.DisplayMode.Normal);

            // 아이콘, 단위 등 화면 갱신
            this.UpdateDisplay();
            this.DisplayBottomMain(this.CurrentDisplay);

            this.ProductChange(this.ParentForm.SystemConfig.ProductNumber);
        }
        #endregion

        #region Override Member
        //protected override void OnLoad(EventArgs e)
        //{
        //    base.OnLoad(e);

        //    this.InitializeDesign();
        //    this.DefaultSetting();

        //    //this.smartMemory1.ParentWindow = this;
        //    //this.smartMemory1.MemoryStatusInfomationShow(SmartX.SmartMemory.VIEWPOSITION.CENTER);
        //}
        #endregion

        #region Event Handler
        private void buttonProductNo_Click(object sender, EventArgs e)
        {
            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);
                }
            }
        }

        private void pictureBoxIconAlarm_Click(object sender, EventArgs e)
        {
            if (this.MainDisplayAlarm.Visible == true)
                this.MainDisplayAlarm.Visible = false;
            else
                this.MainDisplayAlarm.Visible = true;
        }

        private void pictureBoxStart_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
        }
        private void pictureBoxStop_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.Start, CommunicationID.MainBoard);
        }

        private void buttonZero_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard1);
        }
        private void buttonWeightInputMode_Click(object sender, EventArgs e)
        {
            if (this.buttonWeightInputMode.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.CurrentSystemStatus.CurrentWeightInputMode = DataStore.WeightInputMode.Deviation;
            else
                this.ParentForm.CurrentSystemStatus.CurrentWeightInputMode = DataStore.WeightInputMode.Weight;

            this.UpdateCurrentProductDisplay(this.ParentForm.CurrentSystemStatus.Equipment, this.ParentForm.CurrentProductItem, this.ParentForm.CurrentWeightData);
        }
        private void buttonClear_Click(object sender, EventArgs e)
        {
            DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 8);
            if (myDlg.ShowDialog() == DialogResult.Yes)
            {
                this.Clear();
            }
        }

        private void buttonConveyorUpDown_Click(object sender, EventArgs e)
        {
            if (this.buttonConveyorUpDown.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.TransferData(CommunicationCommand.MotorDown, CommunicationID.MainBoard);
            else
                this.ParentForm.TransferData(CommunicationCommand.MotorUp, CommunicationID.MainBoard);
        }

        private void buttonBargraph_Click(object sender, EventArgs e)
        {
            this.CurrentDisplay = DataStore.MainDisplayStore.BarGraph;

            this.DisplayBottomMain(this.CurrentDisplay);
        }
        private void buttonLinegraph_Click(object sender, EventArgs e)
        {
            this.CurrentDisplay = DataStore.MainDisplayStore.LineGraph;

            this.DisplayBottomMain(this.CurrentDisplay);
        }
        private void buttonList_Click(object sender, EventArgs e)
        {
            this.CurrentDisplay = DataStore.MainDisplayStore.List;

            this.DisplayBottomMain(this.CurrentDisplay);
        }
        private void buttonDataStat_Click(object sender, EventArgs e)
        {
            this.CurrentDisplay = DataStore.MainDisplayStore.Statistics;

            this.DisplayBottomMain(this.CurrentDisplay);
        }
        private void buttonSubMenu_Click(object sender, EventArgs e)
        {
            this.CurrentDisplay = DataStore.MainDisplayStore.Function1;

            this.DisplayBottomMain(this.CurrentDisplay);
        }

        private void buttonMenu_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.CurrentSystemStatus.Equipment == DataStore.EquipmentStatus.Stop)
            {
                ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
                this.ParentForm.ChildFormMenu.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
            }
            //else
            //{
            //    if (this.CurrentDisplay != DataStore.MainDisplayStore.Function1)
            //    {
            //        this.CurrentDisplay = DataStore.MainDisplayStore.Function1;
            //        this.MainDisplayMenu.DisplayRefresh(this.ParentForm.CurrentSystemStatus);
            //        this.MainDisplayMenu.BringToFront();
            //    }
            //    else
            //    {

            //    }
            //}
        }
        #endregion

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