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_2.Forms;
using ITC81DB_2_ImageDll;
using SmartX;

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

        private Define.E_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.SystemConfig.Language == Define.E_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.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.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));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_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.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.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));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
                this.buttonUpdate.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpUpdateDisable));
                this.buttonUpdate.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpUpdateDown));
                this.buttonUpdate.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpUpdateUp));
                this.buttonInitialize.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpInitializationDisable));
                this.buttonInitialize.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpInitializationDown));
                this.buttonInitialize.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpInitializationUp));
                this.buttonFunction.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpFunctionDisable));
                this.buttonFunction.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpFunctionDown));
                this.buttonFunction.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpFunctionUp));
                this.buttonUser.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpUserDisable));
                this.buttonUser.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpUserDown));
                this.buttonUser.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpUserUp));
                this.buttonEngineerSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpEngineerDisable));
                this.buttonEngineerSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpEngineerDown));
                this.buttonEngineerSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpEngineerUp));
            }
            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.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.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));
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = Define.E_MenuBottomEquipment.Help;

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

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

            this.buttonEngineerSetting.Visible = bValue;
        }
        private void UpdateDisplayUser(UserItem user)
        {
            if (user.Group == Define.E_UserGroup.Developer && this.ParentForm.ParentForm.SystemConfig.IsLogin == true)
                this.DisplayHiddenMenu(true);
            else
                this.DisplayHiddenMenu(false);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.EquipHelp;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_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 = Define.E_MenuBottomEquipment.Update;
            else if (button == this.buttonInitialize)
                this.CurrentMenu = Define.E_MenuBottomEquipment.Initialize;
            else if (button == this.buttonFunction)
                this.CurrentMenu = Define.E_MenuBottomEquipment.FunctionSetting;
            else if (button == this.buttonUser)
                this.CurrentMenu = Define.E_MenuBottomEquipment.User;
            else if (button == this.buttonEngineerSetting)
                this.CurrentMenu = Define.E_MenuBottomEquipment.Engineer;
            else
                this.CurrentMenu = Define.E_MenuBottomEquipment.Help;

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