Exemple #1
0
        public FlagCheckedListBoxItem Add(int v, string c)
        {
            FlagCheckedListBoxItem item = new FlagCheckedListBoxItem(v, c);

            Items.Add(item);
            return(item);
        }
Exemple #2
0
        protected void UpdateCheckedItems(FlagCheckedListBoxItem composite, CheckState cs)
        {
            if (composite.value == 0)
            {
                UpdateCheckedItems(0);
            }
            int sum = 0;

            for (int i = 0; i < Items.Count; i++)
            {
                FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
                if (GetItemChecked(i))
                {
                    sum |= item.value;
                }
            }
            if (cs == CheckState.Unchecked)
            {
                sum = sum & (~composite.value);
            }
            else
            {
                sum |= composite.value;
            }
            UpdateCheckedItems(sum);
        }
Exemple #3
0
        protected override void OnItemCheck(ItemCheckEventArgs e)
        {
            base.OnItemCheck(e);
            if (isUpdatingCheckStates)
            {
                return;
            }
            FlagCheckedListBoxItem item = Items[e.Index] as FlagCheckedListBoxItem;

            UpdateCheckedItems(item, e.NewValue);
        }
Exemple #4
0
        public int GetCurrentValue()
        {
            int sum = 0;

            for (int i = 0; i < Items.Count; i++)
            {
                FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
                if (GetItemChecked(i))
                {
                    sum |= item.value;
                }
            }
            return(sum);
        }
Exemple #5
0
 protected void UpdateCheckedItems(int value)
 {
     isUpdatingCheckStates = true;
     for (int i = 0; i < Items.Count; i++)
     {
         FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
         if (item.value == 0)
         {
             SetItemChecked(i, value == 0);
         }
         else
         {
             if ((item.value & value) == item.value && item.value != 0)
             {
                 SetItemChecked(i, true);
             }
             else
             {
                 SetItemChecked(i, false);
             }
         }
     }
     isUpdatingCheckStates = false;
 }
Exemple #6
0
 public FlagCheckedListBoxItem Add(FlagCheckedListBoxItem item)
 {
     Items.Add(item);
     return(item);
 }
Exemple #7
0
 public bool IsMemberFlag(FlagCheckedListBoxItem composite)
 {
     return(IsFlag && ((value & composite.value) == value));
 }