예제 #1
0
 private void ValidateItems(PopupListItem[] items)
 {
     if (items == null)
     {
         throw new NullReferenceException();
     }
     for (var i = 0; i < items.Length; i++)
     {
         var item = items[i];
         if (item.Type < PopupListItemType.Text || item.Type > PopupListItemType.Separator)
         {
             throw new ArgumentOutOfRangeException(string.Format("Items[{0}]", i), item.Type, "Not a valid PopupListItemType");
         }
         if (item.Type != PopupListItemType.Text)
         {
             if (item.IsSelected)
             {
                 throw new ArgumentException("IsSelected can only be used on Text types", string.Format("Items[{0}]", i));
             }
             else if (item.IsDisabled)
             {
                 throw new ArgumentException("IsDisabled can only be used on Text types", string.Format("Items[{0}]", i));
             }
         }
         else if (item.IsSelected && item.IsDisabled)
         {
             throw new ArgumentException("IsSelected and IsDisabled cannot be used together", string.Format("Items[{0}]", i));
         }
     }
 }
예제 #2
0
 private void SetIndicies(PopupListItem[] items, Func<PopupListItem, bool> test, Func<IntPtr, int[], int, int> setFunc)
 {
     var indices = (from ele in items.Select((value, index) => new { value, index })
                    where test(ele.value)
                    select ele.index).ToArray();
     if (indices.Length > 0 && setFunc(handle, indices, indices.Length) != BPS.BPS_SUCCESS)
     {
         Util.ThrowExceptionForLastErrno();
     }
 }