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

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

        private DataStore.MenuBottomBasic CurrentMenu;
        #endregion

        #region Constructor
        public ControlCenterBasicHelp(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.buttonTime.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpTimeDisable));
                this.buttonTime.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpTimeDown));
                this.buttonTime.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpTimeUp));
                this.buttonProduct.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpItemDisable));
                this.buttonProduct.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpItemDown));
                this.buttonProduct.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpItemUp));
                this.buttonDataBackup.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataBackupDisable));
                this.buttonDataBackup.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataBackupDown));
                this.buttonDataBackup.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataBackupUp));
                this.buttonDataStatistics.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataStatisticsDisable));
                this.buttonDataStatistics.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataStatisticsDown));
                this.buttonDataStatistics.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataStatisticsUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.buttonTime.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpTimeDisable));
                this.buttonTime.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpTimeDown));
                this.buttonTime.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpTimeUp));
                this.buttonProduct.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpItemDisable));
                this.buttonProduct.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpItemDown));
                this.buttonProduct.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpItemUp));
                this.buttonDataBackup.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpDataBackupDisable));
                this.buttonDataBackup.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpDataBackupDown));
                this.buttonDataBackup.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpDataBackupUp));
                this.buttonDataStatistics.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpDataStatisticsDisable));
                this.buttonDataStatistics.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpDataStatisticsDown));
                this.buttonDataStatistics.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpDataStatisticsUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                this.buttonTime.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpTimeDisable));
                this.buttonTime.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpTimeDown));
                this.buttonTime.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpTimeUp));
                this.buttonProduct.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpItemDisable));
                this.buttonProduct.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpItemDown));
                this.buttonProduct.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpItemUp));
                this.buttonDataBackup.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpDataBackupDisable));
                this.buttonDataBackup.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpDataBackupDown));
                this.buttonDataBackup.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpDataBackupUp));
                this.buttonDataStatistics.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpDataStatisticsDisable));
                this.buttonDataStatistics.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpDataStatisticsDown));
                this.buttonDataStatistics.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpDataStatisticsUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.buttonTime.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpTimeDisable));
                this.buttonTime.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpTimeDown));
                this.buttonTime.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpTimeUp));
                this.buttonProduct.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpItemDisable));
                this.buttonProduct.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpItemDown));
                this.buttonProduct.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpItemUp));
                this.buttonDataBackup.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpDataBackupDisable));
                this.buttonDataBackup.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpDataBackupDown));
                this.buttonDataBackup.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpDataBackupUp));
                this.buttonDataStatistics.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpDataStatisticsDisable));
                this.buttonDataStatistics.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpDataStatisticsDown));
                this.buttonDataStatistics.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpDataStatisticsUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                this.buttonTime.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpTimeDisable));
                this.buttonTime.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpTimeDown));
                this.buttonTime.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpTimeUp));
                this.buttonProduct.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpItemDisable));
                this.buttonProduct.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpItemDown));
                this.buttonProduct.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpItemUp));
                this.buttonDataBackup.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataBackupDisable));
                this.buttonDataBackup.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataBackupDown));
                this.buttonDataBackup.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataBackupUp));
                this.buttonDataStatistics.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataStatisticsDisable));
                this.buttonDataStatistics.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataStatisticsDown));
                this.buttonDataStatistics.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpDataStatisticsUp));
            }
            else
            {
                this.buttonTime.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpTimeDisable));
                this.buttonTime.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpTimeDown));
                this.buttonTime.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpTimeUp));
                this.buttonProduct.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpItemDisable));
                this.buttonProduct.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpItemDown));
                this.buttonProduct.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpItemUp));
                this.buttonDataBackup.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpDataBackupDisable));
                this.buttonDataBackup.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpDataBackupDown));
                this.buttonDataBackup.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpDataBackupUp));
                this.buttonDataStatistics.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpDataStatisticsDisable));
                this.buttonDataStatistics.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpDataStatisticsDown));
                this.buttonDataStatistics.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpDataStatisticsUp));
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = DataStore.MenuBottomBasic.Help;
        }

        public void UpdateMenuDisplay(SystemStatus status)
        {

            switch (status.CurrentUser.Group)
            {
                case DataStore.UserGroup.Level1Operator:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicProduct;
                    this.buttonDataBackup.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicDataBackup;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicDataStatistics;
                    break;
                case DataStore.UserGroup.Level2Engineer:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicProduct;
                    this.buttonDataBackup.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicDataBackup;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicDataStatistics;
                    break;
                case DataStore.UserGroup.Level3Manager:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicProduct;
                    this.buttonDataBackup.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicDataBackup;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicDataStatistics;
                    break;
                case DataStore.UserGroup.Level4Developer:
                    this.buttonTime.Enabled = true;
                    this.buttonProduct.Enabled = true;
                    this.buttonDataBackup.Enabled = true;
                    this.buttonDataStatistics.Enabled = true;
                    break;
                case DataStore.UserGroup.NotLogin:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicProduct;
                    this.buttonDataBackup.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicDataBackup;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicDataStatistics;
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.BasicHelp;
            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.buttonTime)
                this.CurrentMenu = DataStore.MenuBottomBasic.Time;
            else if (button == this.buttonProduct)
                this.CurrentMenu = DataStore.MenuBottomBasic.Product;
            else if (button == this.buttonDataBackup)
                this.CurrentMenu = DataStore.MenuBottomBasic.DataBackup;
            else if (button == this.buttonDataStatistics)
                this.CurrentMenu = DataStore.MenuBottomBasic.DataStatistics;
            else
                this.CurrentMenu = DataStore.MenuBottomBasic.Help;

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