Esempio n. 1
0
        private void lbMaskBits_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            BitItem bitItem = (BitItem)lbMaskBits.Items[e.Index];

            MaskValue = MaskValue.SetBit(bitItem.Bit, e.NewValue == CheckState.Checked);
            ShowMaskValue();
        }
Esempio n. 2
0
        /// <summary>
        /// Shows the list of bits.
        /// </summary>
        private void ShowBits()
        {
            if (MaskBits is IEnumerable maskBits)
            {
                try
                {
                    lbMaskBits.BeginUpdate();
                    lbMaskBits.ItemCheck -= lbMaskBits_ItemCheck;
                    int index = 0;

                    foreach (object bitObj in maskBits)
                    {
                        if (bitObj != null)
                        {
                            BitItem bitItem = bitObj as BitItem ??
                                              new BitItem(index, bitObj.ToString());
                            lbMaskBits.Items.Add(bitItem);

                            if (MaskValue.BitIsSet(bitItem.Bit))
                            {
                                lbMaskBits.SetItemChecked(index, true);
                            }
                        }

                        index++;
                    }
                }
                finally
                {
                    lbMaskBits.EndUpdate();
                    lbMaskBits.ItemCheck += lbMaskBits_ItemCheck;
                }
            }
        }
Esempio n. 3
0
        public void AddBitItem(string name, int length)
        {
            if (length > 0)
            {
                if (_bitItems != null && _bitItems.Count > 0 && _bitItems.Exists(m => m.Name == name))
                {
                    throw new DuplicateItemException("Item exists, Same item name.");
                }

                if (CheckLength(length))
                {
                    BitItem bi = new BitItem(name, length);
                    _bitItems.Add(bi);
                }
                else
                {
                    throw new OutOfLengthLimitationException("The total length is big than size of byte.");
                }
            }
        }
Esempio n. 4
0
        public void AddBitItem(string name, int length)
        {
            if (length > 0)
            {
                if (_bitItems != null && _bitItems.Count > 0 && _bitItems.Exists(m => m.Name == name))
                {
                    throw new DuplicateItemException("Item exists, Same item name.");
                }

                if (CheckLength(length))
                {
                    BitItem bi = new BitItem(name, length);
                    _bitItems.Add(bi);
                }
                else
                {
                    throw new OutOfLengthLimitationException("The total length is big than size of byte.");
                }
            }
        }