using System;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using SmartX;
using INT69DB_2A_ImageDll;
using INT69DB_2A.Controls;
using INT69DB_2A.DialogForms;

namespace INT69DB_2A.Forms
{
    public partial class FormConfiguration : Form
    {
        #region Field
        private FormMain m_ParentForm;
        private ControlConfiguration ChildControl;

        private string BeforeVariate;
        private string BeforeDoubleDelay;
        #endregion

        #region Constructor
        public FormConfiguration(FormMain parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

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

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

        #region Method
        private void InitializeDesign()
        {
            ImageDll images = new ImageDll();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
            {

            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                #region English
                this.labelTitle.Text = "Configuration";

                this.groupBoxAutoZero.Text = "Auto zero";
                this.labelStaticTime.Text = "Time";
                this.labelStaticRange.Text = "Range";
                this.labelStaticVariable.Text = "Variable";
                this.labelStaticMode.Text = "Mode";

                this.groupBoxOption.Text = "Option";
                this.labelStaticDoubleEntry.Text = "Double entry";
                this.labelStaticBuzzerOnTime.Text = "Buzzer ON time";
                this.labelStaticRelayOnTime.Text = "Relay ON time";
                this.labelStaticBypass.Text = "Bypass";
                this.labelStaticChattering.Text = "Chattering";
                this.labelStaticDecimalPoint.Text = "Decimal point";

                this.groupBoxCount.Text = "counter";
                this.labelStaticAlarmContinuousNG.Text = "Continuous NG";
                this.labelStaticATPC.Text = "Pass alarm"; 
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                #region Chinese
                this.labelTitle.Text = "选项";

                this.groupBoxAutoZero.Text = "自动零点跟踪";
                this.labelStaticTime.Text = "时间";
                this.labelStaticRange.Text = "范围";
                this.labelStaticVariable.Text = "变化";
                this.labelStaticMode.Text = "模式";

                this.groupBoxOption.Text = "等等";
                this.labelStaticDoubleEntry.Text = "重复进入";
                this.labelStaticBuzzerOnTime.Text = "蜂鸣器开启时间";
                this.labelStaticRelayOnTime.Text = "继电器接通时间";
                this.labelStaticBypass.Text = "旁路";
                this.labelStaticChattering.Text = "颤振";
                this.labelStaticDecimalPoint.Text = "小数点";

                this.groupBoxCount.Text = "柜台";
                this.labelStaticAlarmContinuousNG.Text = "连续不好";
                this.labelStaticATPC.Text = "通过警报";

                this.buttonDoubleEnter.DownImage = this.buttonBypassMode.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnEnable));
                this.buttonDoubleEnter.UpImage = this.buttonBypassMode.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnDisable)); 
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Japanese)
            {
                #region Japanese
                this.labelTitle.Text = "構成";

                this.groupBoxAutoZero.Text = "自動ゼロ";
                this.labelStaticTime.Text = "時間";
                this.labelStaticRange.Text = "範囲";
                this.labelStaticVariable.Text = "変化";
                this.labelStaticMode.Text = "モㅡド";

                this.groupBoxOption.Text = "オプション";
                this.labelStaticDoubleEntry.Text = "ダブル";
                this.labelStaticBuzzerOnTime.Text = "ブザㅡON時間";
                this.labelStaticRelayOnTime.Text = "リレㅡON時間";
                this.labelStaticBypass.Text = "バイパスモㅡド";
                this.labelStaticChattering.Text = "チャタリング";
                this.labelStaticDecimalPoint.Text = "小数点";

                this.groupBoxCount.Text = "カウンタ";
                this.labelStaticAlarmContinuousNG.Text = "連続NG";
                this.labelStaticATPC.Text = "定量アラㅡム";
                #endregion
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {

            }
            else
            {

            }
        }
        private void InitializeControl()
        {
            this.ChildControl = new ControlConfiguration(this);
            this.Controls.Add(this.ChildControl);
            this.ChildControl.Location = new Point(0, 68);
            this.ChildControl.BringToFront();
            this.ChildControl.Visible = false;

            this.BeforeVariate = "";
            this.BeforeDoubleDelay = "";

            this.labelZeroParameterTime.Text = "-";
            this.labelZeroParameterRange.Text = "-";
            this.labelChattering.Text = "-";
            this.labelBuzzerOnTime.Text = "-";
            this.labelRelayOnTime.Text = "-";

            this.comboBoxZeroParameterVariate.Items.Clear();
            this.comboBoxZeroParameterVariate.SelectedIndexChanged -= new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged);
            this.comboBoxZeroParameterVariate.Items.Add("0.05");
            this.comboBoxZeroParameterVariate.Items.Add("0.1");
            this.comboBoxZeroParameterVariate.Items.Add("0.2");
            this.comboBoxZeroParameterVariate.Items.Add("0.5");
            this.comboBoxZeroParameterVariate.Items.Add("1.0");
            this.comboBoxZeroParameterVariate.Items.Add("1.2");
            this.comboBoxZeroParameterVariate.SelectedIndex = 0;
            this.comboBoxZeroParameterVariate.SelectedIndexChanged += new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged);

            this.comboBoxZeroParameterMode.Items.Clear();
            this.comboBoxZeroParameterMode.SelectedIndexChanged -= new EventHandler(this.comboBoxZeroParameterMode_SelectedIndexChanged);
            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                this.comboBoxZeroParameterMode.Items.Add("模式1");
                this.comboBoxZeroParameterMode.Items.Add("模式2");
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Japanese)
            {
                this.comboBoxZeroParameterMode.Items.Add("モㅡド1");
                this.comboBoxZeroParameterMode.Items.Add("モㅡド2");
            }
            else
            {
                this.comboBoxZeroParameterMode.Items.Add("Mode1");
                this.comboBoxZeroParameterMode.Items.Add("Mode2");
            }
            this.comboBoxZeroParameterMode.SelectedIndex = 0;
            this.comboBoxZeroParameterMode.SelectedIndexChanged += new EventHandler(this.comboBoxZeroParameterMode_SelectedIndexChanged);

            this.comboBoxDecimalPlaces.Items.Clear();
            this.comboBoxDecimalPlaces.SelectedIndexChanged -= new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);
            this.comboBoxDecimalPlaces.Items.Add("0");
            this.comboBoxDecimalPlaces.Items.Add("0.0");
            this.comboBoxDecimalPlaces.Items.Add("0.00");
            this.comboBoxDecimalPlaces.Items.Add("0.000");
            this.comboBoxDecimalPlaces.SelectedIndex = 0;
            this.comboBoxDecimalPlaces.SelectedIndexChanged += new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);

        }
        private void DefaultSetting()
        {
            this.UpdateDisplay();
        }

        private void UpdateDisplay()
        {
            string value = "";

            // DecimalPlaces
            this.comboBoxDecimalPlaces.SelectedIndexChanged -= new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);
            this.comboBoxDecimalPlaces.SelectedIndex = this.ParentForm.SystemConfig.DecimalPlaces;
            this.comboBoxDecimalPlaces.SelectedIndexChanged += new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);

            // Bypass
            if (this.ParentForm.SystemConfig.IsBypassMode == true)
                this.buttonBypassMode.ButtonDown();
            else
                this.buttonBypassMode.ButtonUp();

            // AlarmContinuousNG Count
            value = this.ParentForm.SystemConfig.AlarmContinuousNG.ToString();
            if (this.labelAlarmContinuousNG.Text != value)
                this.labelAlarmContinuousNG.Text = value;

            // AlarmContinuousNG Enable
            if (this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable == true)
                this.buttonAlarmContinuousNG.ButtonDown();
            else
                this.buttonAlarmContinuousNG.ButtonUp();

            // AlarmTotalCount
            value = this.ParentForm.SystemConfig.AlarmTotalPassCnt.ToString();
            if (this.labelAlarmTotalPassCount.Text != value)
                this.labelAlarmTotalPassCount.Text = value;

            // AlarmTotalCount Enable
            if (this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable == true)
                this.buttonAlarmTotalPassCount.ButtonDown();
            else
                this.buttonAlarmTotalPassCount.ButtonUp();
        }
        public void UpdateZeroParameterRangeDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateZeroParameterRangeDisplay(status, values);
        }
        public void UpdateZeroParameterTimeDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateZeroParameterTimeDisplay(status, values);
        }
        public void UpdateZeroParameterVariateDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateZeroParameterVariateDisplay(status, values);
        }
        public void UpdateZeroParameterDisplay(DataStore.EquipmentStatus status, ZeroParameterItem item)
        {
            int iValue = 0;
            string sValue = "";

            sValue = item.Time.Trim();
            if (this.labelZeroParameterTime.Text != sValue)
                this.labelZeroParameterTime.Text = sValue;

            sValue = item.Range.Trim();
            if (this.labelZeroParameterRange.Text != sValue)
                this.labelZeroParameterRange.Text = sValue;

            iValue = int.Parse(item.Variate.Trim());
            this.comboBoxZeroParameterVariate.SelectedIndexChanged -= new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged);
            this.comboBoxZeroParameterVariate.SelectedIndex = iValue;
            this.BeforeVariate = this.comboBoxZeroParameterVariate.SelectedItem.ToString();
            this.comboBoxZeroParameterVariate.SelectedIndexChanged += new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged);
        }
        public void UpdateOptionParameterDisplay(DataStore.EquipmentStatus status, OptionParameterItem item)
        {
            string value = "";

            value = item.Chattering.Trim();
            if (this.labelChattering.Text != value)
                this.labelChattering.Text = value;

            value = item.BuzzerOnTime.Trim();
            if (this.labelBuzzerOnTime.Text != value)
                this.labelBuzzerOnTime.Text = value;

            value = item.RelayOnTime.Trim();
            if (this.labelRelayOnTime.Text != value)
                this.labelRelayOnTime.Text = value;

            if (item.DoubleEnter == "1")
            {
                this.buttonDoubleEnter.ButtonDown();
                this.BeforeDoubleDelay = "ON";
            }
            else
            {
                this.buttonDoubleEnter.ButtonUp();
                this.BeforeDoubleDelay = "OFF";
            }
        }
        public void UpdateBalanceWeightDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateBalanceWeightDisplay(status, values);
        }
        public void UpdateMaxWeightDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateMaxWeightDisplay(status, values);
        }
        public void UpdateDigitDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateDigitDisplay(status, values);
        }
        public void UpdateFilterDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            if (this.ChildControl != null)
                this.ChildControl.UpdateFilterDisplay(status, values);
        }

        public void DisplayRefresh()
        {
            this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormConfiguration;
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoard1, CommunicationAddress._4901_ParameterRead4901, "");

            this.UpdateDisplay();
        }
        #endregion

        #region Event Handler
        private void buttonBack_Click(object sender, EventArgs e)
        {
            if (this.ChildControl.Visible == true)
                this.ChildControl.Visible = false;

            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
        }
        private void buttonDoubleEnter_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.BeforeDoubleDelay;
            if (this.buttonDoubleEnter.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6005_DoubleEnter, Helper.StringZeroFillDigits4("1"));
                after = "ON";
            }
            else
            {
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6005_DoubleEnter, Helper.StringZeroFillDigits4("0"));
                after = "OFF";
            }

            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcDoubleEntry, "", before, after);
        }
        private void buttonBypassMode_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            string before = "", after = "";

            if (this.ParentForm.SystemConfig.IsBypassMode == true)
                before = "ON";
            else
                before = "OFF";

            if (this.buttonBypassMode.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                    sb.Append("1");
                after = "ON";

                this.ParentForm.SystemConfig.IsBypassMode = true;
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString());
            }
            else
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                    sb.Append("0");
                after = "OFF";

                this.ParentForm.SystemConfig.IsBypassMode = false;
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString());
            }

            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcBypass, "", before, after);
        }
        private void buttonScreen_Click(object sender, EventArgs e)
        {
            if (this.ChildControl.Visible == false)
            {
                this.ChildControl.BringToFront();
                this.ChildControl.Visible = true;
            }
            else
                this.ChildControl.Visible = false;
        }

        private void labelZeroParameterTime_Click(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.labelZeroParameterTime.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

                    value = Helper.StringZeroFillDigits4(this.labelZeroParameterTime.Text);

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4001_ZeroTime, value);

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.AutoZeroTime, "", before, after);
                }
            }
        }
        private void labelZeroParameterRange_Click(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.labelZeroParameterRange.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterRange.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

                    value = Helper.StringZeroFillDigits4(this.labelZeroParameterRange.Text);

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4002_ZeroRange, value);

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.AutoZeroRange, "", before, after);
                }
            }
        }
        private void labelChattering_Click(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.labelChattering.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelChattering.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

                    value = Helper.StringZeroFillDigits4(this.labelChattering.Text);

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6006_Chattering, value);

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Chattering, "", before, after);
                }
            }
        }
        private void labelBuzzerOnTime_Click(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.labelBuzzerOnTime.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelBuzzerOnTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

                    value = Helper.StringZeroFillDigits4(this.labelBuzzerOnTime.Text);

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6001_BuzzerOnTime, value);

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BuzzerONTime, "", before, after);
                }
            }
        }
        private void labelRelayOnTime_Click(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.labelRelayOnTime.Text;
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRelayOnTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

                    value = Helper.StringZeroFillDigits4(this.labelRelayOnTime.Text);

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6002_RelayRunTime, value);

                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.RelayONTime, "", before, after);
                }
            }
        }

        private void comboBoxZeroParameterVariate_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";
            string before = "", after = "";

            before = this.BeforeVariate;

            this.ParentForm.CurrentZeroParameterItem.Variate = this.comboBoxZeroParameterVariate.SelectedIndex.ToString();

            value = Helper.StringZeroFillDigits4(this.comboBoxZeroParameterVariate.SelectedIndex.ToString());
            this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4003_ZeroVariate, value);

            after = this.comboBoxZeroParameterVariate.SelectedItem.ToString();

            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.AutoZeroVariance, "", before, after);
        }
        private void comboBoxZeroParameterMode_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        private void comboBoxDecimalPlaces_SelectedIndexChanged(object sender, EventArgs e)
        {
            string before = "", after = "";
            before = this.comboBoxDecimalPlaces.Items.IndexOf(this.ParentForm.SystemConfig.DecimalPlaces).ToString();
            this.ParentForm.SystemConfig.DecimalPlaces = this.comboBoxDecimalPlaces.SelectedIndex;
            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
            after = this.comboBoxDecimalPlaces.SelectedItem.ToString();

            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.Decimal, "", before, after);
        }

        private void labelAlarmContinuousNG_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.labelAlarmContinuousNG.Text;

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

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

                    this.ParentForm.SystemConfig.AlarmContinuousNG = myKeyPad.IntValue;
                    this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ACNC_Count, "", before, after);
                }
            }
        }
        private void buttonAlarmContinuousNG_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            if (this.buttonAlarmContinuousNG.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                before = "OFF";
                after = "ON";
                this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable = true;
            }
            else
            {
                before = "ON";
                after = "OFF";
                this.ParentForm.SystemConfig.IsAlarmContinuousNGEnable = false;
            }

            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ACNC_Activate, "", before, after);
        }

        private void labelAlarmTotalCount_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            before = this.labelAlarmTotalPassCount.Text;

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

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

                    this.ParentForm.SystemConfig.AlarmTotalPassCnt = myKeyPad.IntValue;
                    this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

                    // Part11
                    if (this.ParentForm.SystemConfig.IsPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ATPC_Count, "", before, after);
                }
            }
        }
        private void buttonAlarmTotalCount_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            if (this.buttonAlarmTotalPassCount.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                before = "OFF";
                after = "ON";
                this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable = true;
            }
            else
            {
                before = "ON";
                after = "OFF";
                this.ParentForm.SystemConfig.IsAlarmTotalPassCntEnable = false;
            }

            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);

            // Part11
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ATPC_Activate, "", before, after);
        }
        #endregion
    }
}