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

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

        #region Constructor
        public ControlMainStartMenu(FormMainDisplay parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
            this.DefaultSetting();
        } 
        #endregion

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

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

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
            }
            else
            {
            }
        }
        private void DefaultSetting()
        {

        }

        public void DisplayRefresh(SystemStatus status)
        {

        }
        #endregion

        #region Event Handler
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            // 이더넷
            this.ParentForm.ParentForm.EthernetClientConnect();
        }
        private void buttonDisconnect_Click(object sender, EventArgs e)
        {
            // 이더넷
            this.ParentForm.ParentForm.IsEthernetTransferData = false;
            this.ParentForm.ParentForm.IsClientConnectTryTimerStart = false;
            this.ParentForm.ParentForm.timerClientConnect.Enabled = false;
            this.ParentForm.ParentForm.EthernetClientDisconnect();
        }

        private void labelTimer_Click(object sender, EventArgs e)
        {
            string value = "";

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

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelTimer.Text = myKeyPad.StringValue;
                }
            }
        }
        private void buttonTimerON_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.timerClientConnect.Enabled = false;
            this.ParentForm.ParentForm.timerClientConnect.Interval = int.Parse(this.labelTimer.Text);
            this.ParentForm.ParentForm.timerClientConnect.Enabled = true;
            this.ParentForm.ParentForm.IsClientConnectTryTimerStart = true;
        }
        private void buttonTimerOFF_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.timerClientConnect.Enabled = false;
            this.ParentForm.ParentForm.IsClientConnectTryTimerStart = false;
        }
        #endregion
    }
}
