UserFormCollection.cs
上传用户:husern
上传日期:2022-03-24
资源大小:534k
文件大小:4k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. // -- FILE ------------------------------------------------------------------
  2. // name       : UserFormCollection.cs
  3. // project    : Itenso Web User Forms
  4. // created    : Jani Giannoudis - 2008.10.30
  5. // language   : c#
  6. // environment: .NET 2.0
  7. // copyright  : (c) 2008 by Itenso GmbH, Switzerland
  8. // --------------------------------------------------------------------------
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. namespace Itenso.WebUserForms.Controls
  13. {
  14. // ------------------------------------------------------------------------
  15. public class UserFormCollection : IUserFormCollection
  16. {
  17. // ----------------------------------------------------------------------
  18. public UserFormCollection()
  19. {
  20. } // UserFormCollection
  21. // ----------------------------------------------------------------------
  22. public int Count
  23. {
  24. get { return this.forms.Count; }
  25. } // Count
  26. // ----------------------------------------------------------------------
  27. public IUserForm this[ int index ]
  28. {
  29. get { return this.forms[ index ] as IUserForm; }
  30. } // this[]
  31. // ----------------------------------------------------------------------
  32. public IEnumerator<IUserForm> GetEnumerator()
  33. {
  34. return this.forms.GetEnumerator();
  35. } // GetEnumerator
  36. // ----------------------------------------------------------------------
  37. IEnumerator IEnumerable.GetEnumerator()
  38. {
  39. return this.forms.GetEnumerator();
  40. } // IEnumerable.GetEnumerator
  41. // ----------------------------------------------------------------------
  42. public int IndexOf( IUserForm form )
  43. {
  44. return this.forms.IndexOf( form );
  45. } // IndexOf
  46. // ----------------------------------------------------------------------
  47. public IUserForm FindByFormName( string formName )
  48. {
  49. foreach ( IUserForm form in this.forms )
  50. {
  51. if ( form.Header.Name.Equals( formName ) )
  52. {
  53. return form;
  54. }
  55. }
  56. return null;
  57. } // FindByFormName
  58. // ----------------------------------------------------------------------
  59. public int Add( IUserForm form )
  60. {
  61. if ( form == null )
  62. {
  63. throw new ArgumentNullException( "form" );
  64. }
  65. int insertPos = forms.Count;
  66. this.forms.Add( form );
  67. return insertPos;
  68. } // Add
  69. // ----------------------------------------------------------------------
  70. public void Add( IUserForm form, int pos )
  71. {
  72. this.forms.Insert( pos, form );
  73. } // Add
  74. // ----------------------------------------------------------------------
  75. public void AddAll( IEnumerable<IUserForm> forms )
  76. {
  77. if ( forms == null )
  78. {
  79. throw new ArgumentNullException( "forms" );
  80. }
  81. foreach ( IUserForm form in forms )
  82. {
  83. Add( form );
  84. }
  85. } // AddAll
  86. // ----------------------------------------------------------------------
  87. public void Remove( IUserForm form )
  88. {
  89. this.forms.Remove( form );
  90. } // Remove
  91. // ----------------------------------------------------------------------
  92. public void RemoveAt( int index )
  93. {
  94. this.forms.RemoveAt( index );
  95. } // RemoveAt
  96. // ----------------------------------------------------------------------
  97. public void Clear()
  98. {
  99. this.forms.Clear();
  100. } // Clear
  101. // ----------------------------------------------------------------------
  102. public IUserForm[] ToArray()
  103. {
  104. IUserForm[] entries = new IUserForm[ Count ];
  105. if ( entries.Length > 0 )
  106. {
  107. CopyTo( entries, 0 );
  108. }
  109. return entries;
  110. } // ToArray
  111. // ----------------------------------------------------------------------
  112. public void CopyTo( IUserForm[] array, int index )
  113. {
  114. this.forms.CopyTo( array, index );
  115. } // CopyTo
  116. // ----------------------------------------------------------------------
  117. // members
  118. private readonly List<IUserForm> forms = new List<IUserForm>();
  119. } // class UserFormCollection
  120. } // namespace Itenso.WebUserForms.Controls
  121. // -- EOF -------------------------------------------------------------------