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

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

        private Define.E_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()
        {
            if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.English)
            {
                this.buttonInformation.Text = "Information";
                this.buttonAS.Text = "A/S";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Chinese)
            {
                this.buttonInformation.Text = "系统信息";
                this.buttonAS.Text = "A/S";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Czech)
            {

            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Russian)
            {
                this.buttonInformation.Text = "Информация";
                this.buttonAS.Text = "A/S";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.German)
            {
                this.buttonInformation.Text = "Information";
                this.buttonAS.Text = "Kundendienst";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {
                this.buttonInformation.Text = "Información";
                this.buttonAS.Text = "Servicio al Cliente";
            }
            else
            {
                this.buttonInformation.Text = "시스템정보";
                this.buttonAS.Text = "A/S";
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = Define.E_MenuBottomInformation.Help;
        }

        public void UpdateMenuDisplay(SystemStatus status)
        {
            switch (status.CurrentUser.Group)
            {
                case Define.E_UserGroup.Level1:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsInforSystem;
                    break;
                case Define.E_UserGroup.Level2:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsInforSystem;
                    break;
                case Define.E_UserGroup.Level3:
                    this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsInforAS;
                    this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsInforSystem;
                    break;
                case Define.E_UserGroup.Admin:
                case Define.E_UserGroup.Developer:
                    this.buttonAS.Enabled = true;
                    this.buttonInformation.Enabled = true;
                    break;
                case Define.E_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 = Define.E_DisplayStore.InforHelp;
            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 == "Information")
                this.CurrentMenu = Define.E_MenuBottomInformation.SystemInformation;
            else if (control == "AS")
                this.CurrentMenu = Define.E_MenuBottomInformation.AS;
            else
                this.CurrentMenu = Define.E_MenuBottomInformation.Help;

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