public void Remove(ChatListSubItem subItem) { int index = this.IndexOf(subItem); if (-1 != index) { this.RemoveAt(index); } }
private void EnsureSpace(int elements) { if (this.m_arrSubItems == null) { this.m_arrSubItems = new ChatListSubItem[Math.Max(elements, 4)]; } else if ((elements + this.count) > this.m_arrSubItems.Length) { ChatListSubItem[] array = new ChatListSubItem[Math.Max((int)(this.m_arrSubItems.Length * 2), (int)(elements + this.count))]; this.m_arrSubItems.CopyTo(array, 0); this.m_arrSubItems = array; } }
public void Add(ChatListSubItem subItem) { if (subItem == null) { throw new ArgumentNullException("SubItem cannot be null"); } this.EnsureSpace(1); if (-1 == this.IndexOf(subItem)) { subItem.OwnerListItem = this.owner; this.m_arrSubItems[this.count++] = subItem; if (this.owner.OwnerChatListBox != null) { this.owner.OwnerChatListBox.Invalidate(); } } }
public void AddAccordingToStatus(ChatListSubItem subItem) { if (subItem.Status == ChatListSubItem.UserStatus.OffLine) { this.Add(subItem); } else { int index = 0; int count = this.count; while (index < count) { if (subItem.Status <= this.m_arrSubItems[index].Status) { this.Insert(index, subItem); return; } index++; } this.Add(subItem); } }
public void Insert(int index, ChatListSubItem subItem) { if ((index < 0) || (index > this.count)) { throw new IndexOutOfRangeException("Index was outside the bounds of the array"); } if (subItem == null) { throw new ArgumentNullException("SubItem cannot be null"); } this.EnsureSpace(1); for (int i = this.count; i > index; i--) { this.m_arrSubItems[i] = this.m_arrSubItems[i - 1]; } subItem.OwnerListItem = this.owner; this.m_arrSubItems[index] = subItem; this.count++; if (this.owner.OwnerChatListBox != null) { this.owner.OwnerChatListBox.Invalidate(); } }
public int IndexOf(ChatListSubItem subItem) { return(Array.IndexOf <ChatListSubItem>(this.m_arrSubItems, subItem)); }
public bool Contains(ChatListSubItem subItem) { return(this.IndexOf(subItem) != -1); }