/// <summary> /// Check if there is enough space to expand the capacity /// </summary> /// <param name="elements">Number of elements to be added</param> private void EnsureSpace(int elements) { if (elements + this._Count > m_controls.Length) { STNodeControl[] arrTemp = new STNodeControl[Math.Max(m_controls.Length * 2, elements + this._Count)]; m_controls.CopyTo(arrTemp, 0); m_controls = arrTemp; } }
public void Remove(STNodeControl control) { int nIndex = this.IndexOf(control); if (nIndex != -1) { this.RemoveAt(nIndex); } }
public int Add(STNodeControl control) { if (control == null) { throw new ArgumentNullException("Add object cannot be null"); } this.EnsureSpace(1); int nIndex = this.IndexOf(control); if (-1 == nIndex) { nIndex = this._Count; control.Owner = m_owner; m_controls[this._Count++] = control; this.Redraw(); } return(nIndex); }
public void Insert(int index, STNodeControl control) { if (index < 0 || index >= this._Count) { throw new IndexOutOfRangeException("Index out of bounds"); } if (control == null) { throw new ArgumentNullException("Insert object cannot be null"); } this.EnsureSpace(1); for (int i = this._Count; i > index; i--) { m_controls[i] = m_controls[i - 1]; } control.Owner = m_owner; m_controls[index] = control; this._Count++; this.Redraw(); }
public int IndexOf(STNodeControl option) { return(Array.IndexOf <STNodeControl>(m_controls, option)); }
public bool Contains(STNodeControl option) { return(this.IndexOf(option) != -1); }