예제 #1
0
            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);
            }
예제 #2
0
            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);
                }
            }
예제 #4
0
 void IList.Insert(int index, object value)
 {
     if (!(value is Attachment))
     {
         throw new InvalidCastException();
     }
     InnerArray.Insert(index, value);
 }
예제 #5
0
 void IList.Remove(object value)
 {
     if (!(value is Attachment))
     {
         throw new InvalidCastException();
     }
     InnerArray.Remove(value);
 }
예제 #6
0
 int IList.Add(object value)
 {
     if (!(value is Attachment))
     {
         throw new InvalidCastException();
     }
     return(InnerArray.Add(value));
 }
예제 #7
0
 public int this[int index]
 {
     get
     {
         object identifier = InnerArray.GetEntryObject(index, SelectedObjectCollection.SelectedObjectMask);
         return(InnerArray.IndexOf(identifier));
     }
 }
예제 #8
0
 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));
     }
 }
예제 #10
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;
        }
예제 #11
0
            public void Remove(object value)
            {
                int index = InnerArray.IndexOf(value, 0);

                if (index != -1)
                {
                    RemoveAt(index);
                }
            }
예제 #12
0
            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);
                }
            }
예제 #14
0
            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);
                }
            }
예제 #16
0
            internal int IndexOfIdentifier(object value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                return(InnerArray.IndexOfIdentifier(value, 0));
            }
예제 #17
0
 public void Clear()
 {
     if (InnerArray.Count > 0)
     {
         //this.owner.CheckNoSharedCell();
         owner.CheckNoDataSource();
         InnerArray.Clear();
         owner.OnItemsCollectionChanged();
     }
 }
예제 #18
0
 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;
     }
 }
예제 #19
0
            /// <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);
            }
예제 #20
0
 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);
                }
            }
예제 #23
0
            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);
            }
예제 #24
0
            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);
                }
            }
예제 #27
0
            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);
            }
예제 #28
0
        /// <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);
        }
예제 #29
0
            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);
            }
예제 #30
0
            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);
                }
            }