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

using SmartX;
using ITC81DB.Forms;
using ITC81DB_ImageDll;

namespace ITC81DB.Controls
{
    public partial class ControlCenterConfiHelp : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;

        private DataStore.MenuBottomConfiguration CurrentMenu;
        #endregion

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

            this.ParentForm = parent;

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

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

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

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                this.buttonCountingOutput.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCountingOutputDisable));
                this.buttonCountingOutput.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCountingOutputDown));
                this.buttonCountingOutput.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCountingOutputUp));
                this.buttonSerialCOM1.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM1Disable));
                this.buttonSerialCOM1.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM1Down));
                this.buttonSerialCOM1.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM1Up));
                this.buttonSerialCOM3.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM3Disable));
                this.buttonSerialCOM3.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM3Down));
                this.buttonSerialCOM3.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM3Up));
                this.buttonSerialCOM4.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM4Disable));
                this.buttonSerialCOM4.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM4Down));
                this.buttonSerialCOM4.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM4Up));
                this.buttonEthernet.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEthernetDisable));
                this.buttonEthernet.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEthernetDown));
                this.buttonEthernet.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEthernetUp));
                this.buttonOptionBoard.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionBoardDisable));
                this.buttonOptionBoard.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionBoardDown));
                this.buttonOptionBoard.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionBoardUp));
                this.buttonOption.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionDisable));
                this.buttonOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionDown));
                this.buttonOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.buttonCountingOutput.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpCountingOutputDisable));
                this.buttonCountingOutput.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpCountingOutputDown));
                this.buttonCountingOutput.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpCountingOutputUp));
                this.buttonSerialCOM1.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM1Disable));
                this.buttonSerialCOM1.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM1Down));
                this.buttonSerialCOM1.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM1Up));
                this.buttonSerialCOM3.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM3Disable));
                this.buttonSerialCOM3.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM3Down));
                this.buttonSerialCOM3.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM3Up));
                this.buttonSerialCOM4.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM4Disable));
                this.buttonSerialCOM4.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM4Down));
                this.buttonSerialCOM4.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSerialCOM4Up));
                this.buttonEthernet.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEthernetDisable));
                this.buttonEthernet.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEthernetDown));
                this.buttonEthernet.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEthernetUp));
                this.buttonOptionBoard.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpOptionBoardDisable));
                this.buttonOptionBoard.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpOptionBoardDown));
                this.buttonOptionBoard.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpOptionBoardUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {

            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                this.buttonCountingOutput.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpCountingOutputDisable));
                this.buttonCountingOutput.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpCountingOutputDown));
                this.buttonCountingOutput.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpCountingOutputUp));
                this.buttonSerialCOM1.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM1Disable));
                this.buttonSerialCOM1.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM1Down));
                this.buttonSerialCOM1.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM1Up));
                this.buttonSerialCOM3.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM3Disable));
                this.buttonSerialCOM3.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM3Down));
                this.buttonSerialCOM3.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM3Up));
                this.buttonSerialCOM4.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM4Disable));
                this.buttonSerialCOM4.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM4Down));
                this.buttonSerialCOM4.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSerialCOM4Up));
                this.buttonEthernet.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEthernetDisable));
                this.buttonEthernet.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEthernetDown));
                this.buttonEthernet.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEthernetUp));
                this.buttonOptionBoard.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpOptionBoardDisable));
                this.buttonOptionBoard.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpOptionBoardDown));
                this.buttonOptionBoard.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpOptionBoardUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.buttonCountingOutput.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpCountingOutputDisable));
                this.buttonCountingOutput.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpCountingOutputDown));
                this.buttonCountingOutput.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpCountingOutputUp));
                this.buttonSerialCOM1.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM1Disable));
                this.buttonSerialCOM1.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM1Down));
                this.buttonSerialCOM1.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM1Up));
                this.buttonSerialCOM3.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM3Disable));
                this.buttonSerialCOM3.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM3Down));
                this.buttonSerialCOM3.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM3Up));
                this.buttonSerialCOM4.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM4Disable));
                this.buttonSerialCOM4.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM4Down));
                this.buttonSerialCOM4.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSerialCOM4Up));
                this.buttonEthernet.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEthernetDisable));
                this.buttonEthernet.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEthernetDown));
                this.buttonEthernet.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEthernetUp));
                this.buttonOptionBoard.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpOptionBoardDisable));
                this.buttonOptionBoard.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpOptionBoardDown));
                this.buttonOptionBoard.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpOptionBoardUp));
                this.buttonOption.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpOptionDisable));
                this.buttonOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpOptionDown));
                this.buttonOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpOptionUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                this.buttonCountingOutput.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCountingOutputDisable));
                this.buttonCountingOutput.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCountingOutputDown));
                this.buttonCountingOutput.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCountingOutputUp));
                this.buttonSerialCOM1.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM1Disable));
                this.buttonSerialCOM1.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM1Down));
                this.buttonSerialCOM1.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM1Up));
                this.buttonSerialCOM3.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM3Disable));
                this.buttonSerialCOM3.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM3Down));
                this.buttonSerialCOM3.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM3Up));
                this.buttonSerialCOM4.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM4Disable));
                this.buttonSerialCOM4.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM4Down));
                this.buttonSerialCOM4.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSerialCOM4Up));
                this.buttonEthernet.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEthernetDisable));
                this.buttonEthernet.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEthernetDown));
                this.buttonEthernet.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEthernetUp));
                this.buttonOptionBoard.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionBoardDisable));
                this.buttonOptionBoard.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionBoardDown));
                this.buttonOptionBoard.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionBoardUp));
                this.buttonOption.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionDisable));
                this.buttonOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionDown));
                this.buttonOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpOptionUp));
            }
            else
            {
                this.buttonCountingOutput.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpCountingOutputDisable));
                this.buttonCountingOutput.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpCountingOutputDown));
                this.buttonCountingOutput.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpCountingOutputUp));
                this.buttonSerialCOM1.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM1Disable));
                this.buttonSerialCOM1.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM1Down));
                this.buttonSerialCOM1.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM1Up));
                this.buttonSerialCOM3.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM3Disable));
                this.buttonSerialCOM3.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM3Down));
                this.buttonSerialCOM3.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM3Up));
                this.buttonSerialCOM4.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM4Disable));
                this.buttonSerialCOM4.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM4Down));
                this.buttonSerialCOM4.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSerialCOM4Up));
                this.buttonEthernet.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEthernetDisable));
                this.buttonEthernet.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEthernetDown));
                this.buttonEthernet.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEthernetUp));
                this.buttonOptionBoard.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpOptionBoardDisable));
                this.buttonOptionBoard.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpOptionBoardDown));
                this.buttonOptionBoard.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpOptionBoardUp));
                this.buttonOption.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpOptionDisable));
                this.buttonOption.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpOptionDown));
                this.buttonOption.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpOptionUp));
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;
        }

        public void UpdateMenuDisplay(SystemStatus status)
        {
            switch (status.CurrentUser.Group)
            {
                case DataStore.UserGroup.Level1Operator:
                    this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial;
                    this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial;
                    this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial;
                    this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiEthernet;
                    this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiCountingOutput;
                    this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiOptionBoard;
                    break;
                case DataStore.UserGroup.Level2Engineer:
                    this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial;
                    this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial;
                    this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial;
                    this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiEthernet;
                    this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiCountingOutput;
                    this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiOptionBoard;
                    break;
                case DataStore.UserGroup.Level3Manager:
                    this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial;
                    this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial;
                    this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial;
                    this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiEthernet;
                    this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiCountingOutput;
                    this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiOptionBoard;
                    break;
                case DataStore.UserGroup.Level4Developer:
                    this.buttonSerialCOM1.Enabled = true;
                    this.buttonSerialCOM3.Enabled = true;
                    this.buttonSerialCOM4.Enabled = true;
                    this.buttonEthernet.Enabled = true;
                    this.buttonCountingOutput.Enabled = true;
                    this.buttonOption.Enabled = true;
                    break;
                case DataStore.UserGroup.NotLogin:
                    this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial;
                    this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial;
                    this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial;
                    this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiEthernet;
                    this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiCountingOutput;
                    this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiOptionBoard;
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            int value;

            value = int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.OptionBoard);
            if (value == 0)
                this.buttonOptionBoard.Visible = false;
            else
                this.buttonOptionBoard.Visible = true;

            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.ConfiHelp;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);
        }
        #endregion

        #region Event Handler
        private void buttonMenu_Click(object sender, EventArgs e)
        {
            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button == this.buttonSerialCOM1)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.SerialCOM1;
            else if (button == this.buttonSerialCOM3)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.SerialCOM3;
            else if (button == this.buttonSerialCOM4)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.SerialCOM4;
            else if (button == this.buttonEthernet)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Ethernet;
            else if (button == this.buttonOption)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Option;
            else if (button == this.buttonOptionBoard)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.OptionBoard;
            else if (button == this.buttonCountingOutput)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.CountingOutput;
            else
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;

            this.ParentForm.DisplayBottomConfiguration(this.CurrentMenu);
        }
        #endregion
    }
}
