Ejemplo n.º 1
0
        private void UpdateBytesControlValue()
        {
            byte[] data = GetInstanceData();

            if (ctlBytes.Count > data.Length)
            {
                for (int i = 0; i < ctlBytes.Count - data.Length; i++)
                {
                    I2C.ctlI2CByte ctl = (I2C.ctlI2CByte)(ctlBytes[i + data.Length]);
                    ctl.OnValueChange -= OnByteCtrlValueChange;
                    panelItems.Controls.Remove(ctl);
                }
                ctlBytes.RemoveRange(data.Length, ctlBytes.Count - data.Length);
            }
            else if (ctlBytes.Count < data.Length)
            {
                int ctlBytesLen = ctlBytes.Count;
                for (int i = 0; i < data.Length - ctlBytesLen; i++)
                {
                    I2C.ctlI2CByte ctl = new I2C.ctlI2CByte();
                    ctl.Top  = (i + ctlBytesLen) * 24 + 17;
                    ctl.Left = 3;
                    ctl.SetID(i + ctlBytesLen);
                    ctl.OnValueChange += new I2C.OnValueChange(OnByteCtrlValueChange);
                    panelItems.Controls.Add(ctl);
                    ctlBytes.Add(ctl);
                }
            }

            for (int i = 0; i < ctlBytes.Count; i++)
            {
                I2C.ctlI2CByte ctl = (I2C.ctlI2CByte)(ctlBytes[i]);
                ctl.Value = data[i];
            }
        }
Ejemplo n.º 2
0
        private void UpdateBytesControlValue()
        {
            byte[] data =GetInstanceData();

            if(ctlBytes.Count > data.Length)
            {
                for(int i = 0; i < ctlBytes.Count - data.Length; i ++)
                {
                    I2C.ctlI2CByte ctl = (I2C.ctlI2CByte)( ctlBytes[i + data.Length]);
                    ctl.OnValueChange -= OnByteCtrlValueChange;
                    panelItems.Controls.Remove(ctl);
                }
                ctlBytes.RemoveRange(data.Length, ctlBytes.Count - data.Length);
            }
            else if(ctlBytes.Count < data.Length)
            {
                int ctlBytesLen = ctlBytes.Count;
                for(int i = 0; i < data.Length - ctlBytesLen; i ++)
                {
                    I2C.ctlI2CByte ctl = new I2C.ctlI2CByte();
                    ctl.Top = (i + ctlBytesLen) * 24 + 17;
                    ctl.Left = 3;
                    ctl.SetID(i + ctlBytesLen);
                    ctl.OnValueChange += new I2C.OnValueChange(OnByteCtrlValueChange);
                    panelItems.Controls.Add(ctl);
                    ctlBytes.Add(ctl);
                }
            }

            for (int i = 0; i < ctlBytes.Count; i++)
            {
                I2C.ctlI2CByte ctl = (I2C.ctlI2CByte)(ctlBytes[i]);
                ctl.Value = data[i];
            }


        }