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.DialogForms;
using ITC81DB.Forms;
using ITC81DB_ImageDll;

namespace ITC81DB.Controls
{
    public partial class ControlCenterSystemJudgmentSelect : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;        
        #endregion

        #region Property
        public FormMenu ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }
        #endregion

        #region Constructor
        public ControlCenterSystemJudgmentSelect(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;
            this.InitializeDesign();
        }
        #endregion

        #region Method
        public void InitializeDesign()
        {
            Class1 images = new Class1();

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                this.buttonItemNo.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDisable));
                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoUp));
                this.buttonAutoMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentAutoDisable));
                this.buttonAutoMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentAutoDown));
                this.buttonAutoMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentAutoUp));
                this.buttonManualMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentManualDisable));
                this.buttonManualMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentManualDown));
                this.buttonManualMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentManualUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                this.buttonItemNo.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnFormProductNoDisable));
                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnFormProductNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnFormProductNoUp));
                this.buttonAutoMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentAutoDisable));
                this.buttonAutoMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentAutoDown));
                this.buttonAutoMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentAutoUp));
                this.buttonManualMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentManualDisable));
                this.buttonManualMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentManualDown));
                this.buttonManualMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnHelpJudgmentManualUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                this.buttonItemNo.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDisable));
                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoUp));
                this.buttonAutoMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpJudgmentAutoDisable));
                this.buttonAutoMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpJudgmentAutoDown));
                this.buttonAutoMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpJudgmentAutoUp));
                this.buttonManualMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpJudgmentManualDisable));
                this.buttonManualMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpJudgmentManualDown));
                this.buttonManualMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusHelpJudgmentManualUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                this.buttonItemNo.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerProductNoDisable));
                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerProductNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerProductNoUp));
                this.buttonAutoMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpJudgmentAutoDisable));
                this.buttonAutoMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpJudgmentAutoDown));
                this.buttonAutoMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpJudgmentAutoUp));
                this.buttonManualMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpJudgmentManualDisable));
                this.buttonManualMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpJudgmentManualDown));
                this.buttonManualMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerHelpJudgmentManualUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                this.buttonItemNo.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDisable));
                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoUp));
                this.buttonAutoMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentAutoDisable));
                this.buttonAutoMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentAutoDown));
                this.buttonAutoMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentAutoUp));
                this.buttonManualMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentManualDisable));
                this.buttonManualMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentManualDown));
                this.buttonManualMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engHelpJudgmentManualUp));
            }
            else
            {
                this.buttonItemNo.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDisable));
                this.buttonItemNo.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoDown));
                this.buttonItemNo.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engProductNoUp));
                this.buttonAutoMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentAutoDisable));
                this.buttonAutoMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentAutoDown));
                this.buttonAutoMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentAutoUp));
                this.buttonManualMode.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentManualDisable));
                this.buttonManualMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentManualDown));
                this.buttonManualMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korHelpJudgmentManualUp));
            }
        }

        public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, ProductItem pItem)
        {
            string value = "";

            value = pItem.Number.ToString();
            if (this.buttonItemNo.Text != value)
                this.buttonItemNo.Text = value;
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.SystemJudgmentSelect;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.SystemSetting);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.buttonItemNo.Text = this.ParentForm.ParentForm.SystemConfig1.ProductNumber.ToString();
        }
        #endregion

        #region Event Handler
        private void buttonItemNo_Click(object sender, EventArgs e)
        {
            string message = "";

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonItemNo.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > this.ParentForm.ParentForm.ProductCount)
                {
                    // 입력범위를 확인하세요
                    message = string.Format("1 ~ {0}", this.ParentForm.ParentForm.ProductCount);
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, message);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.buttonItemNo.Text = myKeyPad.StringValue;

                    this.buttonItemNo.Text = "**";
                    this.ParentForm.ParentForm.TransferProductParameter(myKeyPad.IntValue);
                }
            }
        }

        private void buttonAutoMode_Click(object sender, EventArgs e)
        {
            this.ParentForm.CenterSystemJudgmentAuto.DisplayRefresh(this.ParentForm.ParentForm.CurrentSystemStatus);
            this.ParentForm.CenterSystemJudgmentAuto.BringToFront();
        }

        private void buttonManualMode_Click(object sender, EventArgs e)
        {
            this.ParentForm.CenterSystemJudgmentManual.DisplayRefresh(this.ParentForm.ParentForm.CurrentSystemStatus);
            this.ParentForm.CenterSystemJudgmentManual.BringToFront();
        }
        #endregion
    }
}
