public int Add(object item) { //this.owner.CheckNoSharedCell(); owner.CheckNoDataSource(); ArgumentNullException.ThrowIfNull(item); int index = InnerArray.Add(item); bool success = false; if (owner.Sorted) { try { InnerArray.Sort(Comparer); index = InnerArray.IndexOf(item); success = true; } finally { if (!success) { InnerArray.Remove(item); } } } owner.OnItemsCollectionChanged(); return(index); }
public void Insert(int index, object item) { //this.owner.CheckNoSharedCell(); owner.CheckNoDataSource(); if (item is null) { throw new ArgumentNullException(nameof(item)); } if (index < 0 || index > InnerArray.Count) { throw new ArgumentOutOfRangeException(nameof(index), index, string.Format(SR.InvalidArgument, nameof(index), nameof(index))); } // If the combo box is sorted, then just treat this like an add // because we are going to twiddle the index anyway. if (owner.Sorted) { Add(item); } else { InnerArray.Insert(index, item); owner.OnItemsCollectionChanged(); } }
/// <summary> /// Same thing for GetChecked. /// </summary> internal void SetCheckedState(int index, CheckState value) { bool isChecked; bool isIndeterminate; switch (value) { case CheckState.Checked: isChecked = true; isIndeterminate = false; break; case CheckState.Indeterminate: isChecked = false; isIndeterminate = true; break; default: isChecked = false; isIndeterminate = false; break; } bool wasChecked = InnerArray.GetState(index, s_checkedItemMask); bool wasIndeterminate = InnerArray.GetState(index, s_indeterminateItemMask); InnerArray.SetState(index, s_checkedItemMask, isChecked); InnerArray.SetState(index, s_indeterminateItemMask, isIndeterminate); if (wasChecked != isChecked || wasIndeterminate != isIndeterminate) { // Raise a notify event that this item has changed. _owner.AccessibilityNotifyClients(AccessibleEvents.StateChange, index); } }
void IList.Insert(int index, object value) { if (!(value is Attachment)) { throw new InvalidCastException(); } InnerArray.Insert(index, value); }
void IList.Remove(object value) { if (!(value is Attachment)) { throw new InvalidCastException(); } InnerArray.Remove(value); }
int IList.Add(object value) { if (!(value is Attachment)) { throw new InvalidCastException(); } return(InnerArray.Add(value)); }
public int this[int index] { get { object identifier = InnerArray.GetEntryObject(index, SelectedObjectCollection.SelectedObjectMask); return(InnerArray.IndexOf(identifier)); } }
public int IndexOf(object value) { if (value is null) { throw new ArgumentNullException(nameof(value)); } return(InnerArray.IndexOf(value)); }
public int this[int index] { get { object identifier = InnerArray.GetEntryObject(index, CheckedItemCollection.s_anyMask); return(InnerArray.IndexOf(identifier, stateMask: 0)); } }
///<summary>末尾に要素をまとめて追加</summary> public void AddRange(Span <T> values) { int c = Count; ExpandIfNeccesary(c + values.Length); values.CopyTo(InnerArray.AsSpan(c, values.Length)); Count += values.Length; }
public void Remove(object value) { int index = InnerArray.IndexOf(value, 0); if (index != -1) { RemoveAt(index); } }
public void CopyTo(object[] destination, int arrayIndex) { int count = InnerArray.GetCount(0); for (int i = 0; i < count; i++) { destination[i + arrayIndex] = InnerArray.GetItem(i, 0); } }
public void CopyTo(Array destination, int index) { int cnt = InnerArray.GetCount(SelectedObjectMask); for (int i = 0; i < cnt; i++) { destination.SetValue(InnerArray.GetItem(i, SelectedObjectMask), i + index); } }
void ICollection.CopyTo(Array destination, int index) { int count = InnerArray.GetCount(0); for (int i = 0; i < count; i++) { destination.SetValue(InnerArray.GetItem(i, 0), i + index); } }
public void CopyTo(Array dest, int index) { int cnt = InnerArray.GetCount(s_anyMask); for (int i = 0; i < cnt; i++) { dest.SetValue(InnerArray.GetItem(i, s_anyMask), i + index); } }
internal int IndexOfIdentifier(object value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } return(InnerArray.IndexOfIdentifier(value, 0)); }
public void Clear() { if (InnerArray.Count > 0) { //this.owner.CheckNoSharedCell(); owner.CheckNoDataSource(); InnerArray.Clear(); owner.OnItemsCollectionChanged(); } }
void ExpandIfNeccesary(int MinSize) { if (InnerArray.Length <= MinSize) { var NextArray = Pool.Rent(Math.Max(MinSize, InnerArray.Length << 1)); InnerArray.AsSpan().CopyTo(NextArray); Pool.Return(InnerArray); InnerArray = NextArray; } }
/// <summary> /// Removes an item from the ListBox at the given index. /// </summary> public void RemoveAt(int index) { if (index < 0 || index >= InnerArray.GetCount(0)) { throw new ArgumentOutOfRangeException(); } // Update InnerArray before calling NativeRemoveAt to ensure that when // SelectedIndexChanged is raised (by NativeRemoveAt), InnerArray's state matches wrapped LB state. InnerArray.RemoveAt(index); }
public object this[int index] { get { return(InnerArray.GetItem(index, SelectedObjectMask)); } set { throw new NotSupportedException(); } }
public object?this[int index] { get { return(InnerArray.GetItem(index, SelectedObjectMask)); } set { throw new NotSupportedException(SR.ListBoxSelectedObjectCollectionIsReadOnly); } }
public void Remove(object value) { owner.CheckNoDataSource(); int index = InnerArray.IndexOf(value, 0); if (index != -1) { RemoveAt(index); } }
private int AddInternal(object item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } int index = -1; if (!owner.sorted) { InnerArray.Add(item); } else { if (Count > 0) { index = InnerArray.BinarySearch(item); if (index < 0) { index = ~index; // getting the index of the first element that is larger than the search value //this index will be used for insert } } else { index = 0; } InnerArray.Insert(index, item); } bool successful = false; try { if (owner.sorted) { } else { index = Count - 1; } successful = true; } finally { if (!successful) { InnerArray.Remove(item); } } return(index); }
public void RemoveAt(int index) { //this.owner.CheckNoSharedCell(); owner.CheckNoDataSource(); if (index < 0 || index >= InnerArray.Count) { throw new ArgumentOutOfRangeException(nameof(index), index, string.Format(SR.InvalidArgument, nameof(index), index)); } InnerArray.RemoveAt(index); owner.OnItemsCollectionChanged(); }
public void CopyTo(object[] destination, int arrayIndex) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } int count = InnerArray.GetCount(0); for (int i = 0; i < count; i++) { destination[i + arrayIndex] = InnerArray.GetItem(i, 0); } }
void ICollection.CopyTo(Array destination, int index) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } int count = InnerArray.GetCount(0); for (int i = 0; i < count; i++) { destination.SetValue(InnerArray.GetItem(i, 0), i + index); } }
internal void SetItemInternal(int index, object value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (index < 0 || index >= InnerArray.GetCount(0)) { throw new ArgumentOutOfRangeException(); } InnerArray.SetItem(index, value); }
/// <summary> /// Returns an Enumerator of type <TKey, TValue>, Requirements reqest lack of a yeild operator in code /// </summary> /// <returns></returns> public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator() { var returnList = InnerArray .Where(filter => (filter != null && filter.IsDeleted == false)) .Select(output => new KeyValuePair <TKey, TValue>( CloneObject(output.Key), CloneObject(output.Value) )).ToList <KeyValuePair <TKey, TValue> >(); var enumerator = new ODDictionaryEnumerator <TKey, TValue>(returnList, this); EnumeratorsToInvalidate.Add(enumerator); return(enumerator); }
public int IndexOf(int selectedIndex) { // Just what does this do? The selectedIndex parameter above is the index into the // main object collection. We look at the state of that item, and if the state indicates // that it is selected, we get back the virtualized index into this collection. Indexes on // this collection match those on the SelectedObjectCollection. if (selectedIndex >= 0 && selectedIndex < InnerArray.Count && InnerArray.GetState(selectedIndex, SelectedObjectCollection.SelectedObjectMask)) { return(InnerArray.IndexOf(InnerArray.GetItem(selectedIndex), SelectedObjectCollection.SelectedObjectMask)); } return(-1); }
public virtual object this[int index] { get { if (index < 0 || index >= InnerArray.GetCount(0)) { throw new ArgumentOutOfRangeException(); } return(InnerArray.GetItem(index, 0)); } set { SetItemInternal(index, value); } }