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

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

        private Define.E_MenuBottomLog CurrentMenu;
        #endregion

        #region Constructor
        public ControlCenterLogHelp(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.buttonLogInspection.Text = "Inspection";
                this.buttonLogHistory.Text = "History";
                this.buttonLogOthers.Text = "Others";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Chinese)
            {
                this.buttonLogInspection.Text = "判断日志";
                this.buttonLogHistory.Text = "历史日志";
                this.buttonLogOthers.Text = "其他的";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Russian)
            {
                this.buttonLogInspection.Text = "Журнал оцен";
                this.buttonLogHistory.Text = "Жур-л истор";
                this.buttonLogOthers.Text = "Другие";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.German)
            {
                this.buttonLogInspection.Text = "Urteilsprotokoll";
                this.buttonLogHistory.Text = "Verlaufsprotokoll";
                this.buttonLogOthers.Text = "Andere";
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Spanish)
            {
                this.buttonLogInspection.Text = "Registro de juicio";
                this.buttonLogHistory.Text = "registro de historial";
                this.buttonLogOthers.Text = "Otros";
            }
            else
            {
                this.buttonLogInspection.Text = "판정로그";
                this.buttonLogHistory.Text = "히스토리로그";
                this.buttonLogOthers.Text = "기타로그";
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = Define.E_MenuBottomLog.Help;
        }

        public void UpdateMenuDisplay(SystemStatus status)
        {
            switch (status.CurrentUser.Group)
            {
                case Define.E_UserGroup.Level1:
                    this.buttonLogInspection.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsLogJudge;
                    this.buttonLogHistory.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsLogHistory;
                    this.buttonLogOthers.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsLogOthers;
                    break;
                case Define.E_UserGroup.Level2:
                    this.buttonLogInspection.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsLogJudge;
                    this.buttonLogHistory.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsLogHistory;
                    this.buttonLogOthers.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsLogOthers;
                    break;
                case Define.E_UserGroup.Level3:
                    this.buttonLogInspection.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsLogJudge;
                    this.buttonLogHistory.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsLogHistory;
                    this.buttonLogOthers.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsLogOthers;
                    break;
                case Define.E_UserGroup.Admin:
                case Define.E_UserGroup.Developer:
                    this.buttonLogInspection.Enabled = true;
                    this.buttonLogHistory.Enabled = true;
                    this.buttonLogOthers.Enabled = true;
                    break;
                case Define.E_UserGroup.NotLogin:
                    //this.buttonLogInspection.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsLogJudge;
                    //this.buttonLogHistory.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsLogHistory;
                    //this.buttonLogOthers.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsLogOthers;
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.LogHelp;
            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 == "Inspection")
                this.CurrentMenu = Define.E_MenuBottomLog.LogInspection;
            else if (control == "History")
                this.CurrentMenu = Define.E_MenuBottomLog.LogHistory;
            else if (control == "Others")
                this.CurrentMenu = Define.E_MenuBottomLog.LogOthers;
            else
                this.CurrentMenu = Define.E_MenuBottomLog.Help;

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