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 SmartX;
using ITC81DB_2.Forms;
using ITC81DB_2_ImageDll;

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

        private Define.E_MenuBottomSystem CurrentMenu;
        #endregion

        #region Constructor
        public ControlCenterSystemHelp(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.SystemConfig.Language == Define.E_LanguageID.English)
            {
                this.buttonCalibration.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCalibrationDisable));
                this.buttonCalibration.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCalibrationDown));
                this.buttonCalibration.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpCalibrationUp));
                this.buttonJudgmentSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentDisable));
                this.buttonJudgmentSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentDown));
                this.buttonJudgmentSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentUp));
                this.buttonSorter.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSorterDisable));
                this.buttonSorter.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSorterDown));
                this.buttonSorter.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpSorterUp));
                this.buttonAutoZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpAutoZeroDisable));
                this.buttonAutoZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpAutoZeroDown));
                this.buttonAutoZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpAutoZeroUp));
                this.buttonIOTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpIOTestDisable));
                this.buttonIOTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpIOTestDown));
                this.buttonIOTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpIOTestUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Chinese)
            {
                this.buttonCalibration.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpCalibrationDisable));
                this.buttonCalibration.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpCalibrationDown));
                this.buttonCalibration.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpCalibrationUp));
                this.buttonJudgmentSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentDisable));
                this.buttonJudgmentSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentDown));
                this.buttonJudgmentSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentUp));
                this.buttonSorter.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSorterDisable));
                this.buttonSorter.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSorterDown));
                this.buttonSorter.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpSorterUp));
                this.buttonAutoZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpAutoZeroDisable));
                this.buttonAutoZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpAutoZeroDown));
                this.buttonAutoZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpAutoZeroUp));
                this.buttonIOTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpIOTestDisable));
                this.buttonIOTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpIOTestDown));
                this.buttonIOTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpIOTestUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
                this.buttonCalibration.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpCalibrationDisable));
                this.buttonCalibration.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpCalibrationDown));
                this.buttonCalibration.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpCalibrationUp));
                this.buttonJudgmentSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpJudgmentDisable));
                this.buttonJudgmentSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpJudgmentDown));
                this.buttonJudgmentSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpJudgmentUp));
                this.buttonSorter.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpSorterDisable));
                this.buttonSorter.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpSorterDown));
                this.buttonSorter.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpSorterUp));
                this.buttonAutoZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpAutoZeroDisable));
                this.buttonAutoZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpAutoZeroDown));
                this.buttonAutoZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpAutoZeroUp));
                this.buttonIOTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpIOTestDisable));
                this.buttonIOTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpIOTestDown));
                this.buttonIOTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnHelpIOTestUp));
            }
            else
            {
                this.buttonCalibration.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpCalibrationDisable));
                this.buttonCalibration.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpCalibrationDown));
                this.buttonCalibration.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpCalibrationUp));
                this.buttonJudgmentSetting.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentDisable));
                this.buttonJudgmentSetting.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentDown));
                this.buttonJudgmentSetting.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentUp));
                this.buttonSorter.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSorterDisable));
                this.buttonSorter.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSorterDown));
                this.buttonSorter.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpSorterUp));
                this.buttonAutoZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpAutoZeroDisable));
                this.buttonAutoZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpAutoZeroDown));
                this.buttonAutoZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpAutoZeroUp));
                this.buttonIOTest.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpIOTestDisable));
                this.buttonIOTest.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpIOTestDown));
                this.buttonIOTest.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpIOTestUp));
            }
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = Define.E_MenuBottomSystem.Help;
        }

        public void UpdateDisplayMenuButton(Define.E_MenuBottomSystem menu)
        {
            switch (menu)
            {
                case Define.E_MenuBottomSystem.AutoZero:
                    if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonAutoZero.ButtonDown();
                    if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonCalibration.ButtonUp();
                    
                    break;
                case Define.E_MenuBottomSystem.Calibration:
                    break;
                case Define.E_MenuBottomSystem.Help:
                    break;
                case Define.E_MenuBottomSystem.IOTest:
                    break;
                case Define.E_MenuBottomSystem.JudgmentSetting:
                    break;
                case Define.E_MenuBottomSystem.SorterSetting:
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.SystemHelp;
            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.buttonCalibration)
                this.CurrentMenu = Define.E_MenuBottomSystem.Calibration;
            else if (button == this.buttonJudgmentSetting)
                this.CurrentMenu = Define.E_MenuBottomSystem.JudgmentSetting;
            else if (button == this.buttonSorter)
                this.CurrentMenu = Define.E_MenuBottomSystem.SorterSetting;
            else if (button == this.buttonAutoZero)
                this.CurrentMenu = Define.E_MenuBottomSystem.AutoZero;
            else if (button == this.buttonIOTest)
                this.CurrentMenu = Define.E_MenuBottomSystem.IOTest;
            else
                this.CurrentMenu = Define.E_MenuBottomSystem.Help;

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