Public Class Protodemo
  Inherits System.Windows.Forms.Form
  Private swd, tsd As SwimData
  Friend WithEvents btClone As System.Windows.Forms.Button
  Friend WithEvents leftList As System.Windows.Forms.ListBox
  Friend WithEvents rightList As System.Windows.Forms.ListBox
  Friend WithEvents btRefresh As System.Windows.Forms.Button

  Private Sub loadLeftList()
    Dim sw As Swimmer
    Dim s As String
    Dim t As Single

    swd.MoveFirst()
    leftList.Items.Clear()
    While swd.hasMoreElements
      sw = swd.getNextSwimmer
      s = sw.getName + Convert.ToChar(9) + sw.getClub + " "
      t = sw.getTime
      s = s + " " + t.ToString

      leftList.Items.Add(s)
    End While
  End Sub

  Public Sub loadRightList()
    Dim sw As Swimmer
    Dim s As String
    Dim t As Single
    While tsd.hasMoreElements
      sw = tsd.getNextSwimmer
      s = sw.getName + Convert.ToChar(9) + sw.getClub + " "
      t = sw.getTime
      s = s + " " + t.ToString
      rightList.Items.Add(s)
    End While
  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
    swd = New SexSwimData("swimmers.txt")
    loadLeftList()
  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

  '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.leftList = New System.Windows.Forms.ListBox()
    Me.rightList = New System.Windows.Forms.ListBox()
    Me.btRefresh = New System.Windows.Forms.Button()
    Me.btClone = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'leftList
    '
    Me.leftList.Location = New System.Drawing.Point(16, 32)
    Me.leftList.Name = "leftList"
    Me.leftList.Size = New System.Drawing.Size(184, 186)
    Me.leftList.TabIndex = 0
    '
    'rightList
    '
    Me.rightList.Location = New System.Drawing.Point(280, 32)
    Me.rightList.Name = "rightList"
    Me.rightList.Size = New System.Drawing.Size(192, 186)
    Me.rightList.TabIndex = 1
    '
    'btRefresh
    '
    Me.btRefresh.Location = New System.Drawing.Point(208, 112)
    Me.btRefresh.Name = "btRefresh"
    Me.btRefresh.Size = New System.Drawing.Size(56, 24)
    Me.btRefresh.TabIndex = 3
    Me.btRefresh.Text = "Refresh"
    '
    'btClone
    '
    Me.btClone.Location = New System.Drawing.Point(216, 56)
    Me.btClone.Name = "btClone"
    Me.btClone.Size = New System.Drawing.Size(48, 24)
    Me.btClone.TabIndex = 2
    Me.btClone.Text = "Clone"
    '
    'Protodemo
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(488, 273)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btRefresh, Me.btClone, Me.rightList, Me.leftList})
    Me.Name = "Protodemo"
    Me.Text = "Prototype demo"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub btClone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClone.Click
    tsd = New TimeSwimData()
    swd.Clone(tsd)
    tsd.sort()
    loadRightList()
  End Sub

  Private Sub btRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btRefresh.Click
    loadLeftList()
  End Sub
End Class
