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()
        {
            this.buttonTime.Font = new Font("새굴림", 15, FontStyle.Bold);
            this.buttonProduct.Font = new Font("새굴림", 15, FontStyle.Bold);
            this.buttonDataStatistics.Font = new Font("새굴림", 15, FontStyle.Bold);

            if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.English)
            {
                this.buttonTime.Text = "Time";
                this.buttonProduct.Text = "Product";
                this.buttonDataStatistics.Text = "Statistics";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Chinese)
            {
                this.buttonTime.Text = "时间设定";
                this.buttonProduct.Text = "产品设定";
                this.buttonDataStatistics.Text = "数据统计";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Czech)
            {

            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Russian)
            {
                this.buttonTime.Text = "Настр.врем";
                this.buttonProduct.Text = "Настр.продукта";
                this.buttonDataStatistics.Text = "Статистика";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.German)
            {
                this.buttonTime.Text = "Zeiteinstellung";
                this.buttonProduct.Text = "Produkteinstellung";
                this.buttonDataStatistics.Text = "Statistik";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {
                this.buttonTime.Text = "Tiempo";
                this.buttonProduct.Text = "Producto";
                this.buttonDataStatistics.Text = "Estadistica de datos";
            }
            else
            {
                this.buttonTime.Text = "시간설정";
                this.buttonProduct.Text = "품목설정";
                this.buttonDataStatistics.Text = "데이터집계";
            }
        }
        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)
        {
            string control = (sender as Control).Tag.ToString();

            if (control == null || control == "")
                return;

            if (control == "Time")
                this.CurrentMenu = Define.E_MenuBottomBasic.Time;
            else if (control == "Product")
                this.CurrentMenu = Define.E_MenuBottomBasic.Product;
            else if (control == "Statistics")
                this.CurrentMenu = Define.E_MenuBottomBasic.DataStatistics;
            else
                this.CurrentMenu = Define.E_MenuBottomBasic.Help;

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