Public Class Form1
  Inherits System.Windows.Forms.Form
  Private med As Mediator

  Private Sub init()
    'Wywoływana przez konstruktor
    Dim evh As EventHandler
    evh = New EventHandler(AddressOf CommandHandler)
    AddHandler btCopy.Click, evh
    AddHandler btClear.Click, evh
    AddHandler kList.SelectedIndexChanged, evh
    med = New Mediator()
    btCopy.setMediator(med)
    btClear.setMediator(med)
    kList.setMediator(med)
    'Rejestruj pozostałe kontrolki
    med.register(txName)
    med.register(lsPicked)
    med.init()                    'Inicjuj mediatora
  End Sub

  Public Sub CommandHandler(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim cmd As Command = CType(sender, Command)
    cmd.Execute()
  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 btCopy As Mediate.CpyButton
  Friend WithEvents btClear As Mediate.ClrButton
  Friend WithEvents lsPicked As System.Windows.Forms.ListBox
  Friend WithEvents txName As System.Windows.Forms.TextBox
  Friend WithEvents kList As Mediate.KidsListBox


  '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.btCopy = New Mediate.CpyButton()
    Me.lsPicked = New System.Windows.Forms.ListBox()
    Me.txName = New System.Windows.Forms.TextBox()
    Me.btClear = New Mediate.ClrButton()
    Me.kList = New Mediate.KidsListBox()
    Me.SuspendLayout()
    '
    'btCopy
    '
    Me.btCopy.Location = New System.Drawing.Point(192, 16)
    Me.btCopy.Name = "btCopy"
    Me.btCopy.Size = New System.Drawing.Size(56, 24)
    Me.btCopy.TabIndex = 3
    Me.btCopy.Text = "Copy"
    '
    'lsPicked
    '
    Me.lsPicked.Location = New System.Drawing.Point(184, 56)
    Me.lsPicked.Name = "lsPicked"
    Me.lsPicked.Size = New System.Drawing.Size(144, 173)
    Me.lsPicked.TabIndex = 1
    '
    'txName
    '
    Me.txName.Location = New System.Drawing.Point(24, 8)
    Me.txName.Name = "txName"
    Me.txName.Size = New System.Drawing.Size(144, 20)
    Me.txName.TabIndex = 2
    Me.txName.Text = ""
    '
    'btClear
    '
    Me.btClear.Location = New System.Drawing.Point(272, 16)
    Me.btClear.Name = "btClear"
    Me.btClear.Size = New System.Drawing.Size(56, 24)
    Me.btClear.TabIndex = 4
    Me.btClear.Text = "Clear"
    '
    'kList
    '
    Me.kList.Location = New System.Drawing.Point(24, 56)
    Me.kList.Name = "kList"
    Me.kList.Size = New System.Drawing.Size(144, 173)
    Me.kList.TabIndex = 5
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(344, 261)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.kList, Me.btClear, Me.btCopy, Me.txName, Me.lsPicked})
    Me.Name = "Form1"
    Me.Text = "Mediator demo"
    Me.ResumeLayout(False)

  End Sub

#End Region

End Class
