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 ITC81DB.Forms;
using ITC81DB_ImageDll;
using SmartX;

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

        private DataStore.MenuBottomEquipment CurrentMenu;
        #endregion

        #region Constructor
        public ControlCenterEquipHelp(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.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInitializationUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEngineerUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUserUp));
                this.buttonEquipmentTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEquipmentTestDisable));
                this.buttonEquipmentTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEquipmentTestDown));
                this.buttonEquipmentTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEquipmentTestUp));
                this.buttonSystemLog.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSystemLogDisable));
                this.buttonSystemLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSystemLogDown));
                this.buttonSystemLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSystemLogUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpInitializationUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEngineerUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpUserUp));
                this.buttonEquipmentTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEquipmentTestDisable));
                this.buttonEquipmentTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEquipmentTestDown));
                this.buttonEquipmentTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpEquipmentTestUp));
                this.buttonSystemLog.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSystemLogDisable));
                this.buttonSystemLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSystemLogDown));
                this.buttonSystemLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSystemLogUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                this.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpInitializationUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEngineerUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpUserUp));
                this.buttonEquipmentTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEquipmentTestDisable));
                this.buttonEquipmentTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEquipmentTestDown));
                this.buttonEquipmentTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpEquipmentTestUp));
                this.buttonSystemLog.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSystemLogDisable));
                this.buttonSystemLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSystemLogDown));
                this.buttonSystemLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpSystemLogUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpInitializationUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEngineerUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpUserUp));
                this.buttonEquipmentTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEquipmentTestDisable));
                this.buttonEquipmentTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEquipmentTestDown));
                this.buttonEquipmentTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpEquipmentTestUp));
                this.buttonSystemLog.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSystemLogDisable));
                this.buttonSystemLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSystemLogDown));
                this.buttonSystemLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpSystemLogUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                this.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInitializationUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEngineerUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpUserUp));
                this.buttonEquipmentTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEquipmentTestDisable));
                this.buttonEquipmentTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEquipmentTestDown));
                this.buttonEquipmentTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpEquipmentTestUp));
                this.buttonSystemLog.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSystemLogDisable));
                this.buttonSystemLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSystemLogDown));
                this.buttonSystemLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSystemLogUp));
            }
            else
            {
                this.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpInitializationUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEngineerUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpUserUp));
                this.buttonEquipmentTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEquipmentTestDisable));
                this.buttonEquipmentTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEquipmentTestDown));
                this.buttonEquipmentTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpEquipmentTestUp));
                this.buttonSystemLog.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSystemLogDisable));
                this.buttonSystemLog.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSystemLogDown));
                this.buttonSystemLog.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSystemLogUp));
            }
        }
        public void DefaultSetting()
        {
            this.CurrentMenu = DataStore.MenuBottomEquipment.Help;

            if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == true)
                this.buttonUser.Visible = true;
            else
                this.buttonUser.Visible = false;
        }

        public void DisplayHiddenMenu(bool bValue)
        {
            if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == true)
                this.buttonEngineerSetting.Location = new Point(194, 240);
            else
                this.buttonEngineerSetting.Location = new Point(28, 240);

            this.buttonEngineerSetting.Visible = bValue;
        }
        private void UpdateDisplayUser(UserItem user)
        {
            if (user.Group == DataStore.UserGroup.Level4Developer && this.ParentForm.ParentForm.SystemConfig1.IsLogin == true)
                this.DisplayHiddenMenu(true);
            else
                this.DisplayHiddenMenu(false);
        }
        public void UpdateMenuDisplay(SystemStatus status)
        {
            switch (status.CurrentUser.Group)
            {
                case DataStore.UserGroup.Level1Operator:
                    this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipUpdate;
                    this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipInitialize;
                    this.buttonFunction.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipFunctionSetting;
                    this.buttonUser.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipUserSetting;
                    this.buttonEngineerSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipEngineerSetting;
                    this.buttonSystemLog.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipSystemLog;
                    break;
                case DataStore.UserGroup.Level2Engineer:
                    this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipUpdate;
                    this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipInitialize;
                    this.buttonFunction.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipFunctionSetting;
                    this.buttonUser.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipUserSetting;
                    this.buttonEngineerSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipEngineerSetting;
                    this.buttonSystemLog.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipSystemLog;
                    break;
                case DataStore.UserGroup.Level3Manager:
                    this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipUpdate;
                    this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipInitialize;
                    this.buttonFunction.Enabled = true;
                    this.buttonUser.Enabled = true;
                    this.buttonEngineerSetting.Enabled = true;
                    this.buttonSystemLog.Enabled =true;
                    break;
                case DataStore.UserGroup.Level4Developer:
                    this.buttonUpdate.Enabled = true;
                    this.buttonInitialize.Enabled = true;
                    this.buttonFunction.Enabled = true;
                    this.buttonUser.Enabled = true;
                    this.buttonEngineerSetting.Enabled = true;
                    this.buttonSystemLog.Enabled = true;
                    break;
                case DataStore.UserGroup.NotLogin:
                    this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipUpdate;
                    this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipInitialize;
                    this.buttonFunction.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipFunctionSetting;
                    this.buttonUser.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipUserSetting;
                    this.buttonEngineerSetting.Enabled = true;
                    this.buttonSystemLog.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipSystemLog;
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.EquipHelp;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.UpdateDisplayUser(status.CurrentUser);
        }
        #endregion

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

            if (button == null)
                return;

            if (button == this.buttonUpdate)
                this.CurrentMenu = DataStore.MenuBottomEquipment.Update;
            else if (button == this.buttonInitialize)
                this.CurrentMenu = DataStore.MenuBottomEquipment.Initialize;
            else if (button == this.buttonFunction)
                this.CurrentMenu = DataStore.MenuBottomEquipment.FunctionSetting;
            else if (button == this.buttonSystemLog)
                this.CurrentMenu = DataStore.MenuBottomEquipment.SystemLog;
            else if (button == this.buttonUser)
                this.CurrentMenu = DataStore.MenuBottomEquipment.User;
            else if (button == this.buttonEquipmentTest)
                this.CurrentMenu = DataStore.MenuBottomEquipment.Test;
            else if (button == this.buttonEngineerSetting)
                this.CurrentMenu = DataStore.MenuBottomEquipment.Engineer;
            else
                this.CurrentMenu = DataStore.MenuBottomEquipment.Help;

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