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

using SmartX;
using ITC81DB_2.DialogForms;
using ITC81DB_2.Forms;
using ITC81DB_2_ImageDll;

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

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

            this.ParentForm = parent;

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

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

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

            if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.English)
            {
                #region English
                this.labelTitleSorter1.Text = "Sorter A";
                this.labelTitleSorter2.Text = "Sorter B";
                this.labelTitleSorterMode1.Text = this.labelTitleSorterMode2.Text = "Mode";
                this.labelTitleSorterDelayTime1.Text = this.labelTitleSorterDelayTime2.Text = "Delay time";
                this.labelTitleSorterRunTime1.Text = this.labelTitleSorterRunTime2.Text = "Run time";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "Time";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "Range";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "Variation";
                this.labelTitleAutoZero1.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.labelTitleAutoZero1.Text = "Auto zero 1";
                this.labelTitleAutoZero2.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.labelTitleAutoZero2.Text = "Auto zero 2";
                this.labelTitleBypass1.Text = "Bypass1";
                this.labelTitleBypass2.Text = "Bypass2";

                this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
                this.comboBoxSorter1Mode.Items.Clear();
                this.comboBoxSorter1Mode.Items.Add("None");
                this.comboBoxSorter1Mode.Items.Add("Over");
                this.comboBoxSorter1Mode.Items.Add("Under");
                this.comboBoxSorter1Mode.Items.Add("NG");
                this.comboBoxSorter1Mode.SelectedIndex = 0;
                this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);

                this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
                this.comboBoxSorter2Mode.Items.Clear();
                this.comboBoxSorter2Mode.Items.Add("None");
                this.comboBoxSorter2Mode.Items.Add("Over");
                this.comboBoxSorter2Mode.Items.Add("Under");
                this.comboBoxSorter2Mode.Items.Add("NG");
                this.comboBoxSorter2Mode.SelectedIndex = 0;
                this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

                this.comboBoxAutoZeroMode1.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);
                this.comboBoxAutoZeroMode1.Items.Clear();
                this.comboBoxAutoZeroMode1.Items.Add("High");
                this.comboBoxAutoZeroMode1.Items.Add("Middle");
                this.comboBoxAutoZeroMode1.Items.Add("Low");
                this.comboBoxAutoZeroMode1.Items.Add("User setting");
                this.comboBoxAutoZeroMode1.SelectedIndex = 0;
                this.comboBoxAutoZeroMode1.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);

                this.comboBoxAutoZeroMode2.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);
                this.comboBoxAutoZeroMode2.Items.Clear();
                this.comboBoxAutoZeroMode2.Items.Add("High");
                this.comboBoxAutoZeroMode2.Items.Add("Middle");
                this.comboBoxAutoZeroMode2.Items.Add("Low");
                this.comboBoxAutoZeroMode2.Items.Add("User setting");
                this.comboBoxAutoZeroMode2.SelectedIndex = 0;
                this.comboBoxAutoZeroMode2.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);

                this.buttonBypassOnce1.DownImage = this.buttonBypassOnce2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBypassCountDown));
                this.buttonBypassOnce1.UpImage = this.buttonBypassOnce2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBypassCountUp));
                this.buttonBypassDirection1.DownImage = this.buttonBypassDirection2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBypassOccasionDown));
                this.buttonBypassDirection1.UpImage = this.buttonBypassDirection2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBypassOccasionUp));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Chinese)
            {
                #region Chinese
                this.labelTitleSorter1.Text = "分类机 A";
                this.labelTitleSorter2.Text = "分类机 B";
                this.labelTitleSorterMode1.Text = this.labelTitleSorterMode2.Text = "模式";
                this.labelTitleSorterDelayTime1.Text = this.labelTitleSorterDelayTime2.Text = "延迟时间";
                this.labelTitleSorterRunTime1.Text = this.labelTitleSorterRunTime2.Text = "运行时间";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "时间";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "范围";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "变化";
                this.labelTitleAutoZero1.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.labelTitleAutoZero1.Text = "自动零点 1";
                this.labelTitleAutoZero2.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.labelTitleAutoZero2.Text = "自动零点 2";
                this.labelTitleBypass1.Text = "选别选项1";
                this.labelTitleBypass2.Text = "选别选项2";

                this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
                this.comboBoxSorter1Mode.Items.Clear();
                this.comboBoxSorter1Mode.Items.Add("不使用");
                this.comboBoxSorter1Mode.Items.Add("上限");
                this.comboBoxSorter1Mode.Items.Add("下限");
                this.comboBoxSorter1Mode.Items.Add("剔除");
                this.comboBoxSorter1Mode.SelectedIndex = 0;
                this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);

                this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
                this.comboBoxSorter2Mode.Items.Clear();
                this.comboBoxSorter2Mode.Items.Add("不使用");
                this.comboBoxSorter2Mode.Items.Add("上限");
                this.comboBoxSorter2Mode.Items.Add("下限");
                this.comboBoxSorter2Mode.Items.Add("剔除");
                this.comboBoxSorter2Mode.SelectedIndex = 0;
                this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

                this.comboBoxAutoZeroMode1.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);
                this.comboBoxAutoZeroMode1.Items.Clear();
                this.comboBoxAutoZeroMode1.Items.Add("高");
                this.comboBoxAutoZeroMode1.Items.Add("中间");
                this.comboBoxAutoZeroMode1.Items.Add("低");
                this.comboBoxAutoZeroMode1.Items.Add("用户设置");
                this.comboBoxAutoZeroMode1.SelectedIndex = 0;
                this.comboBoxAutoZeroMode1.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);

                this.comboBoxAutoZeroMode2.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);
                this.comboBoxAutoZeroMode2.Items.Clear();
                this.comboBoxAutoZeroMode2.Items.Add("高");
                this.comboBoxAutoZeroMode2.Items.Add("中间");
                this.comboBoxAutoZeroMode2.Items.Add("低");
                this.comboBoxAutoZeroMode2.Items.Add("用户设置");
                this.comboBoxAutoZeroMode2.SelectedIndex = 0;
                this.comboBoxAutoZeroMode2.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);

                this.buttonBypassOnce1.DownImage = this.buttonBypassOnce2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnBypassCountDown));
                this.buttonBypassOnce1.UpImage = this.buttonBypassOnce2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnBypassCountUp));
                this.buttonBypassDirection1.DownImage = this.buttonBypassDirection2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnBypassOccasionDown));
                this.buttonBypassDirection1.UpImage = this.buttonBypassDirection2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnBypassOccasionUp));
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == Define.E_LanguageID.Spanish)
            {
                #region English
                this.labelTitleSorter1.Text = "Clasificador A";
                this.labelTitleSorter2.Text = "Clasificador B";
                this.labelTitleSorterMode1.Text = this.labelTitleSorterMode2.Text = "Modo";
                this.labelTitleSorterDelayTime1.Text = this.labelTitleSorterDelayTime2.Text = "Retardo";
                this.labelTitleSorterRunTime1.Text = this.labelTitleSorterRunTime2.Text = "Ejecución";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "Tiempo";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "Distancia";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "Variation";
                this.labelTitleAutoZero1.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.labelTitleAutoZero1.Text = "Seguimiento de cero 1";
                this.labelTitleAutoZero2.Font = new Font("새굴림", 9, FontStyle.Bold);
                this.labelTitleAutoZero2.Text = "Seguimiento de cero 2";
                this.labelTitleBypass1.Text = "Bypass 1";
                this.labelTitleBypass2.Text = "Bypass 2";

                this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
                this.comboBoxSorter1Mode.Items.Clear();
                this.comboBoxSorter1Mode.Items.Add("Ninguna");
                this.comboBoxSorter1Mode.Items.Add("Superior");
                this.comboBoxSorter1Mode.Items.Add("Inferior");
                this.comboBoxSorter1Mode.Items.Add("Rechazo");
                this.comboBoxSorter1Mode.SelectedIndex = 0;
                this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);

                this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
                this.comboBoxSorter2Mode.Items.Clear();
                this.comboBoxSorter2Mode.Items.Add("Ninguna");
                this.comboBoxSorter2Mode.Items.Add("Superior");
                this.comboBoxSorter2Mode.Items.Add("Inferior");
                this.comboBoxSorter2Mode.Items.Add("Rechazo");
                this.comboBoxSorter2Mode.SelectedIndex = 0;
                this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

                this.comboBoxAutoZeroMode1.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);
                this.comboBoxAutoZeroMode1.Items.Clear();
                this.comboBoxAutoZeroMode1.Items.Add("Alto");
                this.comboBoxAutoZeroMode1.Items.Add("Medio");
                this.comboBoxAutoZeroMode1.Items.Add("Bajo");
                this.comboBoxAutoZeroMode1.Items.Add("Usuario");
                this.comboBoxAutoZeroMode1.SelectedIndex = 0;
                this.comboBoxAutoZeroMode1.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);

                this.comboBoxAutoZeroMode2.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);
                this.comboBoxAutoZeroMode2.Items.Clear();
                this.comboBoxAutoZeroMode2.Items.Add("Alto");
                this.comboBoxAutoZeroMode2.Items.Add("Medio");
                this.comboBoxAutoZeroMode2.Items.Add("Bajo");
                this.comboBoxAutoZeroMode2.Items.Add("Usuario");
                this.comboBoxAutoZeroMode2.SelectedIndex = 0;
                this.comboBoxAutoZeroMode2.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);

                this.buttonBypassOnce1.DownImage = this.buttonBypassOnce2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnBypassCountDown));
                this.buttonBypassOnce1.UpImage = this.buttonBypassOnce2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnBypassCountUp));
                this.buttonBypassDirection1.DownImage = this.buttonBypassDirection2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnBypassOccasionDown));
                this.buttonBypassDirection1.UpImage = this.buttonBypassDirection2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.spnBypassOccasionUp));
                #endregion
            }
            else
            {
                #region Korean
                this.labelTitleSorter1.Text = "선별부 A";
                this.labelTitleSorter2.Text = "선별부 B";
                this.labelTitleSorterMode1.Text = this.labelTitleSorterMode2.Text = "모드";
                this.labelTitleSorterDelayTime1.Text = this.labelTitleSorterDelayTime2.Text = "지연시간";
                this.labelTitleSorterRunTime1.Text = this.labelTitleSorterRunTime2.Text = "동작시간";
                this.labelTitleTime1.Text = this.labelTitleTime2.Text = "시간";
                this.labelTitleRange1.Text = this.labelTitleRange2.Text = "범위";
                this.labelTitleVariation1.Text = this.labelTitleVariation2.Text = "변량";
                this.labelTitleAutoZero1.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.labelTitleAutoZero1.Text = "자동영점 1";
                this.labelTitleAutoZero2.Font = new Font("새굴림", 12, FontStyle.Bold);
                this.labelTitleAutoZero2.Text = "자동영점 2";
                this.labelTitleBypass1.Text = "Bypass1";
                this.labelTitleBypass2.Text = "Bypass2";

                this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
                this.comboBoxSorter1Mode.Items.Clear();
                this.comboBoxSorter1Mode.Items.Add("사용안함");
                this.comboBoxSorter1Mode.Items.Add("과량");
                this.comboBoxSorter1Mode.Items.Add("경량");
                this.comboBoxSorter1Mode.Items.Add("불량");
                this.comboBoxSorter1Mode.SelectedIndex = 0;
                this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);

                this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
                this.comboBoxSorter2Mode.Items.Clear();
                this.comboBoxSorter2Mode.Items.Add("사용안함");
                this.comboBoxSorter2Mode.Items.Add("과량");
                this.comboBoxSorter2Mode.Items.Add("경량");
                this.comboBoxSorter2Mode.Items.Add("불량");
                this.comboBoxSorter2Mode.SelectedIndex = 0;
                this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

                this.comboBoxAutoZeroMode1.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);
                this.comboBoxAutoZeroMode1.Items.Clear();
                this.comboBoxAutoZeroMode1.Items.Add("High");
                this.comboBoxAutoZeroMode1.Items.Add("Middle");
                this.comboBoxAutoZeroMode1.Items.Add("Low");
                this.comboBoxAutoZeroMode1.Items.Add("User setting");
                this.comboBoxAutoZeroMode1.SelectedIndex = 0;
                this.comboBoxAutoZeroMode1.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);

                this.comboBoxAutoZeroMode2.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);
                this.comboBoxAutoZeroMode2.Items.Clear();
                this.comboBoxAutoZeroMode2.Items.Add("High");
                this.comboBoxAutoZeroMode2.Items.Add("Middle");
                this.comboBoxAutoZeroMode2.Items.Add("Low");
                this.comboBoxAutoZeroMode2.Items.Add("User setting");
                this.comboBoxAutoZeroMode2.SelectedIndex = 0;
                this.comboBoxAutoZeroMode2.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);

                this.buttonBypassOnce1.DownImage = this.buttonBypassOnce2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korBypassCountDown));
                this.buttonBypassOnce1.UpImage = this.buttonBypassOnce2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korBypassCountUp));
                this.buttonBypassDirection1.DownImage = this.buttonBypassDirection2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBypassOccasionDown));
                this.buttonBypassDirection1.UpImage = this.buttonBypassDirection2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBypassOccasionUp));
                #endregion
            }
        }
        private void DefaultSetting()
        {
            this.comboBoxMode1Variate1.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);
            this.comboBoxMode1Variate1.Items.Clear();
            this.comboBoxMode1Variate1.Items.Add(0.1);
            this.comboBoxMode1Variate1.Items.Add(0.2);
            this.comboBoxMode1Variate1.Items.Add(0.5);
            this.comboBoxMode1Variate1.Items.Add(1.0);
            this.comboBoxMode1Variate1.SelectedIndex = 0;
            this.comboBoxMode1Variate1.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);

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

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

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

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

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

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

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

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

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

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

        private void UpdateDisplayUser(UserItem user)
        {
            switch (user.Group)
            {
                case Define.E_UserGroup.LogOut:
                    this.groupBoxSorter.Enabled = false;
                    this.groupBoxAutoZero.Enabled = false;
                    break;
                case Define.E_UserGroup.Level1:
                    this.groupBoxSorter.Enabled = false;
                    this.groupBoxAutoZero.Enabled = false;
                    break;
                case Define.E_UserGroup.Level2:
                    this.groupBoxSorter.Enabled = true;
                    this.groupBoxAutoZero.Enabled = true;
                    break;
                case Define.E_UserGroup.Level3:
                    this.groupBoxSorter.Enabled = true;
                    this.groupBoxAutoZero.Enabled = true;
                    break;
                case Define.E_UserGroup.Developer:
                    this.groupBoxSorter.Enabled = true;
                    this.groupBoxAutoZero.Enabled = true;
                    break;
                default:
                    this.groupBoxSorter.Enabled = false;
                    this.groupBoxAutoZero.Enabled = false;
                    break;
            }
        }
        private void UpdateControl(JudgmentSetItem item1,JudgmentSetItem item2, SystemParameter9510 parameter1, SystemParameter9511 parameter2)
        {
            int iValue = 0;
            string value = "";

            #region Sorter
            this.comboBoxSorter1Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
            this.comboBoxSorter2Mode.SelectedIndexChanged -= new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);

            // 선별기1 모드
            iValue = item1.Sorter1Mode;
            if (this.comboBoxSorter1Mode.SelectedIndex != iValue)
                this.comboBoxSorter1Mode.SelectedIndex = iValue;

            // 선별기1 지연시간
            iValue = item1.Sorter1DelayTime;
            if (this.labelSorter1DelayTime.Text != iValue.ToString())
                this.labelSorter1DelayTime.Text = iValue.ToString();

            // 선별기1 동작시간
            iValue = item1.Sorter1RunTime;
            if (this.labelSorter1RunTime.Text != iValue.ToString())
                this.labelSorter1RunTime.Text = iValue.ToString();

            // 선별기2 모드
            iValue = item2.Sorter1Mode;
            if (this.comboBoxSorter2Mode.SelectedIndex != iValue)
                this.comboBoxSorter2Mode.SelectedIndex = iValue;

            // 선별기2 지연시간
            iValue = item2.Sorter1DelayTime;
            if (this.labelSorter2DelayTime.Text != iValue.ToString())
                this.labelSorter2DelayTime.Text = iValue.ToString();

            // 선별기2 동작시간
            iValue = item2.Sorter1RunTime;
            if (this.labelSorter2RunTime.Text != iValue.ToString())
                this.labelSorter2RunTime.Text = iValue.ToString();

            this.comboBoxSorter1Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter1Mode_SelectedIndexChanged);
            this.comboBoxSorter2Mode.SelectedIndexChanged += new EventHandler(this.comboBoxSorter2Mode_SelectedIndexChanged);
            #endregion

            #region AutoZero Line1
            // Mode 1
            this.UpdateZero1ParameterDisplay(parameter1);
            #endregion

            #region AutoZero Line2
            // Mode 1
            this.UpdateZero2ParameterDisplay(parameter2);
            #endregion
        }

        public void UpdateZero1ParameterDisplay(SystemParameter9510 item)
        {
            int iValue = 0;
            string value = "";

            // Mode 1
            this.comboBoxAutoZeroMode1.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);
            iValue = int.Parse(item.AutoZero1Mode.Trim());
            if (iValue == 1)
            {
                this.comboBoxAutoZeroMode1.SelectedIndex = 2;
                this.ControlEnableMode1(false, false, false);
            }
            else if (iValue == 2)
            {
                this.comboBoxAutoZeroMode1.SelectedIndex = 1;
                this.ControlEnableMode1(false, false, false);
            }
            else if (iValue == 3)
            {
                this.comboBoxAutoZeroMode1.SelectedIndex = 0;
                this.ControlEnableMode1(false, false, false);
            }
            else if (iValue == 4)
            {
                this.comboBoxAutoZeroMode1.SelectedIndex = 3;
                this.ControlEnableMode1(true, true, true);
            }
            else
            {
                this.comboBoxAutoZeroMode1.SelectedIndex = 3;
                this.ControlEnableMode1(true, true, true);
            }
            this.comboBoxAutoZeroMode1.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode1_SelectedIndexChanged);

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

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

            // Mode1 Variate
            iValue = int.Parse(item.AutoZero1Variate.Trim());
            this.comboBoxMode1Variate1.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);
            if (this.comboBoxMode1Variate1.Items.Count > iValue)
                this.comboBoxMode1Variate1.SelectedIndex = iValue;
            else
                this.comboBoxMode1Variate1.SelectedIndex = 0;
            this.comboBoxMode1Variate1.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate1_SelectedIndexChanged);

        }
        public void UpdateZero2ParameterDisplay(SystemParameter9511 item)
        {
            int iValue = 0;
            string value = "";

            // Mode 1
            this.comboBoxAutoZeroMode2.SelectedIndexChanged -= new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);
            iValue = int.Parse(item.AutoZero1Mode.Trim());
            if (iValue == 1)
            {
                this.comboBoxAutoZeroMode2.SelectedIndex = 2;
                this.ControlEnableMode2(false, false, false);
            }
            else if (iValue == 2)
            {
                this.comboBoxAutoZeroMode2.SelectedIndex = 1;
                this.ControlEnableMode2(false, false, false);
            }
            else if (iValue == 3)
            {
                this.comboBoxAutoZeroMode2.SelectedIndex = 0;
                this.ControlEnableMode2(false, false, false);
            }
            else if (iValue == 4)
            {
                this.comboBoxAutoZeroMode2.SelectedIndex = 3;
                this.ControlEnableMode2(true, true, true);
            }
            else
            {
                this.comboBoxAutoZeroMode2.SelectedIndex = 3;
                this.ControlEnableMode2(true, true, true);
            }
            this.comboBoxAutoZeroMode2.SelectedIndexChanged += new EventHandler(this.comboBoxAutoZeroMode2_SelectedIndexChanged);

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

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

            // Mode1 Variate
            iValue = int.Parse(item.AutoZero1Variate.Trim());
            this.comboBoxMode1Variate2.SelectedIndexChanged -= new EventHandler(this.comboBoxMode1Variate2_SelectedIndexChanged);
            if (this.comboBoxMode1Variate2.Items.Count > iValue)
                this.comboBoxMode1Variate2.SelectedIndex = iValue;
            else
                this.comboBoxMode1Variate2.SelectedIndex = 0;
            this.comboBoxMode1Variate2.SelectedIndexChanged += new EventHandler(this.comboBoxMode1Variate2_SelectedIndexChanged);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.UpdateDisplayUser(status.CurrentUser);
            this.UpdateControl(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.CurrentJudgmentSetItem2,
                this.ParentForm.ParentForm.CurrentSystemParameter9510, this.ParentForm.ParentForm.CurrentSystemParameter9511);

            this.Focus();
        }
        #endregion

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

            if (this.comboBoxSorter1Mode.Items.Count == 0)
                return;

            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode = this.comboBoxSorter1Mode.SelectedIndex;
            value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1Mode.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5101_Sorter1Mode, value);
        }
        private void labelSorter1DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";

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

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

                    this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1DelayTime = myKeyPad.IntValue;
                    this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits4(this.labelSorter1DelayTime.Text);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5102_Sorter1DelayTime, value);
                }
            }
        }
        private void labelSorter1RunTime_Click(object sender, EventArgs e)
        {
            string value = "";

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

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

                    this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter1RunTime = myKeyPad.IntValue;
                    this.ParentForm.ParentForm.SaveJudgmentSetFile1(this.ParentForm.ParentForm.CurrentJudgmentSetItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits4(this.labelSorter1RunTime.Text);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5103_Sorter1RunTime, value);
                }
            }
        }

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

            if (this.comboBoxSorter2Mode.Items.Count == 0)
                return;

            this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode = this.comboBoxSorter2Mode.SelectedIndex;
            value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentJudgmentSetItem1.Sorter2Mode.ToString());
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5104_Sorter2Mode, value);
        }
        private void labelSorter2DelayTime_Click(object sender, EventArgs e)
        {
            string value = "";

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

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

                    this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1DelayTime = myKeyPad.IntValue;
                    this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits4(this.labelSorter2DelayTime.Text);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5105_Sorter2DelayTime, value);
                }
            }
        }
        private void labelSorter2RunTime_Click(object sender, EventArgs e)
        {
            string value = "";

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

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

                    this.ParentForm.ParentForm.CurrentJudgmentSetItem2.Sorter1RunTime = myKeyPad.IntValue;
                    this.ParentForm.ParentForm.SaveJudgmentSetFile2(this.ParentForm.ParentForm.CurrentJudgmentSetItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                    value = Helper.StringZeroFillDigits4(this.labelSorter2RunTime.Text);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5106_Sorter2RunTime, value);
                }
            }
        }

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

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

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

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

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

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

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Time);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4001_Zero1Time, value);
                }
            }
        }
        private void comboBoxAutoZeroMode1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            if (this.comboBoxAutoZeroMode1.SelectedIndex == 0) // High
                value = "0003";
            else if (this.comboBoxAutoZeroMode1.SelectedIndex == 1) // Middle
                value = "0002";
            else if (this.comboBoxAutoZeroMode1.SelectedIndex == 2) // Low
                value = "0001";
            else if (this.comboBoxAutoZeroMode1.SelectedIndex == 3) // User
                value = "0004";

            this.ParentForm.ParentForm.CurrentSystemParameter9510.AutoZero1Mode = value;

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

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

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

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

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

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

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

                    value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter9511.AutoZero1Time);
                    this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._4021_Zero1Time, value);
                }
            }
        }
        private void comboBoxAutoZeroMode2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = "";

            if (this.comboBoxAutoZeroMode2.SelectedIndex == 0) // High
                value = "0003";
            else if (this.comboBoxAutoZeroMode2.SelectedIndex == 1) // Middle
                value = "0002";
            else if (this.comboBoxAutoZeroMode2.SelectedIndex == 2) // Low
                value = "0001";
            else if (this.comboBoxAutoZeroMode2.SelectedIndex == 3) // User
                value = "0004";

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

        private void buttonBypassDirection1_Click(object sender, EventArgs e)
        {
            if (this.buttonBypassDirection1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass1 = false;
            else
                this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass1 = true;
        }
        private void buttonBypassOnce1_Click(object sender, EventArgs e)
        {
            if (this.buttonBypassOnce1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.SystemConfig.IsBypassOnce1 = false;
                this.buttonBypassRun1.Mode = SmartButton.BUTTONMODE.PUSH;
            }
            else
            {
                this.ParentForm.ParentForm.SystemConfig.IsBypassOnce1 = true;
                this.buttonBypassRun1.Mode = SmartButton.BUTTONMODE.NORMAL;
            }
        }
        private void buttonBypassRun1_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.ParentForm.SystemConfig.IsBypassOnce1 == true)
            {
                if (this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass1 == true)
                    this.ParentForm.ParentForm.TransferData(CommunicationCommand.BypassOnce, CommunicationID.SubBoard1);
                else
                    this.ParentForm.ParentForm.TransferData(CommunicationCommand.ByNGOnce, CommunicationID.SubBoard1);
            }
            else
            {
                if (this.buttonBypassRun1.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    this.buttonBypassDirection1.Enabled = false;
                    this.buttonBypassOnce1.Enabled = false;

                    if (this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass1 == true)
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.BypassON, CommunicationID.SubBoard1);
                    else
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.ByNGON, CommunicationID.SubBoard1);
                }
                else
                {
                    this.buttonBypassDirection1.Enabled = true;
                    this.buttonBypassOnce1.Enabled = true;

                    if (this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass1 == true)
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.BypassOFF, CommunicationID.SubBoard1);
                    else
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.ByNGOFF, CommunicationID.SubBoard1);
                }
            }
        }

        private void buttonBypassDirection2_Click(object sender, EventArgs e)
        {
            if (this.buttonBypassDirection2.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass2 = false;
            else
                this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass2 = true;
        }
        private void buttonBypassOnce2_Click(object sender, EventArgs e)
        {
            if (this.buttonBypassOnce2.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.ParentForm.SystemConfig.IsBypassOnce2 = false;
                this.buttonBypassRun2.Mode = SmartButton.BUTTONMODE.PUSH;
            }
            else
            {
                this.ParentForm.ParentForm.SystemConfig.IsBypassOnce2 = true;
                this.buttonBypassRun2.Mode = SmartButton.BUTTONMODE.NORMAL;
            }
        }
        private void buttonBypassRun2_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.ParentForm.SystemConfig.IsBypassOnce2 == true)
            {
                if (this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass2 == true)
                    this.ParentForm.ParentForm.TransferData(CommunicationCommand.BypassOnce, CommunicationID.SubBoard2);
                else
                    this.ParentForm.ParentForm.TransferData(CommunicationCommand.ByNGOnce, CommunicationID.SubBoard2);
            }
            else
            {
                if (this.buttonBypassRun2.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                {
                    this.buttonBypassDirection2.Enabled = false;
                    this.buttonBypassOnce2.Enabled = false;

                    if (this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass2 == true)
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.BypassON, CommunicationID.SubBoard2);
                    else
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.ByNGON, CommunicationID.SubBoard2);
                }
                else
                {
                    this.buttonBypassDirection2.Enabled = true;
                    this.buttonBypassOnce2.Enabled = true;

                    if (this.ParentForm.ParentForm.SystemConfig.IsBypassDirectionPass2 == true)
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.BypassOFF, CommunicationID.SubBoard2);
                    else
                        this.ParentForm.ParentForm.TransferData(CommunicationCommand.ByNGOFF, CommunicationID.SubBoard2);
                }
            }
        }
        #endregion
    }
}
