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 ControlCenterInforHelp : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;

        private DataStore.MenuBottomInformation CurrentMenu;
        #endregion

        #region Constructor
        public ControlCenterInforHelp(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.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpASUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
                this.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                this.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpASUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpASUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                this.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpASUp));
            }
            else
            {
                this.buttonInformation.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpInformationDisable));
                this.buttonInformation.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpInformationDown));
                this.buttonInformation.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpInformationUp));
                this.buttonAS.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpASDisable));
                this.buttonAS.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpASDown));
                this.buttonAS.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpASUp));
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = DataStore.MenuBottomInformation.Help;
        }

        public void UpdateMenuDisplay(SystemStatus status)
        {
            switch (status.CurrentUser.Group)
            {
                case DataStore.UserGroup.Level1Operator:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsInforSystem;
                    break;
                case DataStore.UserGroup.Level2Engineer:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsInforSystem;
                    break;
                case DataStore.UserGroup.Level3Manager:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsInforSystem;
                    break;
                case DataStore.UserGroup.Level4Developer:
                    this.buttonAS.Enabled = true;
                    this.buttonInformation.Enabled = true;
                    break;
                case DataStore.UserGroup.NotLogin:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsInforSystem;
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.InforHelp;
            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.buttonInformation)
                this.CurrentMenu = DataStore.MenuBottomInformation.SystemInformation;
            else if (button == this.buttonAS)
                this.CurrentMenu = DataStore.MenuBottomInformation.AS;
            else
                this.CurrentMenu = DataStore.MenuBottomInformation.Help;

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