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.Threading;
using System.Windows.Forms;

using SmartX;
using INT69DC_ImageDll;
using INT69DC_7C.Controls;
using INT69DC_7C.DialogForms;

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

        private ControlConfiguration1 ChildControl1;

        private Collection<SmartLabel> CollectionBypassLabel;
        private Collection<SmartButton> CollectionBypassButton;
        #endregion

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

            this.ParentForm = parent;

            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.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.labelStaticChattering.Text = "Chattering";
                this.labelStaticDecimalPoint.Text = "Decimal point";
                this.labelStaticAlarmContinuousNG.Text = "Continuous NG";

                this.labelStaticBuzzerOnTime.Text = "Buzzer ON time";
                this.labelStaticRelayOnTime.Text = "Relay ON time";
                this.labelStaticBypass.Text = "Bypass";

                this.groupBoxCount.Text = "Counter";
                this.labelStaticATPC.Text = "Pass alarm";

                this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenDisable));
                this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenDown));
                this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenUp));
                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.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.labelStaticChattering.Text = "颤振";
                this.labelStaticBuzzerOnTime.Text = "蜂鸣器开启时间";
                this.labelStaticRelayOnTime.Text = "继电器接通时间";
                this.labelStaticDecimalPoint.Text = "小数点";
                this.labelStaticAlarmContinuousNG.Text = "连续不好";
                this.labelStaticBypass.Text = "旁路";

                this.groupBoxBypass.Text = "旁路";

                this.labelTitleLine1.Text = "列1";
                this.labelTitleLine2.Text = "列2";
                this.labelTitleLine3.Text = "列3";
                this.labelTitleLine4.Text = "列4";
                this.labelTitleLine5.Text = "列5";
                this.labelTitleLine6.Text = "列6";
                this.labelTitleLine7.Text = "列7";
                this.labelTitleLine8.Text = "列8";
                this.labelTitleLine9.Text = "列9";
                this.labelTitleLine10.Text = "列10";
                this.labelTitleLine11.Text = "列11";
                this.labelTitleLine12.Text = "列12";

                this.groupBoxCount.Text = "柜台";
                this.labelStaticATPC.Text = "通过警报";

                this.buttonBypassLane1.DownImage = this.buttonBypassLane2.DownImage = this.buttonBypassLane3.DownImage =
                this.buttonBypassLane4.DownImage = this.buttonBypassLane5.DownImage = this.buttonBypassLane6.DownImage =
                this.buttonBypassLane7.DownImage = this.buttonBypassLane8.DownImage = this.buttonBypassLane9.DownImage =
                this.buttonBypassLane10.DownImage = this.buttonBypassLane11.DownImage = this.buttonBypassLane12.DownImage =
                this.buttonBypassMode.DownImage = this.buttonDoubleEnter.DownImage = this.buttonAlarmContinuousNG.DownImage =
                new Bitmap(images.GetImage(ImageDll.ButtonImages.chnEnable));

                this.buttonBypassLane1.UpImage = this.buttonBypassLane2.UpImage = this.buttonBypassLane3.UpImage =
                this.buttonBypassLane4.UpImage = this.buttonBypassLane5.UpImage = this.buttonBypassLane6.UpImage =
                this.buttonBypassLane7.UpImage = this.buttonBypassLane8.UpImage = this.buttonBypassLane9.UpImage =
                this.buttonBypassLane10.UpImage = this.buttonBypassLane11.UpImage = this.buttonBypassLane12.UpImage =
                this.buttonBypassMode.UpImage = this.buttonDoubleEnter.UpImage = this.buttonAlarmContinuousNG.UpImage =
                new Bitmap(images.GetImage(ImageDll.ButtonImages.chnDisable));

                this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenDisable));
                this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenDown));
                this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenUp));
                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
                this.labelTitle.Text = "Konfigurace";

                this.groupBoxAutoZero.Text = "Automatické nulování";
                this.labelStaticTime.Text = "Čas";
                this.labelStaticRange.Text = "Rozsah";
                this.labelStaticVariable.Text = "Odchylka";
                this.labelStaticMode.Text = "Mód";

                this.groupBoxOption.Text = "Možnosti";
                this.labelStaticDoubleEntry.Text = "Zdvojení";
                this.labelStaticChattering.Text = "Chvění";
                this.labelStaticDecimalPoint.Text = "Desetinná čárka";
                this.labelStaticAlarmContinuousNG.Text = "Trvalá chyba";

                this.labelStaticBuzzerOnTime.Text = "Zapnutí času alarmu";
                this.labelStaticRelayOnTime.Text = "Zapnutí času relé";
                this.labelStaticBypass.Text = "Mód pro bypass";

                this.labelTitleLine1.Text = "Linka 1";
                this.labelTitleLine2.Text = "Linka 2";
                this.labelTitleLine3.Text = "Linka 3";
                this.labelTitleLine4.Text = "Linka 4";
                this.labelTitleLine5.Text = "Linka 5";
                this.labelTitleLine6.Text = "Linka 6";
                this.labelTitleLine7.Text = "Linka 7";
                this.labelTitleLine8.Text = "Linka 8";
                this.labelTitleLine9.Text = "Linka 9";
                this.labelTitleLine10.Text = "Linka 10";
                this.labelTitleLine11.Text = "Linka 11";
                this.labelTitleLine12.Text = "Linka 12";

                this.labelStaticBypass.Text = "Bypass vše";

                this.groupBoxCount.Text = "čelit";
                this.labelStaticATPC.Text = "Předání alarmu";

                this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenDisable));
                this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenDown));
                this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenUp));
                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackUp));

                this.buttonBypassLane1.DownImage = this.buttonBypassLane2.DownImage = this.buttonBypassLane3.DownImage =
                this.buttonBypassLane4.DownImage = this.buttonBypassLane5.DownImage = this.buttonBypassLane6.DownImage =
                this.buttonBypassLane7.DownImage = this.buttonBypassLane8.DownImage = this.buttonBypassLane9.DownImage =
                this.buttonBypassLane10.DownImage = this.buttonBypassLane11.DownImage = this.buttonBypassLane12.DownImage =
                this.buttonBypassMode.DownImage = this.buttonDoubleEnter.DownImage = this.buttonAlarmContinuousNG.DownImage =
                new Bitmap(images.GetImage(ImageDll.ButtonImages.czeEnable));

                this.buttonBypassLane1.UpImage = this.buttonBypassLane2.UpImage = this.buttonBypassLane3.UpImage =
                this.buttonBypassLane4.UpImage = this.buttonBypassLane5.UpImage = this.buttonBypassLane6.UpImage =
                this.buttonBypassLane7.UpImage = this.buttonBypassLane8.UpImage = this.buttonBypassLane9.UpImage =
                this.buttonBypassLane10.UpImage = this.buttonBypassLane11.UpImage = this.buttonBypassLane12.UpImage =
                this.buttonBypassMode.UpImage = this.buttonDoubleEnter.UpImage = this.buttonAlarmContinuousNG.UpImage =
                new Bitmap(images.GetImage(ImageDll.ButtonImages.czeDisable));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                this.labelTitle.Text = "Konfiguration";

                this.groupBoxAutoZero.Text = "automatische Nullung";
                this.labelStaticTime.Text = "Zeit";
                this.labelStaticRange.Text = "Bereich";
                this.labelStaticVariable.Text = "Unterschied";
                this.labelStaticMode.Text = "Modus";

                this.groupBoxOption.Text = "Möglichkeit";
                this.labelStaticDoubleEntry.Text = "doppelte Eingabe";
                this.labelStaticChattering.Text = "Beruhigung des Dehnungsmessers";
                this.labelStaticDecimalPoint.Text = "Dezimalpunkt";
                this.labelStaticAlarmContinuousNG.Text = "Dauerhafter Fehler";

                this.labelStaticBuzzerOnTime.Text = "Summer-Einschaltzeit";
                this.labelStaticRelayOnTime.Text = "Relais-Einschaltzeit";
                this.labelStaticBypass.Text = "Bypass-Modus";

                this.labelTitleLine1.Text = "Reihe 1";
                this.labelTitleLine2.Text = "Reihe 2";
                this.labelTitleLine3.Text = "Reihe 3";
                this.labelTitleLine4.Text = "Reihe 4";
                this.labelTitleLine5.Text = "Reihe 5";
                this.labelTitleLine6.Text = "Reihe 6";
                this.labelTitleLine7.Text = "Reihe 7";
                this.labelTitleLine8.Text = "Reihe 8";
                this.labelTitleLine9.Text = "Reihe 9";
                this.labelTitleLine10.Text = "Reihe 10";
                this.labelTitleLine11.Text = "Reihe 11";
                this.labelTitleLine12.Text = "Reihe 12";

                this.labelStaticBypass.Text = "Bypass Alles";

                this.groupBoxCount.Text = "Schalter";
                this.labelStaticATPC.Text = "Alarm übergeben";

                this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenDisable));
                this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenDown));
                this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenUp));
                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackUp));

                this.buttonBypassLane1.DownImage = this.buttonBypassLane2.DownImage = this.buttonBypassLane3.DownImage =
                this.buttonBypassLane4.DownImage = this.buttonBypassLane5.DownImage = this.buttonBypassLane6.DownImage =
                this.buttonBypassLane7.DownImage = this.buttonBypassLane8.DownImage = this.buttonBypassLane9.DownImage =
                this.buttonBypassLane10.DownImage = this.buttonBypassLane11.DownImage = this.buttonBypassLane12.DownImage =
                this.buttonBypassMode.DownImage = this.buttonDoubleEnter.DownImage = this.buttonAlarmContinuousNG.DownImage =
                new Bitmap(images.GetImage(ImageDll.ButtonImages.gerEnable));

                this.buttonBypassLane1.UpImage = this.buttonBypassLane2.UpImage = this.buttonBypassLane3.UpImage =
                this.buttonBypassLane4.UpImage = this.buttonBypassLane5.UpImage = this.buttonBypassLane6.UpImage =
                this.buttonBypassLane7.UpImage = this.buttonBypassLane8.UpImage = this.buttonBypassLane9.UpImage =
                this.buttonBypassLane10.UpImage = this.buttonBypassLane11.UpImage = this.buttonBypassLane12.UpImage =
                this.buttonBypassMode.UpImage = this.buttonDoubleEnter.UpImage = this.buttonAlarmContinuousNG.UpImage =
                new Bitmap(images.GetImage(ImageDll.ButtonImages.gerDisable));

            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.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.labelStaticChattering.Text = "チャタリング";
                this.labelStaticDecimalPoint.Text = "小数点";
                this.labelStaticAlarmContinuousNG.Text = "連続不良";
                this.labelStaticBuzzerOnTime.Text = "ブザㅡON時間";
                this.labelStaticRelayOnTime.Text = "リレㅡON時間";

                this.groupBoxBypass.Text = "バイパス";

                this.labelTitleLine1.Text = "列1";
                this.labelTitleLine2.Text = "列2";
                this.labelTitleLine3.Text = "列3";
                this.labelTitleLine4.Text = "列4";
                this.labelTitleLine5.Text = "列5";
                this.labelTitleLine6.Text = "列6";
                this.labelTitleLine7.Text = "列7";
                this.labelTitleLine8.Text = "列8";
                this.labelTitleLine9.Text = "列9";
                this.labelTitleLine10.Text = "列10";
                this.labelTitleLine11.Text = "列11";
                this.labelTitleLine12.Text = "列12";
                this.labelStaticBypass.Text = "バイパス";
                this.buttonSaveBypass.Text = "保存";

                this.groupBoxCount.Text = "カウンタ";
                this.labelStaticATPC.Text = "パスアラㅡム";

                this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnScreenDisable));
                this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnScreenDown));
                this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnScreenUp));
                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.jpnBackUp));
            }
            else
            {

            }
        }
        private void InitializeControl()
        {
            this.ChildControl1 = new ControlConfiguration1(this.ParentForm);
            this.Controls.Add(this.ChildControl1);
            this.ChildControl1.Location = new Point(0, 80);
            this.ChildControl1.Visible = false;

            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.Czech)
            {
                this.comboBoxZeroParameterMode.Items.Add("Režim1");
                this.comboBoxZeroParameterMode.Items.Add("Režim2");
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                this.comboBoxZeroParameterMode.Items.Add("Modus1");
                this.comboBoxZeroParameterMode.Items.Add("Modus2");
            }
            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.SelectedIndex = 0;
            this.comboBoxDecimalPlaces.SelectedIndexChanged += new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);
        }
        private void DefaultSetting()
        {
            this.CollectionBypassLabel = new Collection<SmartLabel>();
            this.CollectionBypassButton = new Collection<SmartButton>();

            this.CollectionBypassLabel.Clear();
            this.CollectionBypassButton.Clear();

            this.CollectionBypassLabel.Add(this.labelTitleLine1);
            this.CollectionBypassLabel.Add(this.labelTitleLine2);
            this.CollectionBypassLabel.Add(this.labelTitleLine3);
            this.CollectionBypassLabel.Add(this.labelTitleLine4);
            this.CollectionBypassLabel.Add(this.labelTitleLine5);
            this.CollectionBypassLabel.Add(this.labelTitleLine6);
            this.CollectionBypassLabel.Add(this.labelTitleLine7);
            this.CollectionBypassLabel.Add(this.labelTitleLine8);
            this.CollectionBypassLabel.Add(this.labelTitleLine9);
            this.CollectionBypassLabel.Add(this.labelTitleLine10);
            this.CollectionBypassLabel.Add(this.labelTitleLine11);
            this.CollectionBypassLabel.Add(this.labelTitleLine12);

            this.CollectionBypassButton.Add(this.buttonBypassLane1);
            this.CollectionBypassButton.Add(this.buttonBypassLane2);
            this.CollectionBypassButton.Add(this.buttonBypassLane3);
            this.CollectionBypassButton.Add(this.buttonBypassLane4);
            this.CollectionBypassButton.Add(this.buttonBypassLane5);
            this.CollectionBypassButton.Add(this.buttonBypassLane6);
            this.CollectionBypassButton.Add(this.buttonBypassLane7);
            this.CollectionBypassButton.Add(this.buttonBypassLane8);
            this.CollectionBypassButton.Add(this.buttonBypassLane9);
            this.CollectionBypassButton.Add(this.buttonBypassLane10);
            this.CollectionBypassButton.Add(this.buttonBypassLane11);
            this.CollectionBypassButton.Add(this.buttonBypassLane12);

            for (int i = this.ParentForm.SystemConfig.EquipmentColumns; i < 12; i++)
            {
                this.CollectionBypassLabel[i].Visible = false;
                this.CollectionBypassButton[i].Visible = false;
            }

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

        public void UpdateZeroParameterRangeDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.UpdateZeroParameterRangeDisplay(status, values);
        }
        public void UpdateZeroParameterTimeDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.UpdateZeroParameterTimeDisplay(status, values);
        }
        public void UpdateZeroParameterVariateDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.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.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();
            else
                this.buttonDoubleEnter.ButtonUp();
        }
        public void UpdateBalanceWeightDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.UpdateBalanceWeightDisplay(status, values);
        }
        public void UpdateMaxWeightDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.UpdateMaxWeightDisplay(status, values);
        }
        public void UpdateDigitDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.UpdateDigitDisplay(status, values);
        }
        public void UpdateFilterDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            this.ChildControl1.UpdateFilterDisplay(status, values);
        }

        public void DisplayRefresh()
        {
            string value = "";

            switch (this.ParentForm.SystemConfig.CurrentUser.Group)
            {
                case DataStore.UserGroup.Admin:
                case DataStore.UserGroup.Developer:
                    this.buttonScreen.Visible = true;
                    break;
                default:
                    this.buttonScreen.Visible = false;
                    break;
            }

            this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormConfiguration;
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoard1, CommunicationAddress._4901_ParameterRead, "");
            this.timerInterval.Enabled = true;
            this.buttonSaveBypass.Enabled = false;

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

            // 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();

            // Bypass
            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
            {
                if (this.ParentForm.CollectionWeightData[i].IsBypassMode == true)
                    this.CollectionBypassButton[i].ButtonDown();
                else
                    this.CollectionBypassButton[i].ButtonUp();
            }
        }
        #endregion

        #region Override Member
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.InitializeDesign();
        }
        #endregion

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

            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
        }
        private void buttonScreen_Click(object sender, EventArgs e)
        {
            if (this.ChildControl1.Visible == false)
            {
                this.ChildControl1.Visible = true;
                this.ChildControl1.BringToFront();
            }
            else
                this.ChildControl1.Visible = false;
        }

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

            before = this.labelZeroParameterTime.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterTime.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.labelZeroParameterTime.Text = myKeyPad.StringValue;
                    after = this.labelZeroParameterTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelZeroParameterTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4001_ZeroTime, value);

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

            before = this.labelZeroParameterRange.Text;

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

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

                    value = Helper.StringZeroFillDigits4(this.labelZeroParameterRange.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4002_ZeroRange, value);

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

            if (this.ParentForm.CurrentZeroParameterItem.Variate == "0")
                before = "0.05";
            else if (this.ParentForm.CurrentZeroParameterItem.Variate == "1")
                before = "0.1";
            else if (this.ParentForm.CurrentZeroParameterItem.Variate == "2")
                before = "0.2";
            else if (this.ParentForm.CurrentZeroParameterItem.Variate == "3")
                before = "0.5";
            else if (this.ParentForm.CurrentZeroParameterItem.Variate == "4")
                before = "1";
            else if (this.ParentForm.CurrentZeroParameterItem.Variate == "5")
                before = "1.2";
            else
                before = "0.05";

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

            value = Helper.StringZeroFillDigits4(this.ParentForm.CurrentZeroParameterItem.Variate);
            this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4003_ZeroVariate, value);

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

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

        }

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

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

            // Part 11
            if (this.ParentForm.SystemConfig.IsOptPart11 == true)

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

            before = this.labelChattering.Text;

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

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

                    value = Helper.StringZeroFillDigits4(this.labelChattering.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6006_Chattering, value);

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

            before = this.labelBuzzerOnTime.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelBuzzerOnTime.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.labelBuzzerOnTime.Text = myKeyPad.StringValue;
                    after = this.labelBuzzerOnTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelBuzzerOnTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6001_BuzzerOnTime, value);

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

            before = this.labelRelayOnTime.Text;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRelayOnTime.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.labelRelayOnTime.Text = myKeyPad.StringValue;
                    after = this.labelRelayOnTime.Text;

                    value = Helper.StringZeroFillDigits4(this.labelRelayOnTime.Text);
                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6002_RelayOperatingTime, value);

                    // Part 11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcRelayRunTime, "", before, after);
                }
            }
        }
        private void comboBoxDecimalPlaces_SelectedIndexChanged(object sender, EventArgs e)
        {
            string before = "", after = "";

            // Before
            if (this.ParentForm.SystemConfig.DecimalPlaces == 0)
                before = "0";
            else if (this.ParentForm.SystemConfig.DecimalPlaces == 1)
                before = "0.0";
            else if (this.ParentForm.SystemConfig.DecimalPlaces == 2)
                before = "0.00";
            else
                before = "0";

            // After
            if (this.comboBoxDecimalPlaces.SelectedIndex == 0)
                after = "0";
            else if (this.comboBoxDecimalPlaces.SelectedIndex == 1)
                after = "0.0";
            else if (this.comboBoxDecimalPlaces.SelectedIndex == 2)
                after = "0.00";
            else
                after = "0";

            // Part 11
            if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcDecimalpoint, "", before, after);

            this.ParentForm.SystemConfig.DecimalPlaces = this.comboBoxDecimalPlaces.SelectedIndex;
            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
        }

        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.IsOptPart11 == 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.IsOptPart11 == 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.IsOptPart11 == 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.IsOptPart11 == true)
                this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.ATPC_Activate, "", before, after);
        }

        private void timerInterval_Tick(object sender, EventArgs e)
        {
            this.timerInterval.Enabled = false;
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress._6901_ParameterRead, "");
        }

        private void buttonBypassLane_Click(object sender, EventArgs e)
        {
            int iTemp = 0;

            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
            {
                if (this.CollectionBypassButton[i].ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    iTemp++;
                }
            }

            if (iTemp == this.ParentForm.SystemConfig.EquipmentColumns)
                this.buttonBypassMode.ButtonDown();
            else
                this.buttonBypassMode.ButtonUp();

            this.buttonSaveBypass.Enabled = true;
        }
        private void buttonSaveBypass_Click(object sender, EventArgs e)
        {
            string before = "", after = "", lane = "";
            StringBuilder sb = new StringBuilder();

            if (this.ParentForm.SystemConfig.IsWeightViewForward == true)
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    if (this.CollectionBypassButton[i].ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                        sb.Append("1");
                    else
                        sb.Append("0");
                }
            }
            else
            {
                for (int i = 1; i <= this.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    if (this.CollectionBypassButton[this.ParentForm.SystemConfig.EquipmentColumns - i].ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                        sb.Append("1");
                    else
                        sb.Append("0");
                }
            }

            #region Lane 1
            if (this.buttonBypassLane1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[0].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[0].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "1";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[0].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[0].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "1";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion
            #region Lane 2
            // Lane 2
            if (this.buttonBypassLane2.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[1].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[1].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "2";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[1].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[1].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "2";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion
            #region Lane 3
            // Lane 3
            if (this.buttonBypassLane3.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[2].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[2].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "3";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[2].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[2].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "3";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion
            #region Lane 4
            // Lane 4
            if (this.buttonBypassLane4.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[3].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[3].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "4";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[3].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[3].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "4";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion
            #region Lane 5
            // Lane 5
            if (this.buttonBypassLane5.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[4].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[4].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "5";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[4].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[4].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "5";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion
            #region Lane 6
            // Lane 6
            if (this.buttonBypassLane6.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[5].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[5].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "6";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[5].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[5].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "6";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion
            #region Lane 7
            // Lane 7
            if (this.buttonBypassLane7.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                if (this.ParentForm.CollectionWeightData[6].IsBypassMode != true)
                {
                    this.ParentForm.CollectionWeightData[6].IsBypassMode = true;

                    before = "OFF";
                    after = "ON";
                    lane = "7";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            else
            {
                if (this.ParentForm.CollectionWeightData[6].IsBypassMode != false)
                {
                    this.ParentForm.CollectionWeightData[6].IsBypassMode = false;

                    before = "ON";
                    after = "OFF";
                    lane = "7";

                    // Part11
                    if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                        this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                }
            }
            #endregion

            if (this.ParentForm.SystemConfig.EquipmentColumns == 8)
            {
                #region 8열
                // Lane 8
                if (this.buttonBypassLane8.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                #endregion
            }
            else if (this.ParentForm.SystemConfig.EquipmentColumns == 10)
            {
                #region 10열
                // Lane 8
                if (this.buttonBypassLane8.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 9
                if (this.buttonBypassLane9.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[8].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[8].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "9";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[8].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[8].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "9";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 10
                if (this.buttonBypassLane10.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[9].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[9].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "10";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[9].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[9].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "10";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                #endregion
            }
            else if (this.ParentForm.SystemConfig.EquipmentColumns == 11)
            {
                #region 11열
                // Lane 8
                if (this.buttonBypassLane8.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 9
                if (this.buttonBypassLane9.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[8].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[8].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "9";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[8].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[8].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "9";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 10
                if (this.buttonBypassLane10.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[9].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[9].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "10";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[9].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[9].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "10";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 11
                if (this.buttonBypassLane11.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[10].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[10].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "11";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[10].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[10].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "11";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                #endregion
            }
            else if (this.ParentForm.SystemConfig.EquipmentColumns == 12)
            {
                #region 12열
                // Lane 8
                if (this.buttonBypassLane8.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[7].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[7].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "8";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 9
                if (this.buttonBypassLane9.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[8].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[8].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "9";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[8].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[8].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "9";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 10
                if (this.buttonBypassLane10.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[9].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[9].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "10";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[9].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[9].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "10";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 11
                if (this.buttonBypassLane11.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[10].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[10].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "11";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[10].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[10].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "11";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                // Lane 12
                if (this.buttonBypassLane12.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    if (this.ParentForm.CollectionWeightData[11].IsBypassMode != true)
                    {
                        this.ParentForm.CollectionWeightData[11].IsBypassMode = true;

                        before = "OFF";
                        after = "ON";
                        lane = "12";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                else
                {
                    if (this.ParentForm.CollectionWeightData[11].IsBypassMode != false)
                    {
                        this.ParentForm.CollectionWeightData[11].IsBypassMode = false;

                        before = "ON";
                        after = "OFF";
                        lane = "12";

                        // Part11
                        if (this.ParentForm.SystemConfig.IsOptPart11 == true)
                            this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.BP_Individual, lane, before, after);
                    }
                }
                #endregion
            }

            this.ParentForm.SystemConfig.IsBypassMode = false;
            for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
            {
                if (this.ParentForm.CollectionWeightData[i].IsBypassMode == true)
                {
                    this.ParentForm.SystemConfig.IsBypassMode = true;
                    break;
                }
            }

            this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString());
            this.buttonSaveBypass.Enabled = false;
        }
        private void buttonBypassMode_Click(object sender, EventArgs e)
        {
            string before = "", after = "";

            StringBuilder sb = new StringBuilder();

            if (this.buttonBypassMode.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    sb.Append("1");
                    this.CollectionBypassButton[i].ButtonDown();
                }
                this.ParentForm.SystemConfig.IsBypassMode = true;

                for (int i = 0; i < this.ParentForm.CollectionWeightData.Count; i++)
                    this.ParentForm.CollectionWeightData[i].IsBypassMode = true;

                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString());

                before = "OFF";
                after = "ON";
            }
            else
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    sb.Append("0");
                    this.CollectionBypassButton[i].ButtonUp();
                }
                this.ParentForm.SystemConfig.IsBypassMode = false;

                for (int i = 0; i < this.ParentForm.CollectionWeightData.Count; i++)
                    this.ParentForm.CollectionWeightData[i].IsBypassMode = false;

                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString());

                before = "ON";
                after = "OFF";
            }

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