private int AddItem (object item, bool suspend)
{
// suspend means do not sort as we put new items in, we will do a
// big sort at the end
if (item == null)
throw new ArgumentNullException ("item");
if (owner.Sorted && !suspend)
{
int index = 0;
foreach (object o in object_items)
{
if (String.Compare (item.ToString (), o.ToString ()) < 0)
{
object_items.Insert (index, item);
// If we added the new item before the selectedindex
// bump the selectedindex by one, behavior differs if
// Handle has not been created.
if (index <= owner.selected_index && owner.IsHandleCreated)
owner.selected_index++;
//UIA Framework event: Item added
OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Add, item));
return index;
}
index++;
}
}
object_items.Add (item);
//UIA Framework event: Item added
OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Add, item));
return object_items.Count - 1;
}