Public Class FormEx
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal key As String)
MyBase.New()
_formsex.Add(Me, key)
End Sub
Private Shared _formsex As FormsExCollection = New FormsExCollection()
Public Shared Property Forms() As FormsExCollection
Get
Return _formsex
End Get
Set(ByVal Value As FormsExCollection)
_formsex = Value
End Set
End Property
Public Overloads Overrides Sub Dispose()
If _formsex.Contains(Me) Then _formsex.Remove(Me)
MyBase.Dispose(True)
GC.SuppressFinalize(True)
End Sub
End Class
Public Class FormsExCollection
Private _keys As System.Collections.ArrayList = New System.Collections.ArrayList()
Private _formsex As System.Collections.ArrayList = New System.Collections.ArrayList()
Friend Function Add(ByRef formex As FormEx, ByVal key As String) As Integer
_keys.Add(key)
Return _formsex.Add(formex)
End Function
Friend Sub Remove(ByRef formex As FormEx)
_keys.RemoveAt(_formsex.IndexOf(formex))
_formsex.Remove(formex)
End Sub
Public ReadOnly Property Count() As Integer
Get
Return _formsex.Count()
End Get
End Property
Public Function Contains(ByRef formex As FormEx) As Boolean
Return _formsex.Contains(formex)
End Function
Public Property Item(ByVal index As Integer) As FormEx
Get
Return CType(_formsex(index), FormEx)
End Get
Set(ByVal Value As FormEx)
_formsex(index) = Value
End Set
End Property
Public Property Item(ByVal key As String) As FormEx
Get
Return CType(_formsex(_keys.IndexOf(key)), FormEx)
End Get
Set(ByVal Value As FormEx)
_formsex(_keys.IndexOf(key)) = Value
End Set
End Property
End Class