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_2H.Forms;
using SmartX;
using ITC81DB_2H_ImageDll;
using ITC81DB_2H.Datastore;

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

        private Define.E_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 == Define.E_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.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 == Define.E_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.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 == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_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.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 == Define.E_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.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
            {
                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.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 = Define.E_MenuBottomBasic.Help;
        }

        public void UpdateMenuDisplay(SystemStatus status)
        {

            switch (status.CurrentUser.Group)
            {
                case Define.E_UserGroup.Level1:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicProduct;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicDataStatistics;
                    break;
                case Define.E_UserGroup.Level2:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicProduct;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicDataStatistics;
                    break;
                case Define.E_UserGroup.Level3:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicProduct;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicDataStatistics;
                    break;
                case Define.E_UserGroup.Admin:
                case Define.E_UserGroup.Developer:
                    this.buttonTime.Enabled = true;
                    this.buttonProduct.Enabled = true;
                    this.buttonDataStatistics.Enabled = true;
                    break;
                case Define.E_UserGroup.NotLogin:
                    this.buttonTime.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicTime;
                    this.buttonProduct.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicProduct;
                    this.buttonDataStatistics.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicDataStatistics;
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.BasicHelp;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_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 = Define.E_MenuBottomBasic.Time;
            else if (button == this.buttonProduct)
                this.CurrentMenu = Define.E_MenuBottomBasic.Product;
            else if (button == this.buttonDataStatistics)
                this.CurrentMenu = Define.E_MenuBottomBasic.DataStatistics;
            else
                this.CurrentMenu = Define.E_MenuBottomBasic.Help;

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