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

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

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

            this.ParentForm = parent;

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

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

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

            if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                this.buttonOverRange1.DisableImage = this.buttonOverRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLineOverDisable));
                this.buttonOverRange1.DownImage = this.buttonOverRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLineOverDown));
                this.buttonOverRange1.UpImage = this.buttonOverRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLineOverUp));
                this.buttonPassRange1.DisableImage = this.buttonPassRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLinePassDisable));
                this.buttonPassRange1.DownImage = this.buttonPassRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLinePassDown));
                this.buttonPassRange1.UpImage = this.buttonPassRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLinePassUp));
                this.buttonUnderRange1.DisableImage = this.buttonUnderRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLineUnderDisable));
                this.buttonUnderRange1.DownImage = this.buttonUnderRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLineUnderDown));
                this.buttonUnderRange1.UpImage = this.buttonUnderRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engMainRunLineUnderUp));

                this.buttonOver1.DownImage = this.buttonOver2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engLightOverDown));
                this.buttonOver1.UpImage = this.buttonOver2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engLightOverUp));
                this.buttonPass1.DownImage = this.buttonPass2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engLightPassDown));
                this.buttonPass1.UpImage = this.buttonPass2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engLightPassUp));
                this.buttonUnder1.DownImage = this.buttonUnder2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engLightUnderDown));
                this.buttonUnder1.UpImage = this.buttonUnder2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engLightUnderUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                this.buttonOverRange1.DisableImage = this.buttonOverRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLineOverDisable));
                this.buttonOverRange1.DownImage = this.buttonOverRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLineOverDown));
                this.buttonOverRange1.UpImage = this.buttonOverRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLineOverUp));
                this.buttonPassRange1.DisableImage = this.buttonPassRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLinePassDisable));
                this.buttonPassRange1.DownImage = this.buttonPassRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLinePassDown));
                this.buttonPassRange1.UpImage = this.buttonPassRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLinePassUp));
                this.buttonUnderRange1.DisableImage = this.buttonUnderRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLineUnderDisable));
                this.buttonUnderRange1.DownImage = this.buttonUnderRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLineUnderDown));
                this.buttonUnderRange1.UpImage = this.buttonUnderRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnMainRunLineUnderUp));

                this.buttonOver1.DownImage = this.buttonOver2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnLightOverDown));
                this.buttonOver1.UpImage = this.buttonOver2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnLightOverUp));
                this.buttonPass1.DownImage = this.buttonPass2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnLightPassDown));
                this.buttonPass1.UpImage = this.buttonPass2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnLightPassUp));
                this.buttonUnder1.DownImage = this.buttonUnder2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnLightUnderDown));
                this.buttonUnder1.UpImage = this.buttonUnder2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnLightUnderUp));
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Russian)
            {
            }
            else
            {
                this.buttonOverRange1.DisableImage = this.buttonOverRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLineOverDisable));
                this.buttonOverRange1.DownImage = this.buttonOverRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLineOverDown));
                this.buttonOverRange1.UpImage = this.buttonOverRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLineOverUp));
                this.buttonPassRange1.DisableImage = this.buttonPassRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLinePassDisable));
                this.buttonPassRange1.DownImage = this.buttonPassRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLinePassDown));
                this.buttonPassRange1.UpImage = this.buttonPassRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLinePassUp));
                this.buttonUnderRange1.DisableImage = this.buttonUnderRange2.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLineUnderDisable));
                this.buttonUnderRange1.DownImage = this.buttonUnderRange2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLineUnderDown));
                this.buttonUnderRange1.UpImage = this.buttonUnderRange2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korMainRunLineUnderUp));

                this.buttonOver1.DownImage = this.buttonOver2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korLightOverDown));
                this.buttonOver1.UpImage = this.buttonOver2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korLightOverUp));
                this.buttonPass1.DownImage = this.buttonPass2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korLightPassDown));
                this.buttonPass1.UpImage = this.buttonPass2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korLightPassUp));
                this.buttonUnder1.DownImage = this.buttonUnder2.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korLightUnderDown));
                this.buttonUnder1.UpImage = this.buttonUnder2.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korLightUnderUp));
            }
        }
        private void DefaultSetting()
        {
            this.InitializeDraw();
        }

        private void InitializeDraw()
        {
            SmartDraw.CHARTREFRESH charRefreshType = SmartDraw.CHARTREFRESH.LEFTSCROLL;
            SmartDraw.CHARTPENSTYLE[] charPenStyle;
            charPenStyle = new SmartX.SmartDraw.CHARTPENSTYLE[1];
            charPenStyle[0].m_chColor = Color.White;
            charPenStyle[0].m_iPenWidth = 2;

            this.draw1.SetChartCfg(2, 210, 268, 210, 5, charRefreshType, 1);
            this.draw1.ChartChannelPenStyle = charPenStyle;
            this.draw1.ChartDrawStep = 1;

            this.draw2.SetChartCfg(2, 210, 268, 210, 5, charRefreshType, 1);
            this.draw2.ChartChannelPenStyle = charPenStyle;
            this.draw2.ChartDrawStep = 1;
        }
        private void SetDrawData(SmartDraw draw, string stringWeight, ProductItem product)
        {
            int value = 0, gap = 0, startingPoint = 0, weight = 0;

            try
            {
                weight = int.Parse(stringWeight);
                gap = int.Parse(product.OverRange.Replace(".", "")) - int.Parse(product.UnderRange.Replace(".", ""));
                startingPoint = int.Parse(product.UnderRange.Replace(".", "")) - gap;

                value = weight - startingPoint;
                value = (value * 70) / gap;

                if (value > 210)
                    value = 210;
                if (value < 1)
                    value = 1;

                draw.PutData(value);
            }
            catch
            {
            }
        }
        private void SetProduct1(ProductItem item)
        {
            string underValue = "", passValue = "", overValue = "";

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    underValue = Helper.StringToDecimalPlaces(item.UnderRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    passValue = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overValue = Helper.StringToDecimalPlaces(item.OverRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    break;
                case DataStore.WeightInputMode.Deviation:
                    if (item.UnderRangDeviation == 0)
                        underValue = string.Format("-{0}", Helper.DoubleToString(0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces));
                    else
                        underValue = Helper.StringToDecimalPlaces(item.UnderRangDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    passValue = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overValue = Helper.StringToDecimalPlaces(item.OverRangeDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overValue = string.Format("+{0}", overValue);
                    break;
                default:
                    break;
            }

            if (this.buttonUnderRange1.Text != underValue)
                this.buttonUnderRange1.Text = underValue;

            if (this.buttonPassRange1.Text != passValue)
                this.buttonPassRange1.Text = passValue;

            if (this.buttonOverRange1.Text != overValue)
                this.buttonOverRange1.Text = overValue;

            // NET Icon 표시
            this.UpdateDisplayIconNET1(item);
        }
        private void SetProduct2(ProductItem item)
        {
            string underValue = "", passValue = "", overValue = "";

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    underValue = Helper.StringToDecimalPlaces(item.UnderRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    passValue = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overValue = Helper.StringToDecimalPlaces(item.OverRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    break;
                case DataStore.WeightInputMode.Deviation:
                    if (item.UnderRangDeviation == 0)
                        underValue = string.Format("-{0}", Helper.DoubleToString(0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces));
                    else
                        underValue = Helper.StringToDecimalPlaces(item.UnderRangDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    passValue = Helper.StringToDecimalPlaces(item.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overValue = Helper.StringToDecimalPlaces(item.OverRangeDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overValue = string.Format("+{0}", overValue);
                    break;
                default:
                    break;
            }

            if (this.buttonUnderRange2.Text != underValue)
                this.buttonUnderRange2.Text = underValue;

            if (this.buttonPassRange2.Text != passValue)
                this.buttonPassRange2.Text = passValue;

            if (this.buttonOverRange2.Text != overValue)
                this.buttonOverRange2.Text = overValue;

            // NET Icon 표시
            this.UpdateDisplayIconNET2(item);
        }
        private void SetCount1(WeightData data)
        {
            string value = "";

            #region Count
            value = data.UnderCount.ToString();
            if (this.labelUnderCount1.Text != value)
                this.labelUnderCount1.Text = value;

            value = data.PassCount.ToString();
            if (this.labelPassCount1.Text != value)
                this.labelPassCount1.Text = value;

            value = data.OverCount.ToString();
            if (this.labelOverCount1.Text != value)
                this.labelOverCount1.Text = value; 
            #endregion

            #region Ratio
            value = data.UnderRatio;
            if (this.labelUnderRatio1.Text != value)
                this.labelUnderRatio1.Text = value;

            value = data.PassRatio;
            if (this.labelPassRatio1.Text != value)
                this.labelPassRatio1.Text = value;

            value = data.OverRatio;
            if (this.labelOverRatio1.Text != value)
                this.labelOverRatio1.Text = value;
            #endregion
        }
        private void SetCount2(WeightData data)
        {
            string value = "";

            #region Count
            value = data.UnderCount.ToString();
            if (this.labelUnderCount2.Text != value)
                this.labelUnderCount2.Text = value;

            value = data.PassCount.ToString();
            if (this.labelPassCount2.Text != value)
                this.labelPassCount2.Text = value;

            value = data.OverCount.ToString();
            if (this.labelOverCount2.Text != value)
                this.labelOverCount2.Text = value; 
            #endregion

            #region Ratio
            value = data.UnderRatio;
            if (this.labelUnderRatio2.Text != value)
                this.labelUnderRatio2.Text = value;

            value = data.PassRatio;
            if (this.labelPassRatio2.Text != value)
                this.labelPassRatio2.Text = value;

            value = data.OverRatio;
            if (this.labelOverRatio2.Text != value)
                this.labelOverRatio2.Text = value;
            #endregion
        }
        private void UpdateDisplayStopWeight1(DataStore.EquipmentStatus status, WeightData data)
        {
            string value = "";

            // 영점 아이콘표시
            if (data.Status == DataStore.WeightStatus.WeightZero)
                this.pictureBoxIconZero1.Visible = true;
            else
                this.pictureBoxIconZero1.Visible = false;

            if (status == DataStore.EquipmentStatus.Stop)
            {
                // 중량
                value = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeight1.Text != value)
                    this.labelWeight1.Text = value;
            }
        }
        private void UpdateDisplayStopWeight2(DataStore.EquipmentStatus status, WeightData data)
        {
            string value = "";

            // 영점 아이콘표시
            if (data.Status == DataStore.WeightStatus.WeightZero)
                this.pictureBoxIconZero2.Visible = true;
            else
                this.pictureBoxIconZero2.Visible = false;

            if (status == DataStore.EquipmentStatus.Stop)
            {
                // 중량
                value = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                if (this.labelWeight2.Text != value)
                    this.labelWeight2.Text = value; 
            }
        }
        private void UpdateDisplayUser(UserItem user)
        {
            switch (user.Group)
            {
                case DataStore.UserGroup.LogOff:
                    this.buttonUnderRange1.Enabled = this.buttonUnderRange2.Enabled = false;
                    this.buttonPassRange1.Enabled = this.buttonPassRange2.Enabled = false;
                    this.buttonOverRange1.Enabled = this.buttonOverRange2.Enabled = false;
                    break;
                case DataStore.UserGroup.Level1Operator:
                    this.buttonUnderRange1.Enabled = this.buttonUnderRange2.Enabled = true;
                    this.buttonPassRange1.Enabled = this.buttonPassRange2.Enabled = true;
                    this.buttonOverRange1.Enabled = this.buttonOverRange2.Enabled = true;
                    break;
                case DataStore.UserGroup.Level2Engineer:
                    this.buttonUnderRange1.Enabled = this.buttonUnderRange2.Enabled = true;
                    this.buttonPassRange1.Enabled = this.buttonPassRange2.Enabled = true;
                    this.buttonOverRange1.Enabled = this.buttonOverRange2.Enabled = true;
                    break;
                case DataStore.UserGroup.Level3Manager:
                    this.buttonUnderRange1.Enabled = this.buttonUnderRange2.Enabled = true;
                    this.buttonPassRange1.Enabled = this.buttonPassRange2.Enabled = true;
                    this.buttonOverRange1.Enabled = this.buttonOverRange2.Enabled = true;
                    break;
                case DataStore.UserGroup.Level4Developer:
                    this.buttonUnderRange1.Enabled = this.buttonUnderRange2.Enabled = true;
                    this.buttonPassRange1.Enabled = this.buttonPassRange2.Enabled = true;
                    this.buttonOverRange1.Enabled = this.buttonOverRange2.Enabled = true;
                    break;
                default:
                    this.buttonUnderRange1.Enabled = this.buttonUnderRange2.Enabled = false;
                    this.buttonPassRange1.Enabled = this.buttonPassRange2.Enabled = false;
                    this.buttonOverRange1.Enabled = this.buttonOverRange2.Enabled = false;
                    break;
            }
        }
        private void UpdateDisplayJudgmentIcon1(DataStore.JudgmentStatus status)
        {
            if (status == DataStore.JudgmentStatus.Under)
            {
                this.buttonUnder1.ButtonDown();
                this.buttonPass1.ButtonUp();
                this.buttonOver1.ButtonUp();
            }
            else if (status == DataStore.JudgmentStatus.Pass)
            {
                this.buttonUnder1.ButtonUp();
                this.buttonPass1.ButtonDown();
                this.buttonOver1.ButtonUp();
            }
            else if (status == DataStore.JudgmentStatus.Over)
            {
                this.buttonUnder1.ButtonUp();
                this.buttonPass1.ButtonUp();
                this.buttonOver1.ButtonDown();
            }
            else
            {
                this.buttonUnder1.ButtonUp();
                this.buttonPass1.ButtonUp();
                this.buttonOver1.ButtonUp();
            }
        }
        private void UpdateDisplayJudgmentIcon2(DataStore.JudgmentStatus status)
        {
            if (status == DataStore.JudgmentStatus.Under)
            {
                this.buttonUnder2.ButtonDown();
                this.buttonPass2.ButtonUp();
                this.buttonOver2.ButtonUp();
            }
            else if (status == DataStore.JudgmentStatus.Pass)
            {
                this.buttonUnder2.ButtonUp();
                this.buttonPass2.ButtonDown();
                this.buttonOver2.ButtonUp();
            }
            else if (status == DataStore.JudgmentStatus.Over)
            {
                this.buttonUnder2.ButtonUp();
                this.buttonPass2.ButtonUp();
                this.buttonOver2.ButtonDown();
            }
            else
            {
                this.buttonUnder2.ButtonUp();
                this.buttonPass2.ButtonUp();
                this.buttonOver2.ButtonUp();
            }
        }
        private void UpdateDisplayIconNET1(ProductItem item)
        {
            double dValue = 0.0;

            dValue = Helper.StringToWeight(item.TareRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            if (dValue != 0.0)
                this.labelIconNET1.Visible = true;
            else
                this.labelIconNET1.Visible = false;
        }
        private void UpdateDisplayIconNET2(ProductItem item)
        {
            double dValue = 0.0;

            dValue = Helper.StringToWeight(item.TareRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            if (dValue != 0.0)
                this.labelIconNET2.Visible = true;
            else
                this.labelIconNET2.Visible = false;
        }

        public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
        {
            if (status == DataStore.EquipmentStatus.Start)
            {
                this.labelWeight1.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                this.labelWeight2.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            }
            else
            {
                this.pictureBoxIconGap1.Visible = false;
                this.pictureBoxIconGap2.Visible = false;
                this.pictureBoxIconMetal1.Visible = false;
                this.pictureBoxIconMetal2.Visible = false;

                this.buttonUnder1.ButtonUp();
                this.buttonUnder2.ButtonUp();
                this.buttonPass1.ButtonUp();
                this.buttonPass2.ButtonUp();
                this.buttonOver1.ButtonUp();
                this.buttonOver2.ButtonUp();
            }
        }
        public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, ProductItem pItem1, ProductItem pItem2, WeightData wData1, WeightData wData2)
        {
            this.SetProduct1(pItem1);
            this.SetProduct2(pItem2);

            this.SetCount1(wData1);
            this.SetCount2(wData2);

            this.draw1.PutDataAllClear();
            this.draw2.PutDataAllClear();
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, WeightData data1, WeightData data2)
        {
            this.UpdateDisplayStopWeight1(status, data1);
            this.UpdateDisplayStopWeight2(status, data2);
        }
        public void UpdateStartWeightDisplay1(DataStore.EquipmentStatus status, WeightData data)
        {
            string value = "";

            if (data.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                return;

            // 중량
            value = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight1.Text != value)
                this.labelWeight1.Text = value;

            // GAP 아이콘 표시
            if (data.JudgmentStatus == DataStore.JudgmentStatus.Double)
            {
                if (this.pictureBoxIconGap1.Visible != true)
                    this.pictureBoxIconGap1.Visible = true;
            }
            else
                this.pictureBoxIconGap1.Visible = false;

            // Metal 아이콘 표시
            if (data.JudgmentStatus == DataStore.JudgmentStatus.Metal)
            {
                if (this.pictureBoxIconMetal1.Visible != true)
                    this.pictureBoxIconMetal1.Visible = true;
            }
            else
                this.pictureBoxIconMetal1.Visible = false;

            this.UpdateDisplayJudgmentIcon1(data.JudgmentStatus);
            this.SetDrawData(this.draw1, data.WeightString, this.ParentForm.ParentForm.CurrentProductItem1);
            this.SetCount1(data);
        }
        public void UpdateStartWeightDisplay2(DataStore.EquipmentStatus status, WeightData data)
        {
            string value = "";

            if (data.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                return;

            // 중량
            value = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            if (this.labelWeight2.Text != value)
                this.labelWeight2.Text = value;

            // GAP 아이콘 표시
            if (data.JudgmentStatus == DataStore.JudgmentStatus.Double)
            {
                if (this.pictureBoxIconGap2.Visible != true)
                    this.pictureBoxIconGap2.Visible = true;
            }
            else
                this.pictureBoxIconGap2.Visible = false;

            // Metal 아이콘 표시
            if (data.JudgmentStatus == DataStore.JudgmentStatus.Metal)
            {
                if (this.pictureBoxIconMetal2.Visible != true)
                    this.pictureBoxIconMetal2.Visible = true;
            }
            else
                this.pictureBoxIconMetal2.Visible = false;

            this.UpdateDisplayJudgmentIcon2(data.JudgmentStatus);
            this.SetDrawData(this.draw2, data.WeightString, this.ParentForm.ParentForm.CurrentProductItem2);
            this.SetCount2(data);
        }

        public void Clear()
        {
            this.SetCount1(this.ParentForm.ParentForm.CurrentWeightData1);
            this.SetCount2(this.ParentForm.ParentForm.CurrentWeightData2);
            this.draw1.PutDataAllClear();
            this.draw2.PutDataAllClear();
        }
        public void DisplayRefresh(SystemStatus status)
        {
            this.UpdateDisplayUser(status.CurrentUser);

            this.SetProduct1(this.ParentForm.ParentForm.CurrentProductItem1);
            this.SetProduct2(this.ParentForm.ParentForm.CurrentProductItem2);
            this.SetCount1(this.ParentForm.ParentForm.CurrentWeightData1);
            this.SetCount2(this.ParentForm.ParentForm.CurrentWeightData2);
        }
        #endregion

        #region Event Handler
        private void buttonUnderRange1_Click(object sender, EventArgs e)
        {
            string value = "", sValue = "";
            double dValue = 0.0;
            int digit = 0;

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 0)
                digit = 4;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                digit = 5;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                digit = 6;
            else
                digit = 5;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonUnderRange1.Text, digit, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces,
               false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() != DialogResult.OK)
                return;

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
                case DataStore.WeightInputMode.Deviation:
                    dValue = Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem1.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces)
                        - Math.Abs(myKeyPad.doubleValue);
                    sValue = Helper.DoubleToString(dValue, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    break;
                default:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
            }

            if (dValue > Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem1.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces) || dValue < 0)
            {
                // 입력범위를 확인하세요
                DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                myMsg.ShowDialog();
            }
            else
            {
                this.ParentForm.ParentForm.CurrentProductItem1.UnderRange = sValue.Replace(".", "");

                switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
                {
                    case DataStore.WeightInputMode.Weight:
                        value = myKeyPad.StringValue;
                        break;
                    case DataStore.WeightInputMode.Deviation:
                        if (myKeyPad.doubleValue == 0)
                            value = string.Format("-{0}", Helper.DoubleToString(0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces));
                        else
                            value = myKeyPad.StringValue;
                        break;
                    default:
                        value = myKeyPad.StringValue;
                        break;
                }

                this.buttonUnderRange1.Text = value;

                this.ParentForm.RescaleControl();

                this.ParentForm.ParentForm.SaveProductFile1(this.ParentForm.ParentForm.CurrentProductItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                value = Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem1.UnderRange);
                this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._2002_UnderRange, value);
            }
        }
        private void buttonPassRange1_Click(object sender, EventArgs e)
        {
            string value = "", underRange = "", overRange = "", viewValue = "";
            int digit = 0, temp = 0, range = 0;
            StringBuilder sb = new StringBuilder();

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 0)
                digit = 4;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                digit = 5;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                digit = 6;
            else
                digit = 5;

            if (this.ParentForm.ParentForm.CurrentWeightData1.Weight < 1)
                viewValue = this.buttonPassRange1.Text;
            else
                viewValue = Helper.DoubleToString(this.ParentForm.ParentForm.CurrentWeightData1.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(viewValue, digit, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces,
                     false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() != DialogResult.OK)
                return;

            this.ParentForm.ParentForm.CurrentProductItem1.PassRange = myKeyPad.StringValue.Replace(".", "");

            temp = this.ParentForm.ParentForm.CurrentProductItem1.PassRangeInt + this.ParentForm.ParentForm.CurrentProductItem1.UnderRangDeviation;
            if (temp < 0)
                this.ParentForm.ParentForm.CurrentProductItem1.UnderRange = "0";
            else
                this.ParentForm.ParentForm.CurrentProductItem1.UnderRange = temp.ToString();

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                range = 1000000;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                range = 100000;
            else
                range = 10000;
            temp = this.ParentForm.ParentForm.CurrentProductItem1.PassRangeInt + this.ParentForm.ParentForm.CurrentProductItem1.OverRangeDeviation;
            if (temp >= range)
                this.ParentForm.ParentForm.CurrentProductItem1.OverRange = this.ParentForm.ParentForm.CurrentProductItem1.PassRange;
            else
                this.ParentForm.ParentForm.CurrentProductItem1.OverRange = temp.ToString();

            this.ParentForm.RescaleControl();

            this.ParentForm.ParentForm.SaveProductFile1(this.ParentForm.ParentForm.CurrentProductItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

            sb.Append(Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem1.UnderRange));
            sb.Append(Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem1.OverRange));
            sb.Append(Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem1.TareRange));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.SystemConfig.ProductNumber.ToString()));
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9003_ParameterWeightSetting, sb.ToString());

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    #region WeightMode
                    underRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem1.UnderRange.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem1.OverRange.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    #endregion
                    break;
                case DataStore.WeightInputMode.Deviation:
                    #region DeviationMode
                    if (this.ParentForm.ParentForm.CurrentProductItem1.UnderRangDeviation == 0)
                        underRange = string.Format("-{0}", Helper.DoubleToString(0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces));
                    else
                        underRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem1.UnderRangDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem1.OverRangeDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overRange = string.Format("+{0}", overRange);
                    #endregion
                    break;
                default:
                    break;
            }

            this.buttonPassRange1.Text = myKeyPad.StringValue;
            this.buttonUnderRange1.Text = underRange;
            this.buttonOverRange1.Text = overRange;
        }
        private void buttonOverRange1_Click(object sender, EventArgs e)
        {
            string value = "", sValue = "";
            double dValue = 0.0;
            int digit = 0;

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 0)
                digit = 4;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                digit = 5;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                digit = 6;
            else
                digit = 5;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonOverRange1.Text, digit, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces,
                false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() != DialogResult.OK)
                return;

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
                case DataStore.WeightInputMode.Deviation:
                    dValue = Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem1.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces)
                        + myKeyPad.doubleValue;
                    sValue = Helper.DoubleToString(dValue, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    break;
                default:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
            }

            if (dValue < Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem1.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces) ||
                dValue >= 10000)
            {
                // 입력범위를 확인하세요
                DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                myMsg.ShowDialog();
            }
            else
            {
                this.ParentForm.ParentForm.CurrentProductItem1.OverRange = sValue.Replace(".", "");

                switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
                {
                    case DataStore.WeightInputMode.Weight:
                        value = myKeyPad.StringValue;
                        break;
                    case DataStore.WeightInputMode.Deviation:
                        value = string.Format("+{0}", myKeyPad.StringValue);
                        break;
                    default:
                        value = myKeyPad.StringValue;
                        break;
                }
                this.buttonOverRange1.Text = value;

                this.ParentForm.RescaleControl();

                this.ParentForm.ParentForm.SaveProductFile1(this.ParentForm.ParentForm.CurrentProductItem1, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                value = Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem1.OverRange);
                this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._2004_OverRange, value);
            }
        }
        private void buttonUnderRange2_Click(object sender, EventArgs e)
        {
            string value = "", sValue = "";
            double dValue = 0.0;
            int digit = 0;

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 0)
                digit = 4;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                digit = 5;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                digit = 6;
            else
                digit = 5;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonUnderRange2.Text, digit, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces,
               false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() != DialogResult.OK)
                return;

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
                case DataStore.WeightInputMode.Deviation:
                    dValue = Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem2.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces)
                        - Math.Abs(myKeyPad.doubleValue);
                    sValue = Helper.DoubleToString(dValue, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    break;
                default:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
            }

            if (dValue > Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem2.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces) || dValue < 0)
            {
                // 입력범위를 확인하세요
                DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                myMsg.ShowDialog();
            }
            else
            {
                this.ParentForm.ParentForm.CurrentProductItem2.UnderRange = sValue.Replace(".", "");

                switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
                {
                    case DataStore.WeightInputMode.Weight:
                        value = myKeyPad.StringValue;
                        break;
                    case DataStore.WeightInputMode.Deviation:
                        if (myKeyPad.doubleValue == 0)
                            value = string.Format("-{0}", Helper.DoubleToString(0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces));
                        else
                            value = myKeyPad.StringValue;
                        break;
                    default:
                        value = myKeyPad.StringValue;
                        break;
                }

                this.buttonUnderRange2.Text = value;

                this.ParentForm.RescaleControl();

                this.ParentForm.ParentForm.SaveProductFile2(this.ParentForm.ParentForm.CurrentProductItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                value = Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem2.UnderRange);
                this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._2006_UnderRange, value);
            }
        }
        private void buttonPassRange2_Click(object sender, EventArgs e)
        {
            string value = "", underRange = "", overRange = "", viewValue = "";
            int digit = 0, temp = 0, range = 0;
            StringBuilder sb = new StringBuilder();

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 0)
                digit = 4;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                digit = 5;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                digit = 6;
            else
                digit = 5;

            if (this.ParentForm.ParentForm.CurrentWeightData2.Weight < 1)
                viewValue = this.buttonPassRange2.Text;
            else
                viewValue = Helper.DoubleToString(this.ParentForm.ParentForm.CurrentWeightData2.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(viewValue, digit, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces,
                     false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() != DialogResult.OK)
                return;

            this.ParentForm.ParentForm.CurrentProductItem2.PassRange = myKeyPad.StringValue.Replace(".", "");

            temp = this.ParentForm.ParentForm.CurrentProductItem2.PassRangeInt + this.ParentForm.ParentForm.CurrentProductItem2.UnderRangDeviation;
            if (temp < 0)
                this.ParentForm.ParentForm.CurrentProductItem2.UnderRange = "0";
            else
                this.ParentForm.ParentForm.CurrentProductItem2.UnderRange = temp.ToString();

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                range = 1000000;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                range = 100000;
            else
                range = 10000;
            temp = this.ParentForm.ParentForm.CurrentProductItem2.PassRangeInt + this.ParentForm.ParentForm.CurrentProductItem2.OverRangeDeviation;
            if (temp >= range)
                this.ParentForm.ParentForm.CurrentProductItem2.OverRange = this.ParentForm.ParentForm.CurrentProductItem2.PassRange;
            else
                this.ParentForm.ParentForm.CurrentProductItem2.OverRange = temp.ToString();

            this.ParentForm.RescaleControl();

            this.ParentForm.ParentForm.SaveProductFile2(this.ParentForm.ParentForm.CurrentProductItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

            sb.Append(Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem2.UnderRange));
            sb.Append(Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem2.OverRange));
            sb.Append(Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem2.TareRange));
            sb.Append(Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.SystemConfig.ProductNumber.ToString()));
            this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._9012_ParameterWeightSetting, sb.ToString());

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    #region WeightMode
                    underRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem2.UnderRange.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem2.OverRange.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    #endregion
                    break;
                case DataStore.WeightInputMode.Deviation:
                    #region DeviationMode
                    if (this.ParentForm.ParentForm.CurrentProductItem2.UnderRangDeviation == 0)
                        underRange = string.Format("-{0}", Helper.DoubleToString(0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces));
                    else
                        underRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem2.UnderRangDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overRange = Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem2.OverRangeDeviation.ToString(), this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    overRange = string.Format("+{0}", overRange);
                    #endregion
                    break;
                default:
                    break;
            }

            this.buttonPassRange2.Text = myKeyPad.StringValue;
            this.buttonUnderRange2.Text = underRange;
            this.buttonOverRange2.Text = overRange;
        }
        private void buttonOverRange2_Click(object sender, EventArgs e)
        {
            string value = "", sValue = "";
            double dValue = 0.0;
            int digit = 0;

            if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 0)
                digit = 4;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 1)
                digit = 5;
            else if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 2)
                digit = 6;
            else
                digit = 5;

            DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonOverRange2.Text, digit, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces,
                false, this.ParentForm.ParentForm.SystemConfig.Language);

            if (myKeyPad.ShowDialog() != DialogResult.OK)
                return;

            switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
            {
                case DataStore.WeightInputMode.Weight:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
                case DataStore.WeightInputMode.Deviation:
                    dValue = Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem2.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces)
                        + myKeyPad.doubleValue;
                    sValue = Helper.DoubleToString(dValue, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    break;
                default:
                    dValue = myKeyPad.doubleValue;
                    sValue = myKeyPad.StringValue;
                    break;
            }

            if (dValue < Helper.StringToWeight(this.ParentForm.ParentForm.CurrentProductItem2.PassRange, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces) ||
                dValue >= 10000)
            {
                // 입력범위를 확인하세요
                DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.Language);
                myMsg.ShowDialog();
            }
            else
            {
                this.ParentForm.ParentForm.CurrentProductItem2.OverRange = sValue.Replace(".", "");

                switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentWeightInputMode)
                {
                    case DataStore.WeightInputMode.Weight:
                        value = myKeyPad.StringValue;
                        break;
                    case DataStore.WeightInputMode.Deviation:
                        value = string.Format("+{0}", myKeyPad.StringValue);
                        break;
                    default:
                        value = myKeyPad.StringValue;
                        break;
                }
                this.buttonOverRange2.Text = value;

                this.ParentForm.RescaleControl();

                this.ParentForm.ParentForm.SaveProductFile2(this.ParentForm.ParentForm.CurrentProductItem2, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);

                value = Helper.StringZeroFillDigits7(this.ParentForm.ParentForm.CurrentProductItem2.OverRange);
                this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._2008_OverRange, value);
            }
        }
        #endregion
    }
}
