Public Class Form1
  Inherits System.Windows.Forms.Form
  Private Seedings As New ArrayList()
  Private Sub init()
    Dim ev As Events

    ev = New Prelimevent("100free.txt", 6)    'utwórz obiekt zawodów eliminacyjnych

    Seedings.Add(ev.getSeeding)               'utwórz rozstawienie i zapisz w ArrayList
    lsEvents.Items.Add("100 Free")

    ev = New TimedFinalEvent("500free.txt", 6) 'utwórz obiekt zawodów finałowych
    Seedings.Add(ev.getSeeding)               'utwórz rozstawienie
    lsEvents.Items.Add("500 Free")            'i dodaj do ArrayList

  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 lsEvents As System.Windows.Forms.ListBox
  Friend WithEvents lsSwimmers As System.Windows.Forms.ListBox
  Friend WithEvents btSeed As System.Windows.Forms.Button

  '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.lsEvents = New System.Windows.Forms.ListBox()
    Me.btSeed = New System.Windows.Forms.Button()
    Me.lsSwimmers = New System.Windows.Forms.ListBox()
    Me.SuspendLayout()
    '
    'lsEvents
    '
    Me.lsEvents.Location = New System.Drawing.Point(24, 24)
    Me.lsEvents.Name = "lsEvents"
    Me.lsEvents.Size = New System.Drawing.Size(128, 186)
    Me.lsEvents.TabIndex = 0
    '
    'btSeed
    '
    Me.btSeed.Location = New System.Drawing.Point(160, 48)
    Me.btSeed.Name = "btSeed"
    Me.btSeed.Size = New System.Drawing.Size(48, 24)
    Me.btSeed.TabIndex = 2
    Me.btSeed.Text = "Seed"
    '
    'lsSwimmers
    '
    Me.lsSwimmers.Location = New System.Drawing.Point(216, 24)
    Me.lsSwimmers.Name = "lsSwimmers"
    Me.lsSwimmers.Size = New System.Drawing.Size(184, 186)
    Me.lsSwimmers.TabIndex = 1
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(424, 245)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btSeed, Me.lsSwimmers, Me.lsEvents})
    Me.Name = "Form1"
    Me.Text = "Seeding demo"
    Me.ResumeLayout(False)

  End Sub

#End Region


  Private Sub btSeed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSeed.Click
    Dim i As Integer
    Dim sd As Seeding
    Dim swmrs As ArrayList
    Dim sw As Swimmer
    Dim sline As String
    Dim lsCol As ArrayList

    i = lsEvents.SelectedIndex

    If i >= 0 Then
      sd = CType(Seedings(i), Seeding)
      sd.seed()
      swmrs = sd.getSeeding
      lsSwimmers.Items.Clear()
      lsCol = New ArrayList()

      For i = 0 To swmrs.Count - 1
        sw = CType(swmrs(i), Swimmer)
        sline = Str$(sw.getHeat) + Str$(sw.getLane) + " " + sw.getName
        sline = sline + " " + sw.getClub + " " + sw.getTime.ToString
        lsSwimmers.Items.Add(sline)
      Next i

    End If
  End Sub

  Private Sub lsEvents_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lsEvents.SelectedIndexChanged
    btSeed_Click(sender, e)
  End Sub
End Class
