Public Class BridgeDemo
  Inherits System.Windows.Forms.Form
  Private products As ArrayList
  Private br As Bridger           'obiekt klasy bridge dla listy 
  Private gbr As Bridger          'obiekt klasy bridge dla tabeli
  Private prodList, execList As VisList
  Friend WithEvents lsProdList As System.Windows.Forms.ListBox
  Friend WithEvents lsExecList As System.Windows.Forms.DataGrid
  Private fl As vbFile
  Private Sub init()
    Dim dtable As DataTable
    dtable = New DataTable("Products")
    Dim column As DataColumn
    column = New DataColumn("ProdName")

    dtable.Columns.Add(column)
    column = New DataColumn("Qty")

    dtable.Columns.Add(column)
    lsExecList.DataSource = dtable

    products = New ArrayList()
    'utwórz obiekty klasy visList
    execList = New ProductTable(lsExecList)
    prodList = New ProductList(lsProdList)

    'wczytaj dane
    readData(products)
    'utwórz dwa obiekty klasy bridge 
    'i wypełnij je danymi
    Dim prodBridge As New ListBridge(prodList)
    Dim tableBridge As New ListBridge(execList)
    prodBridge.addData(products)
    tableBridge.addData(products)

  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
  Private Sub readData(ByVal plist As ArrayList)
    Dim fl As vbFile
    Dim s As String
    fl = New vbFile("products.txt")
    fl.OpenForRead()
    s = fl.readLine

    While s.Length > 0
      Dim p As Product
      p = New Product(s)
      plist.Add(p)
      s = fl.readLine
    End While
  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.lsExecList = New System.Windows.Forms.DataGrid()
    Me.lsProdList = New System.Windows.Forms.ListBox()
    CType(Me.lsExecList, System.ComponentModel.ISupportInitialize).BeginInit()
    Me.SuspendLayout()
    '
    'lsExecList
    '
    Me.lsExecList.CaptionVisible = False
    Me.lsExecList.DataMember = ""
    Me.lsExecList.Location = New System.Drawing.Point(248, 40)
    Me.lsExecList.Name = "lsExecList"
    Me.lsExecList.RowHeadersVisible = False
    Me.lsExecList.Size = New System.Drawing.Size(184, 176)
    Me.lsExecList.TabIndex = 1
    '
    'lsProdList
    '
    Me.lsProdList.Location = New System.Drawing.Point(16, 40)
    Me.lsProdList.Name = "lsProdList"
    Me.lsProdList.Size = New System.Drawing.Size(176, 173)
    Me.lsProdList.TabIndex = 0
    '
    'BridgeDemo
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(440, 293)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lsExecList, Me.lsProdList})
    Me.Name = "BridgeDemo"
    Me.Text = "Basic bridge"
    CType(Me.lsExecList, System.ComponentModel.ISupportInitialize).EndInit()
    Me.ResumeLayout(False)

  End Sub

#End Region

End Class
