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

using SmartX;
using INT63DC_2C.Forms;

namespace INT63DC_2C.Controls
{
    public partial class ControlMainDisplayTable16 : UserControl
    {
        #region Field
        private FormMainDisplay m_ParentForm;

        private Color WeightOverColor = Color.Red;
        private Color WeightStandardColor = Color.Black;
        private Color WeightUnderColor = Color.Red;
        private Color WeightSamplingDataColor = Color.Blue;

        private Collection<PictureBox> CollectionPictureBoxZero;
        private Collection<PictureBox> CollectionPictureBoxBypass;
        private Collection<SmartLabel> CollectionLabelTenAvg;
        private Collection<SmartLabel> CollectionLabelAllAvg;
        private Collection<SmartListBox> CollectionListBox;
        private Collection<WeightStorageItem> CollectionWeightStorageItem;
        #endregion

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

            this.ParentForm = parent;

            this.CreateCollection();
            this.InitializeControl();
        }
        #endregion

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

        #region Method
        private void CreateCollection()
        {
            this.CollectionWeightStorageItem = new Collection<WeightStorageItem>();
            this.CollectionPictureBoxZero = new Collection<PictureBox>();
            this.CollectionPictureBoxBypass = new Collection<PictureBox>();
            this.CollectionLabelTenAvg = new Collection<SmartLabel>();
            this.CollectionLabelAllAvg = new Collection<SmartLabel>();
            this.CollectionListBox = new Collection<SmartListBox>();

            for (int i = 1; i <= this.EquipmentColumns; i++)
            {
                this.CollectionPictureBoxZero.Add(FindByNameUtil.PictureBox("pictureBox" + i, this));
                this.CollectionPictureBoxBypass.Add(FindByNameUtil.PictureBox("pictureBoxBypass" + i, this));
                this.CollectionLabelTenAvg.Add(FindByNameUtil.SmartLabel("labelTenAvg" + i, this));
                this.CollectionLabelAllAvg.Add(FindByNameUtil.SmartLabel("labelAllAvg" + i, this));
                this.CollectionListBox.Add(FindByNameUtil.SmartListBox("listBox" + i, this));
                this.CollectionWeightStorageItem.Add(new WeightStorageItem());
            }
        }
        private void InitializeControl()
        {
            string weight = "";
            int[] iColPos = new int[2];
            iColPos[0] = 10;
            iColPos[1] = 53;

            for (int i = 0; i < this.EquipmentColumns; i++)
            {
                this.CollectionPictureBoxZero[i].Visible = false;
                this.CollectionPictureBoxBypass[i].Visible = false;
                this.CollectionLabelTenAvg[i].Text = Helper.DoubleToString(0.0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                this.CollectionLabelAllAvg[i].Text = Helper.DoubleToString(0.0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);

                this.CollectionListBox[i].ColumnAlign = SmartListBox.COLUMNALIGNS.RIGHT;
                this.CollectionListBox[i].ColumnOffsets = iColPos;
                this.CollectionListBox[i].ColumnDelimiter = ';';
                this.CollectionListBox[i].Enabled = false;
                for (int j = 0; j < 10; j++)
                {
                    weight = Helper.DoubleToString(0.0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    this.CollectionListBox[i].AddItem(string.Format(";{0}", weight));
                }
            }
        }

        public void Clear()
        {
            string weight = "";

            for (int i = 0; i < this.EquipmentColumns; i++)
            {
                this.CollectionWeightStorageItem[i].AllClear();
                this.CollectionListBox[i].ClearAll();
                for (int j = 0; j < 10; j++)
                {
                    weight = Helper.DoubleToString(0.0, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                    this.CollectionListBox[i].AddItem(string.Format(";{0}", weight));
                }

                Helper.SetTableLabelValue(this.CollectionLabelTenAvg[i], this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                   this.CollectionWeightStorageItem[i].WeightTenAverage());
                Helper.SetTableLabelValue(this.CollectionLabelAllAvg[i], this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                    this.CollectionWeightStorageItem[i].WeightTotalAverage());
            }
        }

        private void UpdateLabelDisplay()
        {
            this.UpdateLabelDisplayLane1();
            this.UpdateLabelDisplayLane2();
            this.UpdateLabelDisplayLane3();
            this.UpdateLabelDisplayLane4();
            this.UpdateLabelDisplayLane5();
            this.UpdateLabelDisplayLane6();
            this.UpdateLabelDisplayLane7();
            this.UpdateLabelDisplayLane8();
            this.UpdateLabelDisplayLane9();
            this.UpdateLabelDisplayLane10();
            this.UpdateLabelDisplayLane11();
            this.UpdateLabelDisplayLane12();
        }
        private void UpdateLabelDisplayLane1()
        {
            // Lane 1
            this.CollectionWeightStorageItem[0].SetQueueData();
            //Helper.SetTableLabelValue(this.label1Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label1Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label1Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label1Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label1Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label1Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label1Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label1Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label1Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label1Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg1, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[0].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg1, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[0].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane2()
        {
            // Lane 2
            this.CollectionWeightStorageItem[1].SetQueueData();
            //Helper.SetTableLabelValue(this.label2Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label2Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label2Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label2Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label2Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label2Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label2Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label2Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label2Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label2Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[1].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg2, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[1].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg2, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[1].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane3()
        {
            // Lane 3
            this.CollectionWeightStorageItem[2].SetQueueData();
            //Helper.SetTableLabelValue(this.label3Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label3Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label3Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label3Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label3Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label3Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label3Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label3Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label3Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label3Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[2].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg3, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[2].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg3, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[2].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane4()
        {
            // Lane 4
            this.CollectionWeightStorageItem[3].SetQueueData();
            //Helper.SetTableLabelValue(this.label4Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label4Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label4Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label4Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label4Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label4Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label4Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label4Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label4Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label4Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[3].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg4, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[3].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg4, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[3].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane5()
        {
            // Lane 5
            this.CollectionWeightStorageItem[4].SetQueueData();
            //Helper.SetTableLabelValue(this.label5Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label5Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label5Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label5Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label5Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label5Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label5Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label5Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label5Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label5Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[4].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg5, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[4].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg5, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[4].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane6()
        {
            // Lane 6
            this.CollectionWeightStorageItem[5].SetQueueData();
            //Helper.SetTableLabelValue(this.label6Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label6Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label6Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label6Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label6Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label6Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label6Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label6Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label6Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label6Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[5].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg6, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[5].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg6, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[5].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane7()
        {
            // Lane 7
            this.CollectionWeightStorageItem[6].SetQueueData();
            //Helper.SetTableLabelValue(this.label7Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label7Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label7Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label7Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label7Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label7Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label7Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label7Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label7Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label7Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[6].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg7, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[6].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg7, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[6].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane8()
        {
            // Lane 8
            this.CollectionWeightStorageItem[7].SetQueueData();
            //Helper.SetTableLabelValue(this.label8Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label8Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label8Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label8Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label8Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label8Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label8Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label8Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label8Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label8Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[7].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg8, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[7].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg8, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[7].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane9()
        {
            // Lane 9
            this.CollectionWeightStorageItem[8].SetQueueData();
            //Helper.SetTableLabelValue(this.label9Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label9Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label9Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label9Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label9Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label9Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label9Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label9Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label9Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label9Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[8].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg9, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[8].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg9, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[8].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane10()
        {
            // Lane 10
            this.CollectionWeightStorageItem[9].SetQueueData();
            //Helper.SetTableLabelValue(this.label10Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label10Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label10Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label10Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label10Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label10Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label10Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label10Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label10Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label10Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[9].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg10, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[9].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg10, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[9].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane11()
        {
            // Lane 11
            this.CollectionWeightStorageItem[10].SetQueueData();
            //Helper.SetTableLabelValue(this.label11Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label11Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label11Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label11Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label11Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label11Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label11Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label11Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label11Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label11Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[10].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg11, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[10].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg11, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[10].WeightTotalAverage());
        }
        private void UpdateLabelDisplayLane12()
        {
            // Lane 12
            this.CollectionWeightStorageItem[11].SetQueueData();
            //Helper.SetTableLabelValue(this.label12Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label12Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label12Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label12Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label12Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label12Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label12Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label12Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label12Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label12Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[11].C_StorageItem[9]);

            Helper.SetTableLabelValue(this.labelTenAvg12, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[11].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg12, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[11].WeightTotalAverage());
        }

        public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
        {
        }
        public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            // 초기화
        }
        public void UpdateBypassDisplay(Collection<WeightData> weightData)
        {
            for (int i = 0; i < this.CollectionPictureBoxBypass.Count; i++)
            {
                if (weightData[i].IsBypassMode == true)
                    this.CollectionPictureBoxBypass[i].Visible = true;
                else
                    this.CollectionPictureBoxBypass[i].Visible = false;
            }
        }
        public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string value = "";

            if (this.ParentForm.ParentForm.SystemConfig.EquipmentColumns > weightDatas.Count)
                return;

            if (status == DataStore.EquipmentStatus.Stop)
            {
                for (int i = 0; i < this.ParentForm.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    // 영점표시
                    if (weightDatas[i].Status == DataStore.WeightStatus.WeightZero)
                        this.CollectionPictureBoxZero[i].Visible = true;
                    else
                        this.CollectionPictureBoxZero[i].Visible = false;
                }
            }
            else
            {
                for (int i = 0; i < this.ParentForm.ParentForm.SystemConfig.EquipmentColumns; i++)
                {
                    // 영점표시
                    if (weightDatas[i].Status == DataStore.WeightStatus.WeightZero)
                        this.CollectionPictureBoxZero[i].Visible = true;
                    else
                        this.CollectionPictureBoxZero[i].Visible = false;
                }
            }
        }
        public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
        {
            string weight = "", grd = "";

            for (int i = 0; i < this.EquipmentColumns; i++)
            {
                if (weightDatas[i].JudgmentStatus == DataStore.JudgmentStatus.None)
                    continue;

                this.CollectionWeightStorageItem[i].SetValue(weightDatas[i]);
                this.CollectionWeightStorageItem[i].SetQueueData();

                if (weightDatas[i].JudgmentStatus == DataStore.JudgmentStatus.Empty)
                {
                    //if (weightDatas[i].IsSamplingData == true)
                    //    grd = "ES";
                    //else
                    //    grd = "E";
                }
                else
                {
                    //grd = "●";

                    if (weightDatas[i].JudgmentStatus == DataStore.JudgmentStatus.Under)
                        grd = "●";//grd = "U";
                    else if (weightDatas[i].JudgmentStatus == DataStore.JudgmentStatus.UnderLimit)
                        grd = "●";//grd = "UL";
                    else if (weightDatas[i].JudgmentStatus == DataStore.JudgmentStatus.Over)
                        grd = "●";//grd = "O";
                    else if (weightDatas[i].JudgmentStatus == DataStore.JudgmentStatus.OverLimit)
                        grd = "●";//grd = "OL";
                    else
                        grd = "";

                    if (weightDatas[i].IsSamplingData == true)
                        grd = "●"; //grd = "S";
                }

                weight = Helper.DoubleToString(weightDatas[i].Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
                this.CollectionListBox[i].AddItem(string.Format("{0};{1}", grd, weight));
                if (this.CollectionListBox[i].Items.Count > 10)
                    this.CollectionListBox[i].RemoveItem(10);

                Helper.SetTableLabelValue(this.CollectionLabelTenAvg[i], this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                    this.CollectionWeightStorageItem[i].WeightTenAverage());
                Helper.SetTableLabelValue(this.CollectionLabelAllAvg[i], this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                    this.CollectionWeightStorageItem[i].WeightTotalAverage());
            }
        }
        public void UpdateStartWeightDisplay1(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;
            string weight = "", grd = "";

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;


            this.CollectionWeightStorageItem[0].SetValue(weightData);
            this.CollectionWeightStorageItem[0].SetQueueData();
            //Helper.SetTableLabelValue(this.label1Col1Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[0]);
            //Helper.SetTableLabelValue(this.label1Col2Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[1]);
            //Helper.SetTableLabelValue(this.label1Col3Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[2]);
            //Helper.SetTableLabelValue(this.label1Col4Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[3]);
            //Helper.SetTableLabelValue(this.label1Col5Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[4]);
            //Helper.SetTableLabelValue(this.label1Col6Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[5]);
            //Helper.SetTableLabelValue(this.label1Col7Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[6]);
            //Helper.SetTableLabelValue(this.label1Col8Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[7]);
            //Helper.SetTableLabelValue(this.label1Col9Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[8]);
            //Helper.SetTableLabelValue(this.label1Col10Row, this.ParentForm.ParentForm.SystemConfig, this.CollectionWeightStorageItem[0].C_StorageItem[9]);

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
            {
                if (weightData.IsSamplingData == true)
                    grd = "ES";
                else
                    grd = "E";
            }
            else
            {
                if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Under)
                    grd = "U";
                else if (weightData.JudgmentStatus == DataStore.JudgmentStatus.UnderLimit)
                    grd = "UL";
                else if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Over)
                    grd = "O";
                else if (weightData.JudgmentStatus == DataStore.JudgmentStatus.OverLimit)
                    grd = "OL";
                else
                    grd = "";
            }

            weight = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
            this.listBox1.AddItem(string.Format("{0};{1}", grd, weight));
            if (this.listBox1.Items.Count > 10)
                this.listBox1.RemoveItem(10);

            Helper.SetTableLabelValue(this.labelTenAvg1, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[0].WeightTenAverage());
            Helper.SetTableLabelValue(this.labelAllAvg1, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig,
                this.CollectionWeightStorageItem[0].WeightTotalAverage());
        }
        public void UpdateStartWeightDisplay2(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[1].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane2();
        }
        public void UpdateStartWeightDisplay3(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[2].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane3();
        }
        public void UpdateStartWeightDisplay4(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[3].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane4();
        }
        public void UpdateStartWeightDisplay5(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[4].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane5();
        }
        public void UpdateStartWeightDisplay6(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[5].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane6();
        }
        public void UpdateStartWeightDisplay7(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[6].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane7();
        }
        public void UpdateStartWeightDisplay8(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[7].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane8();
        }
        public void UpdateStartWeightDisplay9(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[8].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane9();
        }
        public void UpdateStartWeightDisplay10(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[9].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane10();
        }
        public void UpdateStartWeightDisplay11(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[10].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane11();
        }
        public void UpdateStartWeightDisplay12(DataStore.EquipmentStatus status, WeightData weightData)
        {
            bool empty = false;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
                return;

            if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
                empty = true;

            this.CollectionWeightStorageItem[11].SetValue(weightData.Weight, weightData.IsSamplingData, empty, weightData.JudgmentStatus);

            this.UpdateLabelDisplayLane12();
        }
        #endregion

        private void smartButton1_Click(object sender, EventArgs e)
        {
            //this.ParentForm.MainDisplayTable16_1.BringToFront();
        }
    }
}
