Public Class ObsForm
  Inherits System.Windows.Forms.Form
  Implements Subject
  Private observers As ArrayList

  Private Sub init()
    Dim evh As EventHandler = New EventHandler(AddressOf RadioHandler)
    AddHandler opRed.Click, evh
    AddHandler opBlue.Click, evh
    AddHandler opGreen.Click, evh
    observers = New ArrayList()
    Dim lscol As New listObs(Me)
    lscol.Show()
    Dim frcol As New ColrForm(Me)
    frcol.Show()
  End Sub

  Protected Sub RadioHandler(ByVal sender As Object, ByVal e As EventArgs)
    Dim i As Integer
    Dim rbut As RadioButton = CType(sender, RadioButton)
    For i = 0 To observers.Count - 1
      Dim obs As Observer = CType(observers(i), Observer)
      obs.sendNotify(rbut.Text)
    Next i
  End Sub
  '-----
  Public Sub registerInterest(ByVal obs As vbnetObserver.Observer) Implements vbnetObserver.Subject.registerInterest
    observers.Add(obs)
  End Sub

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
    init()

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
  Friend WithEvents opRed As System.Windows.Forms.RadioButton
  Friend WithEvents opGreen As System.Windows.Forms.RadioButton
  Friend WithEvents opBlue As System.Windows.Forms.RadioButton

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.GroupBox1 = New System.Windows.Forms.GroupBox()
    Me.opRed = New System.Windows.Forms.RadioButton()
    Me.opGreen = New System.Windows.Forms.RadioButton()
    Me.opBlue = New System.Windows.Forms.RadioButton()
    Me.GroupBox1.SuspendLayout()
    Me.SuspendLayout()
    '
    'GroupBox1
    '
    Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.opBlue, Me.opGreen, Me.opRed})
    Me.GroupBox1.Location = New System.Drawing.Point(48, 40)
    Me.GroupBox1.Name = "GroupBox1"
    Me.GroupBox1.Size = New System.Drawing.Size(136, 96)
    Me.GroupBox1.TabIndex = 0
    Me.GroupBox1.TabStop = False
    Me.GroupBox1.Text = "Colors"
    '
    'opRed
    '
    Me.opRed.Location = New System.Drawing.Point(24, 16)
    Me.opRed.Name = "opRed"
    Me.opRed.Size = New System.Drawing.Size(104, 16)
    Me.opRed.TabIndex = 0
    Me.opRed.Text = "Red"
    '
    'opGreen
    '
    Me.opGreen.Location = New System.Drawing.Point(24, 44)
    Me.opGreen.Name = "opGreen"
    Me.opGreen.Size = New System.Drawing.Size(72, 16)
    Me.opGreen.TabIndex = 1
    Me.opGreen.Text = "Green"
    '
    'opBlue
    '
    Me.opBlue.Location = New System.Drawing.Point(24, 72)
    Me.opBlue.Name = "opBlue"
    Me.opBlue.Size = New System.Drawing.Size(64, 16)
    Me.opBlue.TabIndex = 2
    Me.opBlue.Text = "Blue"
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(256, 205)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1})
    Me.Name = "Form1"
    Me.Text = "Observer demo"
    Me.GroupBox1.ResumeLayout(False)
    Me.ResumeLayout(False)

  End Sub

#End Region

End Class
