TreeNodeCollection.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. //
  2. // System.Windows.Forms.TreeNodeCollection
  3. //
  4. // Author:
  5. // stubbed out by Jackson Harper ([email protected])
  6. // Dennis Hayes ([email protected])
  7. // Aleksey Ryabchuk ([email protected])
  8. //
  9. // (C) 2002 Ximian, Inc
  10. //
  11. using System.Collections;
  12. namespace System.Windows.Forms {
  13. // <summary>
  14. //
  15. // </summary>
  16. public class TreeNodeCollection : IList, ICollection, IEnumerable {
  17. private TreeNode owner;
  18. private ArrayList list;
  19. private TreeView treeView;
  20. internal TreeNodeCollection ( TreeNode owner, TreeView treeView )
  21. {
  22. list = new ArrayList();
  23. this.owner = owner;
  24. this.treeView = treeView;
  25. }
  26. public int Count {
  27. get { return list.Count; }
  28. }
  29. public bool IsReadOnly {
  30. get { return list.IsReadOnly; }
  31. }
  32. [MonoTODO]
  33. public virtual TreeNode this[int index] {
  34. get {
  35. return (TreeNode) list[index];
  36. }
  37. set {
  38. list[index] = value;
  39. }
  40. }
  41. public virtual TreeNode Add( string text )
  42. {
  43. TreeNode node = new TreeNode ( text );
  44. Add ( node );
  45. return node;
  46. }
  47. [MonoTODO]
  48. public virtual int Add( TreeNode node )
  49. {
  50. if ( node == null )
  51. throw new ArgumentNullException("value");
  52. if ( node.Parent != null )
  53. throw new ArgumentException("Object already has a parent.", "node");
  54. node.setParent( owner );
  55. node.setTreeView ( treeView );
  56. int index = list.Add( node );
  57. return index;
  58. }
  59. public virtual void AddRange( TreeNode[] nodes )
  60. {
  61. if ( nodes == null )
  62. throw new ArgumentNullException("nodes");
  63. foreach ( TreeNode node in nodes ) {
  64. // it will do a check for parent and set the parent
  65. Add ( node );
  66. }
  67. }
  68. [MonoTODO]
  69. public virtual void Clear()
  70. {
  71. foreach ( object node in list )
  72. ( ( TreeNode )node ).setParent ( null );
  73. list.Clear();
  74. }
  75. public bool Contains( TreeNode node )
  76. {
  77. return list.Contains( node );
  78. }
  79. [MonoTODO]
  80. public void CopyTo(Array dest, int index)
  81. {
  82. //FIXME:
  83. }
  84. public IEnumerator GetEnumerator()
  85. {
  86. return list.GetEnumerator();
  87. }
  88. public int IndexOf( TreeNode node )
  89. {
  90. return list.IndexOf( node );
  91. }
  92. [MonoTODO]
  93. public virtual void Insert( int index, TreeNode node )
  94. {
  95. if ( node == null )
  96. throw new ArgumentNullException ( "node" );
  97. if ( node.Parent != null)
  98. throw new ArgumentException ( "Object already has a parent.", "node" );
  99. if (index < 0 || index > Count )
  100. throw new ArgumentOutOfRangeException( "index" );
  101. list.Insert( index, node );
  102. node.setParent ( owner );
  103. }
  104. [MonoTODO]
  105. public void Remove( TreeNode node )
  106. {
  107. if ( node == null )
  108. throw new ArgumentNullException( "node" );
  109. list.Remove( node );
  110. node.setParent ( null );
  111. }
  112. [MonoTODO]
  113. public virtual void RemoveAt( int index )
  114. {
  115. if (index < 0 || index > Count )
  116. throw new ArgumentOutOfRangeException( "index" );
  117. TreeNode node = (TreeNode) list[ index ];
  118. list.RemoveAt( index );
  119. node.setParent ( null );
  120. }
  121. /// <summary>
  122. /// IList Interface implmentation.
  123. /// </summary>
  124. bool IList.IsReadOnly{
  125. get{
  126. // We allow addition, removeal, and editing of items after creation of the list.
  127. return false;
  128. }
  129. }
  130. bool IList.IsFixedSize{
  131. get{
  132. // We allow addition and removeal of items after creation of the list.
  133. return false;
  134. }
  135. }
  136. //[MonoTODO]
  137. object IList.this[int index]{
  138. get{
  139. throw new NotImplementedException ();
  140. }
  141. set{
  142. //FIXME:
  143. }
  144. }
  145. [MonoTODO]
  146. void IList.Clear(){
  147. throw new NotImplementedException ();
  148. }
  149. [MonoTODO]
  150. int IList.Add( object value){
  151. throw new NotImplementedException ();
  152. }
  153. [MonoTODO]
  154. bool IList.Contains( object value){
  155. throw new NotImplementedException ();
  156. }
  157. [MonoTODO]
  158. int IList.IndexOf( object value){
  159. throw new NotImplementedException ();
  160. }
  161. [MonoTODO]
  162. void IList.Insert(int index, object value){
  163. //FIXME:
  164. }
  165. [MonoTODO]
  166. void IList.Remove( object value){
  167. //FIXME:
  168. }
  169. [MonoTODO]
  170. void IList.RemoveAt( int index){
  171. //FIXME:
  172. }
  173. // End of IList interface
  174. /// <summary>
  175. /// ICollection Interface implmentation.
  176. /// </summary>
  177. int ICollection.Count{
  178. get{
  179. throw new NotImplementedException ();
  180. }
  181. }
  182. bool ICollection.IsSynchronized{
  183. get{
  184. throw new NotImplementedException ();
  185. }
  186. }
  187. object ICollection.SyncRoot{
  188. get{
  189. throw new NotImplementedException ();
  190. }
  191. }
  192. void ICollection.CopyTo(Array array, int index){
  193. //FIXME:
  194. }
  195. // End Of ICollection
  196. }
  197. }