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

using SmartX;
using INT89DB_26_ImageDll;
using INT89DB_26.DialogForms;

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

        private Collection<SmartLabel> CollectionZeroParameterRangeLabel;
        private Collection<SmartLabel> CollectionZeroParameterTimeLabel;
        private Collection<SmartLabel> CollectionZeroParameterVariateLabel;
        private Collection<SmartLabel> CollectionMaxWeightLabel;
        private Collection<SmartLabel> CollectionBalanceWeightLabel;
        private Collection<SmartLabel> CollectionDigitLabel;
        private Collection<SmartLabel> CollectionFilterLabel;
        #endregion

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

            this.ParentForm = parent;
        }
        #endregion

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

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

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

            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.E_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.labelStaticBuzzerOnTime.Text = "Buzzer ON time";
                this.labelStaticRelayOnTime.Text = "Relay ON time";
                this.labelStaticBypass.Text = "Bypass";
                this.labelStaticChattering.Text = "Chattering";
                this.labelStaticDecimalPoint.Text = "Decimal point";

                this.buttonBack.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.E_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.labelStaticBypass.Text = "旁路";

                this.buttonBypassMode.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnEnable));
                this.buttonBypassMode.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnDisable));
                this.buttonDoubleEnter.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnEnable));
                this.buttonDoubleEnter.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnDisable));

                this.buttonBack.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.E_LanguageID.Czech)
            {

            }
            else
            {

            }
        }
        private void InitializeControl()
        {
            this.panelSpecialMenu.Location = new Point(0, 140);
            this.panelSpecialMenu.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.E_LanguageID.Chinese)
            {
                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.CollectionZeroParameterRangeLabel = new Collection<SmartLabel>();
            this.CollectionZeroParameterTimeLabel = new Collection<SmartLabel>();
            this.CollectionZeroParameterVariateLabel = new Collection<SmartLabel>();
            this.CollectionMaxWeightLabel = new Collection<SmartLabel>();
            this.CollectionBalanceWeightLabel = new Collection<SmartLabel>();
            this.CollectionDigitLabel = new Collection<SmartLabel>();
            this.CollectionFilterLabel = new Collection<SmartLabel>();

            this.CollectionZeroParameterRangeLabel.Clear();
            this.CollectionZeroParameterTimeLabel.Clear();
            this.CollectionZeroParameterVariateLabel.Clear();
            this.CollectionMaxWeightLabel.Clear();
            this.CollectionBalanceWeightLabel.Clear();
            this.CollectionDigitLabel.Clear();
            this.CollectionFilterLabel.Clear();

            this.CollectionZeroParameterRangeLabel.Add(this.labelZeroRange1);
            this.CollectionZeroParameterRangeLabel.Add(this.labelZeroRange2);
            this.CollectionZeroParameterRangeLabel.Add(this.labelZeroRange3);
            this.CollectionZeroParameterRangeLabel.Add(this.labelZeroRange4);
            this.CollectionZeroParameterRangeLabel.Add(this.labelZeroRange5);
            this.CollectionZeroParameterRangeLabel.Add(this.labelZeroRange6);

            this.CollectionZeroParameterTimeLabel.Add(this.labelZeroTime1);
            this.CollectionZeroParameterTimeLabel.Add(this.labelZeroTime2);
            this.CollectionZeroParameterTimeLabel.Add(this.labelZeroTime3);
            this.CollectionZeroParameterTimeLabel.Add(this.labelZeroTime4);
            this.CollectionZeroParameterTimeLabel.Add(this.labelZeroTime5);
            this.CollectionZeroParameterTimeLabel.Add(this.labelZeroTime6);

            this.CollectionZeroParameterVariateLabel.Add(this.labelZeroVariate1);
            this.CollectionZeroParameterVariateLabel.Add(this.labelZeroVariate2);
            this.CollectionZeroParameterVariateLabel.Add(this.labelZeroVariate3);
            this.CollectionZeroParameterVariateLabel.Add(this.labelZeroVariate4);
            this.CollectionZeroParameterVariateLabel.Add(this.labelZeroVariate5);
            this.CollectionZeroParameterVariateLabel.Add(this.labelZeroVariate6);

            this.CollectionMaxWeightLabel.Add(this.labelMaxWeight1);
            this.CollectionMaxWeightLabel.Add(this.labelMaxWeight2);
            this.CollectionMaxWeightLabel.Add(this.labelMaxWeight3);
            this.CollectionMaxWeightLabel.Add(this.labelMaxWeight4);
            this.CollectionMaxWeightLabel.Add(this.labelMaxWeight5);
            this.CollectionMaxWeightLabel.Add(this.labelMaxWeight6);

            this.CollectionBalanceWeightLabel.Add(this.labelBalanceWeight1);
            this.CollectionBalanceWeightLabel.Add(this.labelBalanceWeight2);
            this.CollectionBalanceWeightLabel.Add(this.labelBalanceWeight3);
            this.CollectionBalanceWeightLabel.Add(this.labelBalanceWeight4);
            this.CollectionBalanceWeightLabel.Add(this.labelBalanceWeight5);
            this.CollectionBalanceWeightLabel.Add(this.labelBalanceWeight6);

            this.CollectionDigitLabel.Add(this.labelDigit1);
            this.CollectionDigitLabel.Add(this.labelDigit2);
            this.CollectionDigitLabel.Add(this.labelDigit3);
            this.CollectionDigitLabel.Add(this.labelDigit4);
            this.CollectionDigitLabel.Add(this.labelDigit5);
            this.CollectionDigitLabel.Add(this.labelDigit6);

            this.CollectionFilterLabel.Add(this.labelFilter1);
            this.CollectionFilterLabel.Add(this.labelFilter2);
            this.CollectionFilterLabel.Add(this.labelFilter3);
            this.CollectionFilterLabel.Add(this.labelFilter4);
            this.CollectionFilterLabel.Add(this.labelFilter5);
            this.CollectionFilterLabel.Add(this.labelFilter6);

            for (int i = 0; i < 6; i++)
            {
                this.CollectionZeroParameterRangeLabel[i].Text = "";
                this.CollectionZeroParameterTimeLabel[i].Text = "";
                this.CollectionZeroParameterVariateLabel[i].Text = "";
                this.CollectionMaxWeightLabel[i].Text = "";
                this.CollectionBalanceWeightLabel[i].Text = "";
                this.CollectionDigitLabel[i].Text = "";
                this.CollectionFilterLabel[i].Text = "";
            }

            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)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
                this.CollectionZeroParameterRangeLabel[i].Text = values[i];
        }
        public void UpdateZeroParameterTimeDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
                this.CollectionZeroParameterTimeLabel[i].Text = values[i];
        }
        public void UpdateZeroParameterVariateDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
            {
                if (values[i].Trim() == "0")
                    this.CollectionZeroParameterVariateLabel[i].Text = "0.05";
                else if (values[i].Trim() == "1")
                    this.CollectionZeroParameterVariateLabel[i].Text = "0.1";
                else if (values[i].Trim() == "2")
                    this.CollectionZeroParameterVariateLabel[i].Text = "0.2";
                else if (values[i].Trim() == "3")
                    this.CollectionZeroParameterVariateLabel[i].Text = "0.5";
                else if (values[i].Trim() == "4")
                    this.CollectionZeroParameterVariateLabel[i].Text = "1";
            }
        }
        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)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
                this.CollectionBalanceWeightLabel[i].Text = values[i];
        }
        public void UpdateMaxWeightDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
                this.CollectionMaxWeightLabel[i].Text = values[i];
        }
        public void UpdateDigitDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
                this.CollectionDigitLabel[i].Text = values[i];
        }
        public void UpdateFilterDisplay(DataStore.EquipmentStatus status, Collection<string> values)
        {
            if (values == null || values.Count == 0)
                return;

            for (int i = 0; i < values.Count; i++)
                this.CollectionFilterLabel[i].Text = values[i];
        }

        public void DisplayRefresh()
        {
            this.comboBoxDecimalPlaces.SelectedIndexChanged -= new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);
            this.comboBoxDecimalPlaces.SelectedIndex = this.ParentForm.SystemConfig.DecimalPlaces;
            this.comboBoxDecimalPlaces.SelectedIndexChanged += new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged);

            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoard1, CommunicationAddress.ParameterRead4901, "");
            this.timerInterval.Enabled = true;
        }
        #endregion

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

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

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

            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.E_FormStore.FormMenu);
        }
        private void buttonDoubleEnter_Click(object sender, EventArgs e)
        {
            if (this.buttonDoubleEnter.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.DoubleEnter, Helper.StringZeroFillDigits4("1"));
            else
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.DoubleEnter, Helper.StringZeroFillDigits4("0"));
        }
        private void buttonBypassMode_Click(object sender, EventArgs e)
        {
            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.ParentForm.SystemConfig.IsBypassMode = true;
                this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.Bypass, sb.ToString());
            }
            else
            {
                for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
                    sb.Append("0");

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

        private void labelZeroParameterTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

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

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.ZeroTime, value);
                }
            }
        }
        private void labelZeroParameterRange_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterRange.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

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

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.ZeroRange, value);
                }
            }
        }
        private void labelChattering_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelChattering.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

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

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.Chattering, value);
                }
            }
        }
        private void labelBuzzerOnTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelBuzzerOnTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

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

                    this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.BuzzerOnTime, value);
                }
            }
        }
        private void labelRelayOnTime_Click(object sender, EventArgs e)
        {
            string value = "";
            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRelayOnTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
            myKeyPad.Location = new Point(300, 90);

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

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

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

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

            value = Helper.StringZeroFillDigits4(this.comboBoxZeroParameterVariate.SelectedIndex.ToString());

            this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress.ZeroVariate, value);
        }
        private void comboBoxZeroParameterMode_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        private void comboBoxDecimalPlaces_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ParentForm.SystemConfig.DecimalPlaces = this.comboBoxDecimalPlaces.SelectedIndex;

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

            this.ParentForm.Update30000DecimalPoint();
        }

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

        private void smartForm1_OnSpecialFunctionClick(object sender, EventArgs e)
        {
            this.panelSpecialMenu.BringToFront();
            if (this.panelSpecialMenu.Visible == false)
                this.panelSpecialMenu.Visible = true;
        }
        #endregion

        #region SpecialFunction Menu
        private void buttonZeroRange_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.ZeroRange, "");
        }
        private void buttonZeroVariate_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.ZeroVariate, "");
        }
        private void buttonZeroTime_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.ZeroTime, "");
        }
        private void buttonDigit_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.Digit, "");
        }
        private void buttonMaxWeight_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.MaxWeight, "");
        }
        private void buttonBalanceWeight_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.BalanceWeight, "");
        }
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoardAll, CommunicationAddress.Filter, "");
        }
        #endregion
    }
}