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

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

        #region Constructor
        public ControlCenterSystemAutoZero(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.labelTitleMode1.Text = "Mode 1";
                this.labelTitleMode2.Text = "Mode 2";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "Time";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "Range";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "Variation";
                                
                this.rbMode2None1.Text = this.rbMode2None2.Text = "None";
                this.rbMode1High1.Text = this.rbMode1High2.Text = this.rbMode2High1.Text = this.rbMode2High2.Text = "High";
                this.rbMode1Middle1.Text = this.rbMode1Middle2.Text = this.rbMode2Middle1.Text = this.rbMode2Middle2.Text = "Middle";
                this.rbMode1Low1.Text = this.rbMode1Low2.Text = this.rbMode2Low1.Text = this.rbMode2Low2.Text = "Low";
                this.rbMode1UserSetting1.Text = this.rbMode1UserSetting2.Text = this.rbMode2UserSetting1.Text = this.rbMode2UserSetting2.Text = "User Setting";
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Chinese)
            {
                this.labelTitleMode1.Text = "模式 1";
                this.labelTitleMode2.Text = "模式 2";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "时间";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "范围";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "变化";

                this.rbMode2None1.Text = this.rbMode2None2.Text = "不使用";
                this.rbMode1High1.Text = this.rbMode1High2.Text = this.rbMode2High1.Text = this.rbMode2High2.Text = "高";
                this.rbMode1Middle1.Text = this.rbMode1Middle2.Text = this.rbMode2Middle1.Text = this.rbMode2Middle2.Text = "中间";
                this.rbMode1Low1.Text = this.rbMode1Low2.Text = this.rbMode2Low1.Text = this.rbMode2Low2.Text = "低";
                this.rbMode1UserSetting1.Text = this.rbMode1UserSetting2.Text = this.rbMode2UserSetting1.Text = this.rbMode2UserSetting2.Text = "用户设置";
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
                this.labelTitleMode1.Text = "Modo 1";
                this.labelTitleMode2.Text = "Modo 2";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "Tiempo";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "Distancia";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "Variación";

                this.rbMode2None1.Text = this.rbMode2None2.Text = "Ninguna";
                this.rbMode1High1.Text = this.rbMode1High2.Text = this.rbMode2High1.Text = this.rbMode2High2.Text = "Alto";
                this.rbMode1Middle1.Text = this.rbMode1Middle2.Text = this.rbMode2Middle1.Text = this.rbMode2Middle2.Text = "Medio";
                this.rbMode1Low1.Text = this.rbMode1Low2.Text = this.rbMode2Low1.Text = this.rbMode2Low2.Text = "Bajo";
                this.rbMode1UserSetting1.Text = this.rbMode1UserSetting2.Text = this.rbMode2UserSetting1.Text = this.rbMode2UserSetting2.Text = "Usuario";
            }
            else
            {
                this.labelTitleMode1.Text = "모드 1";
                this.labelTitleMode2.Text = "모드 2";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "시간";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "범위";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "변량";

                this.rbMode2None1.Text = this.rbMode2None2.Text = "None";
                this.rbMode1High1.Text = this.rbMode1High2.Text = this.rbMode2High1.Text = this.rbMode2High2.Text = "High";
                this.rbMode1Middle1.Text = this.rbMode1Middle2.Text = this.rbMode2Middle1.Text = this.rbMode2Middle2.Text = "Middle";
                this.rbMode1Low1.Text = this.rbMode1Low2.Text = this.rbMode2Low1.Text = this.rbMode2Low2.Text = "Low";
                this.rbMode1UserSetting1.Text = this.rbMode1UserSetting2.Text = this.rbMode2UserSetting1.Text = this.rbMode2UserSetting2.Text = "User Setting";
            }
        }
        private void DefaultSetting()
        {
            //this.labelAutoZeroTime.Text = " -";
            //this.labelAutoZeroRange.Text = " -";

            this.comboBoxMode1Variate1.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);
            this.comboBoxMode1Variate1.Items.Clear();
            this.comboBoxMode1Variate1.Items.Add(0.1);
            this.comboBoxMode1Variate1.Items.Add(0.2);
            this.comboBoxMode1Variate1.Items.Add(0.5);
            this.comboBoxMode1Variate1.Items.Add(1.0);
            this.comboBoxMode1Variate1.SelectedIndex = 0;
            this.comboBoxMode1Variate1.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);

            this.comboBoxMode2Variate1.SelectedIndexChanged -= new EventHandler(this.comboBoxMode2Variate1_SelectedIndexChanged);
            this.comboBoxMode2Variate1.Items.Clear();
            this.comboBoxMode2Variate1.Items.Add(0.1);
            this.comboBoxMode2Variate1.Items.Add(0.2);
            this.comboBoxMode2Variate1.Items.Add(0.5);
            this.comboBoxMode2Variate1.Items.Add(1.0);
            this.comboBoxMode2Variate1.SelectedIndex = 0;
            this.comboBoxMode2Variate1.SelectedIndexChanged += new EventHandler(this.comboBoxMode2Variate1_SelectedIndexChanged);

            this.comboBoxMode1Variate2.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate2_SelectedIndexChanged);
            this.comboBoxMode1Variate2.Items.Clear();
            this.comboBoxMode1Variate2.Items.Add(0.1);
            this.comboBoxMode1Variate2.Items.Add(0.2);
            this.comboBoxMode1Variate2.Items.Add(0.5);
            this.comboBoxMode1Variate2.Items.Add(1.0);
            this.comboBoxMode1Variate2.SelectedIndex = 0;
            this.comboBoxMode1Variate2.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate2_SelectedIndexChanged);

            this.comboBoxMode2Variate2.SelectedIndexChanged -= new EventHandler(this.comboBoxMode2Variate2_SelectedIndexChanged);
            this.comboBoxMode2Variate2.Items.Clear();
            this.comboBoxMode2Variate2.Items.Add(0.1);
            this.comboBoxMode2Variate2.Items.Add(0.2);
            this.comboBoxMode2Variate2.Items.Add(0.5);
            this.comboBoxMode2Variate2.Items.Add(1.0);
            this.comboBoxMode2Variate2.SelectedIndex = 0;
            this.comboBoxMode2Variate2.SelectedIndexChanged += new EventHandler(this.comboBoxMode2Variate2_SelectedIndexChanged);
        }

        private void ControlEnableZero1(bool time, bool range, bool variate)
        {
            if (time == true)
            {
                if (this.labelMode1Time1.ForeColor != Color.Black)
                    this.labelMode1Time1.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode1Time1.ForeColor != Color.DarkGray)
                    this.labelMode1Time1.ForeColor = Color.DarkGray;
            }

            if (range == true)
            {
                if (this.labelMode1Range1.ForeColor != Color.Black)
                    this.labelMode1Range1.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode1Range1.ForeColor != Color.DarkGray)
                    this.labelMode1Range1.ForeColor = Color.DarkGray;
            }

            if (this.labelMode1Time1.Enabled != time)
                this.labelMode1Time1.Enabled = time;

            if (this.labelMode1Range1.Enabled != range)
                this.labelMode1Range1.Enabled = range;

            if (this.comboBoxMode1Variate1.Enabled != variate)
                this.comboBoxMode1Variate1.Enabled = variate;
        }
        private void ControlEnableZero2(bool time, bool range, bool variate)
        {
            if (time == true)
            {
                if (this.labelMode2Time1.ForeColor != Color.Black)
                    this.labelMode2Time1.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode2Time1.ForeColor != Color.DarkGray)
                    this.labelMode2Time1.ForeColor = Color.DarkGray;
            }

            if (range == true)
            {
                if (this.labelMode2Range1.ForeColor != Color.Black)
                    this.labelMode2Range1.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode2Range1.ForeColor != Color.DarkGray)
                    this.labelMode2Range1.ForeColor = Color.DarkGray;
            }

            if (this.labelMode2Time1.Enabled != time)
                this.labelMode2Time1.Enabled = time;

            if (this.labelMode2Range1.Enabled != range)
                this.labelMode2Range1.Enabled = range;

            if (this.comboBoxMode2Variate1.Enabled != variate)
                this.comboBoxMode2Variate1.Enabled = variate;
        }
        private void ControlEnableZero3(bool time, bool range, bool variate)
        {
            if (time == true)
            {
                if (this.labelMode1Time2.ForeColor != Color.Black)
                    this.labelMode1Time2.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode1Time2.ForeColor != Color.DarkGray)
                    this.labelMode1Time2.ForeColor = Color.DarkGray;
            }

            if (range == true)
            {
                if (this.labelMode1Range2.ForeColor != Color.Black)
                    this.labelMode1Range2.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode1Range2.ForeColor != Color.DarkGray)
                    this.labelMode1Range2.ForeColor = Color.DarkGray;
            }

            if (this.labelMode1Time2.Enabled != time)
                this.labelMode1Time2.Enabled = time;

            if (this.labelMode1Range2.Enabled != range)
                this.labelMode1Range2.Enabled = range;

            if (this.comboBoxMode1Variate2.Enabled != variate)
                this.comboBoxMode1Variate2.Enabled = variate;
        }
        private void ControlEnableZero4(bool time, bool range, bool variate)
        {
            if (time == true)
            {
                if (this.labelMode2Time2.ForeColor != Color.Black)
                    this.labelMode2Time2.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode2Time2.ForeColor != Color.DarkGray)
                    this.labelMode2Time2.ForeColor = Color.DarkGray;
            }

            if (range == true)
            {
                if (this.labelMode2Range2.ForeColor != Color.Black)
                    this.labelMode2Range2.ForeColor = Color.Black;
            }
            else
            {
                if (this.labelMode2Range2.ForeColor != Color.DarkGray)
                    this.labelMode2Range2.ForeColor = Color.DarkGray;
            }

            if (this.labelMode2Time2.Enabled != time)
                this.labelMode2Time2.Enabled = time;

            if (this.labelMode2Range2.Enabled != range)
                this.labelMode2Range2.Enabled = range;

            if (this.comboBoxMode2Variate2.Enabled != variate)
                this.comboBoxMode2Variate2.Enabled = variate;
        }

        private void UpdateZeroParameterDisplay(SystemParameter9510 item1, SystemParameter9511 item2)
        {
            this.UpdateZero1ParameterDisplay(item1);
            this.UpdateZero2ParameterDisplay(item1);
            this.UpdateZero3ParameterDisplay(item2);
            this.UpdateZero4ParameterDisplay(item2);
        }
        /// <summary>
        /// 1열 모드1
        /// </summary>
        /// <param name="item"></param>
        public void UpdateZero1ParameterDisplay(SystemParameter9510 item)
        {
            int iValue = 0;
            string value = "";

            // Mode 1
            iValue = int.Parse(item.AutoZero1Mode.Trim());
            if (iValue == 1)
            {
                this.rbMode1Low1.Checked = true;
                this.ControlEnableZero1(false, false, false);
            }
            else if (iValue == 2)
            {
                this.rbMode1Middle1.Checked = true;
                this.ControlEnableZero1(false, false, false);
            }
            else if (iValue == 3)
            {
                this.rbMode1High1.Checked = true;
                this.ControlEnableZero1(false, false, false);
            }
            else if (iValue == 4)
            {
                this.rbMode1UserSetting1.Checked = true;
                this.ControlEnableZero1(true, true, true);
            }
            else
            {
                this.rbMode1UserSetting1.Checked = true;
                this.ControlEnableZero1(true, true, true);
            }

            // Mode1 Time
            value = item.AutoZero1Time.Trim();
            if (this.labelMode1Time1.Text != value)
                this.labelMode1Time1.Text = value;

            // Mode1 Range
            value = item.AutoZero1Range.Trim();
            if (this.labelMode1Range1.Text != value)
                this.labelMode1Range1.Text = value;

            // Mode1 Variate
            iValue = int.Parse(item.AutoZero1Variate.Trim());
            this.comboBoxMode1Variate1.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);
            this.comboBoxMode1Variate1.SelectedIndex = iValue;
            this.comboBoxMode1Variate1.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);

        }
        /// <summary>
        /// 1열 모드2
        /// </summary>
        /// <param name="item"></param>
        public void UpdateZero2ParameterDisplay(SystemParameter9510 item)
        {
            int iValue = 0;
            string value = "";

            // Mode 2
            iValue = int.Parse(item.AutoZero2Mode.Trim());
            if (iValue == 0)
            {
                this.rbMode2None1.Checked = true;
                this.ControlEnableZero2(false, false, false);
            }
            else if (iValue == 1)
            {
                this.rbMode2Low1.Checked = true;
                this.ControlEnableZero2(false, false, false);
            }
            else if (iValue == 2)
            {
                this.rbMode2Middle1.Checked = true;
                this.ControlEnableZero2(false, false, false);
            }
            else if (iValue == 3)
            {
                this.rbMode2High1.Checked = true;
                this.ControlEnableZero2(false, false, false);
            }
            else if (iValue == 4)
            {
                this.rbMode2UserSetting1.Checked = true;
                this.ControlEnableZero2(true, true, true);
            }
            else
            {
                this.rbMode2None1.Checked = true;
                this.ControlEnableZero2(true, true, true);
            }

            // Mode2 Time;
            value = item.AutoZero2Time.Trim();
            if (this.labelMode2Time1.Text != value)
                this.labelMode2Time1.Text = value;

            // Mode2 Range
            value = item.AutoZero2Range.Trim();
            if (this.labelMode2Range1.Text != value)
                this.labelMode2Range1.Text = value;

            // Mode2 Variate
            iValue = int.Parse(item.AutoZero2Variate.Trim());
            this.comboBoxMode2Variate1.SelectedIndexChanged -= new EventHandler(this.comboBoxMode2Variate1_SelectedIndexChanged);
            this.comboBoxMode2Variate1.SelectedIndex = iValue;
            this.comboBoxMode2Variate1.SelectedIndexChanged += new EventHandler(this.comboBoxMode2Variate1_SelectedIndexChanged);
        }
        /// <summary>
        /// 2열 모드1
        /// </summary>
        /// <param name="item"></param>
        public void UpdateZero3ParameterDisplay(SystemParameter9511 item)
        {
            int iValue = 0;
            string value = "";

            // Mode 1
            iValue = int.Parse(item.AutoZero1Mode.Trim());
            if (iValue == 1)
            {
                this.rbMode1Low2.Checked = true;
                this.ControlEnableZero3(false, false, false);
            }
            else if (iValue == 2)
            {
                this.rbMode1Middle2.Checked = true;
                this.ControlEnableZero3(false, false, false);
            }
            else if (iValue == 3)
            {
                this.rbMode1High2.Checked = true;
                this.ControlEnableZero3(false, false, false);
            }
            else if (iValue == 4)
            {
                this.rbMode1UserSetting2.Checked = true;
                this.ControlEnableZero3(true, true, true);
            }
            else
            {
                this.rbMode1UserSetting2.Checked = true;
                this.ControlEnableZero3(true, true, true);
            }

            // Mode1 Time
            value = item.AutoZero1Time.Trim();
            if (this.labelMode1Time2.Text != value)
                this.labelMode1Time2.Text = value;

            // Mode1 Range
            value = item.AutoZero1Range.Trim();
            if (this.labelMode1Range2.Text != value)
                this.labelMode1Range2.Text = value;

            // Mode1 Variate
            iValue = int.Parse(item.AutoZero1Variate.Trim());
            this.comboBoxMode1Variate2.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate2_SelectedIndexChanged);
            this.comboBoxMode1Variate2.SelectedIndex = iValue;
            this.comboBoxMode1Variate2.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate2_SelectedIndexChanged);

        }
        /// <summary>
        /// 2열 모드2
        /// </summary>
        /// <param name="item"></param>
        public void UpdateZero4ParameterDisplay(SystemParameter9511 item)
        {
            int iValue = 0;
            string value = "";

            // Mode 2
            iValue = int.Parse(item.AutoZero2Mode.Trim());
            if (iValue == 0)
            {
                this.rbMode2None2.Checked = true;
                this.ControlEnableZero4(false, false, false);
            }
            else if (iValue == 1)
            {
                this.rbMode2Low2.Checked = true;
                this.ControlEnableZero4(false, false, false);
            }
            else if (iValue == 2)
            {
                this.rbMode2Middle2.Checked = true;
                this.ControlEnableZero4(false, false, false);
            }
            else if (iValue == 3)
            {
                this.rbMode2High2.Checked = true;
                this.ControlEnableZero4(false, false, false);
            }
            else if (iValue == 4)
            {
                this.rbMode2UserSetting2.Checked = true;
                this.ControlEnableZero4(true, true, true);
            }
            else
            {
                this.rbMode2None2.Checked = true;
                this.ControlEnableZero4(true, true, true);
            }

            // Mode2 Time;
            value = item.AutoZero2Time.Trim();
            if (this.labelMode2Time2.Text != value)
                this.labelMode2Time2.Text = value;

            // Mode2 Range
            value = item.AutoZero2Range.Trim();
            if (this.labelMode2Range2.Text != value)
                this.labelMode2Range2.Text = value;

            // Mode2 Variate
            iValue = int.Parse(item.AutoZero2Variate.Trim());
            this.comboBoxMode2Variate2.SelectedIndexChanged -= new EventHandler(this.comboBoxMode2Variate2_SelectedIndexChanged);
            this.comboBoxMode2Variate2.SelectedIndex = iValue;
            this.comboBoxMode2Variate2.SelectedIndexChanged += new EventHandler(this.comboBoxMode2Variate2_SelectedIndexChanged);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.SystemAutoZero;
            this.ParentForm.ParentForm.SetDisplayMode(Define.E_DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.UpdateZeroParameterDisplay(this.ParentForm.ParentForm.CurrentSystemParameter9510, this.ParentForm.ParentForm.CurrentSystemParameter9511);
            this.Focus();
        }
        #endregion

        #region Event Handler
        private void radioButtonLane1Mode1_Click(object sender, EventArgs e)
        {
            string value = "";
            SmartRadioButton button = sender as SmartRadioButton;

            if (button == null)
                return;

            if (button == this.rbMode1Low1)
                value = "0001";
            else if (button == this.rbMode1Middle1)
                value = "0002";
            else if (button == this.rbMode1High1)
                value = "0003";
            else if (button == this.rbMode1UserSetting1)
                value = "0004";

            this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Mode = value;
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4004_Zero1Mode, value);
        }
        private void radioButtonLane1Mode2_Click(object sender, EventArgs e)
        {
            string value = "";
            SmartRadioButton button = sender as SmartRadioButton;

            if (button == null)
                return;

            if (button == this.rbMode2None1)
                value = "0000";
            else if (button == this.rbMode2Low1)
                value = "0001";
            else if (button == this.rbMode2Middle1)
                value = "0002";
            else if (button == this.rbMode2High1)
                value = "0003";
            else if (button == this.rbMode2UserSetting1)
                value = "0004";

            this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero2Mode = value;
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4005_Zero2Mode, value);
        }
        private void radioButtonLane2Mode1_Click(object sender, EventArgs e)
        {
            string value = "";
            SmartRadioButton button = sender as SmartRadioButton;

            if (button == null)
                return;

            if (button == this.rbMode1Low2)
                value = "0001";
            else if (button == this.rbMode1Middle2)
                value = "0002";
            else if (button == this.rbMode1High2)
                value = "0003";
            else if (button == this.rbMode1UserSetting2)
                value = "0004";

            this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Mode = value;
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4024_Zero1Mode, value);
        }
        private void radioButtonLane2Mode2_Click(object sender, EventArgs e)
        {
            string value = "";
            SmartRadioButton button = sender as SmartRadioButton;

            if (button == null)
                return;

            if (button == this.rbMode2None2)
                value = "0000";
            else if (button == this.rbMode2Low2)
                value = "0001";
            else if (button == this.rbMode2Middle2)
                value = "0002";
            else if (button == this.rbMode2High2)
                value = "0003";
            else if (button == this.rbMode2UserSetting2)
                value = "0004";

            this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero2Mode = value;
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4025_Zero2Mode, value);
        }

        private void labelMode1Time1_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode1Time1.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode1Time1.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Time = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Time);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4001_Zero1Time, value);
                }
            }
        }
        private void labelMode1Range1_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode1Range1.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode1Range1.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Range = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Range);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4002_Zero1Range, value);
                }
            }
        }
        private void labelMode2Time1_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode2Time1.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode2Time1.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero2Time = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero2Time);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4006_Zero2Time, value);
                }
            }
        }
        private void labelMode2Range1_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode2Range1.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode2Range1.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero2Range = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero2Range);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4007_Zero2Range, value);
                }
            }
        }
        private void labelMode1Time2_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode1Time2.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode1Time2.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Time = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Time);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4021_Zero1Time, value);
                }
            }
        }
        private void labelMode1Range2_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode1Range2.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode1Range2.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Range = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Range);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4022_Zero1Range, value);
                }
            }
        }
        private void labelMode2Time2_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode2Time2.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode2Time2.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero2Time = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero2Time);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4026_Zero2Time, value);
                }
            }
        }
        private void labelMode2Range2_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMode2Range2.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() == DialogResult.OK)
            {
                if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999)
                {
                    // 입력범위를 확인하세요
                    DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                    myMsg.ShowDialog();
                }
                else
                {
                    this.labelMode2Range2.Text = myKeyPad.StringValue;
                    this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero2Range = myKeyPad.StringValue;

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero2Range);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4027_Zero2Range, value);
                }
            }
        }

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

            value = Helper.StringZeroFillDigits4(this.comboBoxMode1Variate1.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Variate = value;

            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4003_Zero1Variate, value);
        }
        private void comboBoxMode2Variate1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            value = Helper.StringZeroFillDigits4(this.comboBoxMode2Variate1.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero2Variate = value;

            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4008_Zero2Variate, value);
        }
        private void comboBoxMode1Variate2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            value = Helper.StringZeroFillDigits4(this.comboBoxMode1Variate2.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Variate = value;

            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4023_Zero1Variate, value);
        }
        private void comboBoxMode2Variate2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            value = Helper.StringZeroFillDigits4(this.comboBoxMode2Variate2.SelectedIndex.ToString());
            this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero2Variate = value;

            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4028_Zero2Variate, value);
        }
        #endregion
    }
}
